How to run a simulink model in rapid accelerator on a cluster?
3 views (last 30 days)
Show older comments
I am trying to calculate a simulink model in parallel on a cluster. According to serveral sources [1,2] from the internet the simulink model should be executed in rapid accelerator to run faster. However, all examples which I have found are running with the profile parpool('local').
Update: two files attached for simplicity. Please try them out.
My problem is, that my calculations works on parpool('local') but not if I am using a cluster profile. Given the following code
First I open a cluster by
poolhdl = parpool(cluster_name, 4);
Define my tunable parameters (I have a simulink model with a sine where I change offset and amplitude. According to [1] I enable 'Inline Parameters'.)
mdl = 'parallel_computing_sim';
a = Simulink.Parameter;
a.CoderInfo.StorageClass = 'SimulinkGlobal';
b = Simulink.Parameter;
b.CoderInfo.StorageClass = 'SimulinkGlobal';
a.Value = 10;
b.Value = 10;
Build my system in rapid accelerator
%%build system in rapid accelerator
load_system(mdl);
set_param(mdl, 'Solver', 'ode4')
set_param(mdl, 'FixedStep', num2str('1e-5'))
rtp = Simulink.BlockDiagram.buildRapidAcceleratorTarget(mdl);
close_system(mdl, 0);
Generate a parameterset
%%generate parameterset
iterations = 0;
for j = 1:3
for i = 1:3
iterations = iterations +1;
paramSet{iterations} = Simulink.BlockDiagram.modifyTunableParameters(rtp, 'a',i, 'b', j);
end
end
and perform the parfor loop
load_system(mdl)
parfor i = 1:iterations
simout{i} = sim('parallel_computing_sim',...
'SimulationMode','rapid',...
'RapidAcceleratorUpToDateCheck','off', ...
'RapidAcceleratorParameterSets',paramSet{i});
end;
Then I get the error message:
Unable to load block diagram 'parallel_computing_sim' (line xyz)
in the line of the parfor loop. I assume that the binary of the rapid accelerator is not transfered to the workers correctly.
That is why I tried something like
addpath('./slprj/raccel/parallel_computing_sim')
poolobj = gcp;
addAttachedFiles(poolobj,{'parallel_computing_sim'})
Then I get the error message:
Error using parallel_computing_sim_start (line xyz)
Executable not found.
I valided the cluster by 'Validate' under 'Cluster Profile Manager' and it passed all tests.
Has anybody an idea how to calculate the cluster in rapid accelerator on clusters?
Thanks a lot!
0 Comments
Answers (1)
Sanjay Nair
on 2 Aug 2017
Hello,
A big challenge with regards to parallel simulations with clusters is that the hosts in the cluster will not share the same file system as the client. This is why it's easier to solve the parallel simulations problem using a 'local' cluster profile as opposed to an 'mjs' cluster profile.
The easiest solution to your problem would be to upgrade your version of MATLAB to R2017a and make use of the parsim command: https://www.mathworks.com/help/simulink/slref/parsim.html
This command is meant as a quick access tool to running parallel simulations and supports both 'local' cluster and 'mjs' workflows.
0 Comments
See Also
Categories
Find more on Parallel Computing Fundamentals in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!