Run calculix multithreaded

About the development of the FEM module/workbench.

Moderator: bernd

User avatar
-alex-
Veteran
Posts: 1856
Joined: Wed Feb 13, 2019 9:42 pm
Location: France

Re: Run calculix multithreaded

Post by -alex- »

Kailee71 wrote: Thu Mar 12, 2020 6:34 pm Hi Thanks for your reply - unfortunately this made no difference; any other pointers?
The numbers of CPU's in FEM Calcuix preferences setting GUI did never work neither for me, but this code in python console did the trick:

Code: Select all

import multiprocessing
import os
cpu_cores = multiprocessing.cpu_count()  # this finds number of your CPUs and use them all
os.putenv('OMP_NUM_THREADS', str(cpu_cores))

I have found that in this topic some times ago: https://forum.freecadweb.org/viewtopic. ... 20#p151713

I don't know why GUI preferences have no effects on my machines (V0.18 on Windows 10 the same).


OS: Debian GNU/Linux 10 (buster) (LXDE/LXDE)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19858 (Git)
Build type: Debug
Branch: master
Hash: dbe292496b56147c081761084774f42bda56ea90
Python version: 3.7.3
Qt version: 5.11.3
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: French/France (fr_FR)
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Run calculix multithreaded

Post by Kunda1 »

-alex- wrote: Thu Mar 12, 2020 10:02 pm The numbers of CPU's in FEM Calcuix preferences setting GUI did never work neither for me, but this code in python console did the trick
Was wondering on processing speed/time here, did you happen to make any side-by-side comparisons between multi-threading and non-multi-threading results ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
thschrader
Veteran
Posts: 3129
Joined: Sat May 20, 2017 12:06 pm
Location: Germany

Re: Run calculix multithreaded

Post by thschrader »

Kunda1 wrote: Sat Mar 14, 2020 5:31 pm Was wondering on processing speed/time here, did you happen to make any side-by-side comparisons between multi-threading and non-multi-threading results ?
multiprocessing.JPG
multiprocessing.JPG (104.63 KiB) Viewed 3353 times
done with
OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19697 (Git)
Build type: Release
Branch: master
Hash: 8832356802011bf5d70e9d6f0efa89c47bc70a91
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Germany (de_DE)
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Run calculix multithreaded

Post by Kunda1 »

thschrader wrote: Sun Mar 15, 2020 11:07 amdone with
Great news! Thanks for conducting this test.
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
-alex-
Veteran
Posts: 1856
Joined: Wed Feb 13, 2019 9:42 pm
Location: France

Re: Run calculix multithreaded

Post by -alex- »

Kunda1 wrote: Sat Mar 14, 2020 5:31 pm Was wondering on processing speed/time here, did you happen to make any side-by-side comparisons between multi-threading and non-multi-threading results ?
Thomas had already replied, I give another comparison just for information:
On a linear static study with 21 contacts surface-to-surface, 157572 1st order tetrahedrons (I can't share any picture sorry):
On a powerless computer Intel core duo 2 CPU 2.5GHz 3Go RAM available on MSwin10 32Bit:
- calculix linear 1 CPU: 1661.3 s
- calculix linear 2 CPU: 866.3 s
ratio= 0.52

On a smaller model with multi-contacts (named "lamelles"), the ratio is not so good: 0.96
see this post (french): https://forum.freecadweb.org/viewtopic. ... 10#p317135

I will try to excecute the "big" model on a raspberry PI4 just for fun, I'll tell the results here.
User avatar
-alex-
Veteran
Posts: 1856
Joined: Wed Feb 13, 2019 9:42 pm
Location: France

Re: Run calculix multithreaded

Post by -alex- »

Results of the same linear static study as above post, with 21 contacts surface-to-surface and 157572 1st order tetrahedrons on Raspberry PI4 4GB:
- 1CPU: 1288s
- 4CPU: 664s
Ratio=0,52
Not so bad, this tiny RPI4 is pretty powerfull and quiet :D
Last edited by -alex- on Mon Mar 16, 2020 11:45 pm, edited 3 times in total.
User avatar
aomanchuria
Posts: 31
Joined: Fri Oct 09, 2020 3:13 pm

Re: Run calculix multithreaded

Post by aomanchuria »

I'm having an interesting problem. I got a friend of a friend who knows a guy to let me use a nice computer with lots of CPUs. More than my personal computer will ever have this year or next. So anyway, I set up the computer to use all cores and the result was that calculix... while calculating a plastic material model with a good sized mesh, it would bang the matrix stuff in like a second or three then it would have a few seconds of no activity, then it would do the vector calcs and move on to bang another matrix calc for the next time step. The performance was no better than the performance I get on my personal computer with 8 cores. What I noticed is that for vector calcs it only uses one to a few CPUs. Same thing when I translate the .frd file to .vtu using ccx2paraview. It only uses a single CPU at a time. It was embarrassing. I had really high hopes.

So I wonder if I can at least use more cores in between time steps, and maybe get a better .vtu translator that can use more than one core. Ccx2paraview has multithreading in its to do list though.
User avatar
flachyjoe
Veteran
Posts: 1869
Joined: Sat Mar 31, 2012 12:00 pm
Location: Limoges, France

Re: Run calculix multithreaded

Post by flachyjoe »

Hi aomanchuria,
for such CCX technical issue I think you can ask Guido Dhondt directly, see http://www.dhondt.de/index.html
- Flachy Joe -
Image
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Run calculix multithreaded

Post by bernd »

or on Calculix user forum https://calculix.discourse.group/
User avatar
aomanchuria
Posts: 31
Joined: Fri Oct 09, 2020 3:13 pm

Re: Run calculix multithreaded

Post by aomanchuria »

yeah I guess that's where we need to ask for multithreading

Here is an moderate example using my normal computer with just 8 CPUs. You can see that using spooles, but also pardiso, the program doesn't seem to use any multithreading after the whole matrix inversion calculation jazz. It would be cool to see that 10% single CPU task become a nice little quick blip between 8 CPUs at 100%.

I'm trying changing the parameters around:

########### set the processor number to 8
os.environ['CCX_NPROC_STIFFNESS'] = "8"
os.environ['NUMBER_OF_PROCESSORS'] = "8"
os.environ['OMP_NUM_THREADS'] = "40"
os.environ['NUMBERS_OF_PROCESSORS'] = "8"

os.environ['CCX_NPROC_STIFFNESS'] = "40"
os.environ['CCX_NPROC_EQUATION_SOLVER'] = "40"
os.environ['CCX_NPROC_RESULTS'] = "40"
os.environ['CCX_NPROC_VIEWFACTOR'] = "40"
os.environ['CCX_NPROC_CFD'] = "40"
os.environ['CCX_NPROC_BIOTSAVART'] = "40"

Seems that the number of threads parameter is not really about threads

Using up to 8 cpu(s) for the stress calculation.
Using up to 8 cpu(s) for the symmetric stiffness/mass contributions.
Using up to 8 cpu(s) for the asymmetric stiffness/mass contributions.
Factoring the system of equations using the unsymmetric spooles solver
Using up to 8 cpu(s) for spooles.

it may be interesting to get feedback from calculix as to what parameter might increase the calculation speed. like an HTML or python code analysis.
Attachments
Screenshot 2021-06-09 104633.png
Screenshot 2021-06-09 104633.png (146.98 KiB) Viewed 2688 times
Post Reply