doc:user:advanced:parallel
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| doc:user:advanced:parallel [2025/11/25 07:46] – boman | doc:user:advanced:parallel [2025/11/25 08:23] (current) – [Read the details] boman | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| Metafor can be run in parallel on several cores of your computer, but this is not done automatically. By default Metafor uses a single core for the calculation (and another one for the visualisation when it is enabled). | Metafor can be run in parallel on several cores of your computer, but this is not done automatically. By default Metafor uses a single core for the calculation (and another one for the visualisation when it is enabled). | ||
| + | |||
| + | ===== Run Metafor with several threads ===== | ||
| To enable parallelism, | To enable parallelism, | ||
| Line 12: | Line 14: | ||
| Doucle-click on the new icon and check that 4 threads are enabled: | Doucle-click on the new icon and check that 4 threads are enabled: | ||
| - | {{: | + | {{: |
| + | |||
| + | ===== Change your python file ===== | ||
| In order to take advantage of parallel loops, you must do 2 things: | In order to take advantage of parallel loops, you must do 2 things: | ||
| - | * you must use a parallel linear solver | + | |
| - | * you must explicitly enable parallel loops in your python file | + | * you must explicitly enable parallel loops in your python file |
| - | ===== Parallel | + | ==== Use a parallel |
| Line 26: | Line 31: | ||
| solver = DSSolver() | solver = DSSolver() | ||
| solman.setSolver(solver) | solman.setSolver(solver) | ||
| - | | ||
| - | ===== Parallel loops ===== | ||
| - | Add these lines enywhere | + | ==== Activate parallel loops ==== |
| + | |||
| + | Add these lines anywhere | ||
| StrVectorBase.useTBB() | StrVectorBase.useTBB() | ||
| Line 38: | Line 43: | ||
| The third line activates parallel contact management. | The third line activates parallel contact management. | ||
| + | These 3 lines will display 3 blocks of messages such as this one: | ||
| + | |||
| + | \************************************************** | ||
| + | | ||
| + | Structural vectors will be computed in parallel. | ||
| + | However, some combinations of elements/ | ||
| + | are NOT thread safe yet! | ||
| + | => Erroneous results / program crash may occur!. | ||
| + | \************************************************** | ||
| + | |||
| + | This is the normal behaviour. Some parts of Metafor are not thread-safe yet. However, if you are using classical commands, algorithms and methods of Metafor, enabling parallelism is totally safe. | ||
| + | |||
| + | Anyway you must keep in mind that parallel calculations are not performed in the same order each time you run the problem. It means that parallel results are not reproductible. You can obtain slightly different results when running Metafor twice on the same test. This is a common behaviour in parallel solvers. | ||
| + | |||
| + | |||
| + | ===== Read CPU times ===== | ||
| + | |||
| + | During the calculation, | ||
| + | |||
| + | \*** STEP 9: t= 0.000149616 - dt= 4.3125e-05 - CPU= 1m24.97s/ | ||
| + | |||
| + | The first time is the "CPU time". This is the sum of the calculation times spent in each core of your CPU. This timer runs much faster than the " | ||
| + | |||
| + | Thus, if you want to compare 2 simulations, | ||
| + | |||
| + | [TSC-CPU] | ||
| + | [TSC-REA] | ||
| + | [TSC-KER] | ||
| + | |||
| + | The third time (kernel) is the CPU time spent by parallel management routines and other system calls. This time is included in the "Real CPU time". | ||
| + | |||
| + | ===== Read the details ===== | ||
| + | |||
| + | The time spent in each part of the code is summarized in '' | ||
| + | |||
| + | If you are interested in analysing the efficiency of your model, you can have a look at its contents (it is a table similar to this one): | ||
| + | |||
| + | ^ ^user ^real ^kernel^ | ||
| + | |GEN_EXT_FORC_TXTYTZ |3.78125 |0.15 |0.109375| | ||
| + | |GEN_INTER_FORC_TXTYTZ |2.9375 |0.572 |0.0625| | ||
| + | |Metafor |47.1562 |12.983 |3.35938| | ||
| + | |ObjectiveFunction |0| 0| 0| | ||
| + | |ValuesManager |0.96875 |0.594| 0.109375| | ||
| + | |buildK_TXTYTZ |12.5156 |1.737| 0.78125| | ||
| + | |contactDetection |7.6875 |1.888 |0.296875| | ||
| + | |prepro |0.390625 |0.731 |0.328125| | ||
| + | |saveFacs |0.21875 |0.17 |0.015625| | ||
| + | |solveK_TXTYTZ |12.5469 |1.883 |0.796875| | ||
| + | |steps |0.75 |0.675 |0.046875| | ||
doc/user/advanced/parallel.1764053219.txt.gz · Last modified: by boman
