Speeding up the FD calculations

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Shivangi Giri
Posts: 51
Joined: Sun Jul 02, 2017 3:04 am

Speeding up the FD calculations

Post by Shivangi Giri » Mon Dec 19, 2022 1:39 am

Hello,
I have a MATLAB code that takes 12 mins to execute. I have to reduce it to less than a minute. However, I am not sure which parallel computing technique is compatible with OpenSim.
Since the integration in the manager takes 80% of the execution time, I was thinking if I can pass this part of code to execute on multiple threads/workers. The part of the code is mentioned below

manager = Manager(main_model); % Manager will be the forward dynamics integrator
state.setTime(0);

manager.initialize(state); % State of the model is given to the manager for update
state = manager.integrate(timed); % Integrate for the time duration of 'timed'
main_model.realizeAcceleration(state);

If anyone has tried a similar problem, kindly help.

Regards,
Shivangi

Tags:

User avatar
Samuele Gould
Posts: 16
Joined: Tue Nov 19, 2019 5:53 am

Re: Speeding up the FD calculations

Post by Samuele Gould » Thu Jan 05, 2023 7:29 am

Hi Shivangi,

I had looked to do something similar. From my limited understanding (maybe another community member with a better understand can clarify) the forward dynamic calculations are performed on a single core, and there does not seem to be a way of accessing how the calculations are distributed across cores. So I don't think what you want to do is possible, at least not on the official release of OpenSim.

Maybe this post could help: viewtopicPhpbb.php?f=91&t=15042&p=43684&start=0&view=

However, if you are running many forward dynamic simulations, you can instead parallise the simulations. Each forward dynamic simulation is computed on a different core, this doesn't speed up an individual simulation, but will reduce the total amount of time you spend waiting for results.

Best,
Samuele

User avatar
Ayman Habib
Posts: 2248
Joined: Fri Apr 01, 2005 12:24 pm

Re: Speeding up the FD calculations

Post by Ayman Habib » Fri Jan 06, 2023 1:30 pm

Thanks Samuele, well said.

I'd just add that forward integration is naturally sequential since it evolves over time so it'd be hard to make a general scheme that integrates in parallel. However in cases of algorithms that run multiple forward integrations (e.g. in an optimization) this becomes an easier problem to tackle.

Best regards,
-Ayman

User avatar
Shivangi Giri
Posts: 51
Joined: Sun Jul 02, 2017 3:04 am

Re: Speeding up the FD calculations

Post by Shivangi Giri » Fri Jan 13, 2023 4:25 am

Thank you, Samuele and Ayman for your replies. Much appreciate your help.

Regards,
Shivangi

POST REPLY