Feasibility of Sim4Life GPU Acceleration and Multithreaded Script Execution
-
Hello everyone! I'm currently running simulations with Sim4Life and would like to know if it's possible to improve efficiency through GPU acceleration or by running multiple scripts in parallel using multithreading. Could anyone share some experience or provide simple example code? Thanks a lot!
-
-
in theory, you can do anything you could do in a "normal" Python installation, in the Sim4Life Python. You might just have to install the package (go to the Python folder in
C:\Program Files\Sim4Life_<installed version>\Python
and runpython.exe -m pip install <some package>
. -
the analysis pipeline can run independent jobs in parallel when you run it from the GUI. In Python, the "Update" is probably blocking. @Sylvain might know?
-
-
-
in theory, you can do anything you could do in a "normal" Python installation, in the Sim4Life Python. You might just have to install the package (go to the Python folder in
C:\Program Files\Sim4Life_<installed version>\Python
and runpython.exe -m pip install <some package>
. -
the analysis pipeline can run independent jobs in parallel when you run it from the GUI. In Python, the "Update" is probably blocking. @Sylvain might know?
-
-
@bryn Is it correct that the EM LF Electro series of solvers do not support GPU acceleration?
@lucky_lin The EM LF solvers do not support GPU acceleration, that is correct. They do use multi-processing on the CPU, though. You can enable that in the solver's setting of any LF simulation, provided your license allows it.
As for multithreading/multithreading via Python scripts, it is in general entirely possible but the way to proceed (and whether or not it might be worth it) depends on what your scripts are doing (e.g. pre-processing grids and voxels, running simulations, or doing postprocessing) and what are the performance bottlenecks.
-
@Sylvain Is this how to set up multi-core processing in a Python script:
solver_settings = simulation.SolverSettings solver_settings.NumberOfProcesses = 0 # use all available cores
@lucky_lin Yes, that looks correct.
You probably know this already, but for the sake of completeness (and for the other readers) note that you can find the Python equivalent of most (and ideally all) simulation settings by setting up a simulation in the GUI, changing the desired parameters from their default values, right-clicking on the simulation and choosing "To Python" in the menu. This should create a script visible in the Scripter window (click VIEW -> Scripter if it is not visible).
-
@lucky_lin Yes, that looks correct.
You probably know this already, but for the sake of completeness (and for the other readers) note that you can find the Python equivalent of most (and ideally all) simulation settings by setting up a simulation in the GUI, changing the desired parameters from their default values, right-clicking on the simulation and choosing "To Python" in the menu. This should create a script visible in the Scripter window (click VIEW -> Scripter if it is not visible).
-
@Sylvain
If I set solver_settings.NumberOfProcesses to 0 or a number greater than 3, the simulation fails, even though the computer I'm using has 208 cores.@lucky_lin There could be many reasons, but the usual suspects would be licenses (i.e. you run out of MPI licenses to run on different processes), or RAM (parallelized simulations can use significantly more RAM and it may exceed what your operating system allows).
Best is, in general, to describe what you are doing (a screenshot of the simulation settings usually gives a lot of information, such as solver type and grid size), report the exact error you are getting (e.g. from the Console), and check the solver logs for errors (those due to license issues would typically be visible there).
I hope this helps already! -
@lucky_lin There could be many reasons, but the usual suspects would be licenses (i.e. you run out of MPI licenses to run on different processes), or RAM (parallelized simulations can use significantly more RAM and it may exceed what your operating system allows).
Best is, in general, to describe what you are doing (a screenshot of the simulation settings usually gives a lot of information, such as solver type and grid size), report the exact error you are getting (e.g. from the Console), and check the solver logs for errors (those due to license issues would typically be visible there).
I hope this helps already!@Sylvain I exported the electric field results from an AC simulation and found that the last six columns of the data are imaginary numbers. Are these the electric field values in three different directions? Why aren't they time-varying? Did I only export the peak values?