Clear Filters
Clear Filters

Parallel computing for OpenSim Matlab code

13 views (last 30 days)
I was to speed up my MATLAB code which uses OpenSim libraryies and model. The time of execution is most for the integration part. I was thinking if I can speed it up using parallel computing or maybe by assigning it to the GPU.
The sample code is
import org.opensim.modeling.*
main_model = Model('DAS_to_arm26.osim');
state = main_model.initSystem();
for i=initial:final
manager = Manager(main_model); % Manager will be the forward dynamics integrator
manager.initialize(state); % State of the model is given to the manager, so that this state can be updated once the integration is done
state = manager.integrate((i+1)*timed); ----->This line takes most time to execution for each iteration
Has anyone ever tried such a thing. Kindly help.
I posted the same question on OpenSim forum, but it has been days since I got an answer.

Answers (1)

Infinite_king on 14 Dec 2023
Hi Shivangi Giri,
I understand that you are seeking to speed up the script using the "Parallel Computing Toolbox" (PCT) or by shifting calculations to the GPU.
It depends upon the specific operations that you are performing.
  1. When dealing with a for loop where each iteration's calculations are independent of others, leverage the 'parfor' (parallel for) functionality.
  2. ‘parfor' enables parallelization of the loop, allowing independent calculations to be performed concurrently, thereby reducing overall execution time. Refer the following MATLAB document for more info,
  1. If you are performing operations on large set of data, then you can transfer the data to GPU and then proceed to perform the operation. This will improve runtime if the operation is supported on GPU. Refer the following MATLAB documentations for more info.
Hope this is helpful.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!