Improving simulation speed in Python #2965
-
I'd like to improve the speed of my simulation, and thought of implementing the multiprocessing module in my simulation to distribute the load among CPUs, but I don't know how to split the simulation into different processes. I've tried including the pool function in the
part, but it doesn't seem to be working, either. If it's of any help, the AdvanceTimer profiler tells me that most of the computation load is from the constraint solver. I've tried changing the solvers and solver parameters, but to no avail. How can I speed up my simulation? I've attached my current code to this post |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hello @Hellscythe789 From what I can read in your scene, you tried using multithreading by:
I warn you that you maybe created a multithreading bottleneck here. In any case, the mentioned techniques of multithreading do not have any impact on the constraint solving step, which appears to be the bottleneck of your simulation. There is not much you can do to speed up this process using multithreading. However you can try to:
Note that there is a page dedicated to improving the performances on the documentation website: https://www.sofa-framework.org/community/doc/using-sofa/performances/improve-performances/ Alex |
Beta Was this translation helpful? Give feedback.
-
Sorry for the late update. I replaced the ParallelBruteForceBroadPhase and ParallelBVHNarrowPhase components with the regular versions, replaced CGLinearSolver with SparseLDLSolver, and made my meshes a lot coarser overall. I'd say 7 fps on contact is a much better result than 1-2 fps. Thank you @alxbilger ! |
Beta Was this translation helpful? Give feedback.
Hello @Hellscythe789
From what I can read in your scene, you tried using multithreading by:
parallelODESolving
andparallelCollisionDetectionAndFreeMotion
in theFreeMotionAnimationLoop
.ParallelBruteForceBroadPhase
andParallelBVHNarrowPhase
to speed up the collision detection.I warn you that you maybe created a multithreading bottleneck here.
ParallelBruteForceBroadPhase
is interesting if you have many objects, otherwise, useBruteForceBroadPhase
.ParallelBVHNarrowPhase
is interesting if you have many elements in your collision models. However, due toparallelCollisionDetectionAndFreeMotion
andparallelODESolving
, you are already doing jobs on all your cores. SoParallelB…