Parallel computing for OpenSim Matlab code

9 ビュー (過去 30 日間)
Shivangi Giri
Shivangi Giri 2022 年 12 月 21 日
回答済み: Infinite_king 2023 年 12 月 14 日
Hello,
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
state.setTime((i)*timed);
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
end
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.
Regards,
Shivangi

回答 (1 件)

Infinite_king
Infinite_king 2023 年 12 月 14 日
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.

カテゴリ

Help Center および File ExchangeGPU Computing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by