MATLAB Answers

Standalone application (Compiler toolobox) of a code using the Parallel computing toolbox

14 views (last 30 days)
Sébastien MAILFERT
Sébastien MAILFERT on 7 Jul 2015
Dear all, I'm trying to create a standalone application using two toolboxes: the Compiler one to create my exe file + the Parallel computing one to speed up my program. I tried to codes, one using a simple for loop and another one using the parfor loop.
if true
function Parallel_Loop()
tic
A3 = cell(7500,1);
for ix = 1:7500 % or parfor ix = 1:7500
for jx = 1:7500
A3{ix}(jx) = ix + jx;
end
end
A3 = cell2mat(A3);
time=toc;
fprintf(display_out, 'Elapsed time (s) : %f\n', time) ;
end
end%how to remove this?!
The last one requires half of the time to run on Matlab (that's normal!). When I compile both codes and run them with the Windows command, both codes run during the same time (as the unparallel one on Matlab). It seems that the parfor loop is understood as a simple for loop when compiled. Could you help me please? Best regards.

  0 Comments

Sign in to comment.

Answers (3)

Edric Ellis
Edric Ellis on 8 Jul 2015
This is a known problem when compiling applications that use parfor, and there is a simple workaround documented in this bug report.

  0 Comments

Sign in to comment.


Sébastien MAILFERT
Sébastien MAILFERT on 8 Jul 2015
Hi Edric,
This doesn't seems to be my problem. I used this code:
if true
function Test_parallel_Yes
gcp('nocreate');
tic
A3 = cell(7500,1);
parfor ix = 1:7500
for jx = 1:7500
A3{ix}(jx) = ix + jx;
end
end
A3 = cell2mat(A3);
time=toc;
fprintf(display_out, 'Elapsed time (s) : %f\n', time) ;
end%function
end
But the program execution is not parallelized.

  0 Comments

Sign in to comment.


Sébastien MAILFERT
Sébastien MAILFERT on 8 Jul 2015
Dear users, I found the problem on the web. I give you the final code:
if true
function Test_parallel_Yes()
delete(gcp);
defaultProfile = parallel.defaultClusterProfile;
myCluster = parcluster(defaultProfile);
parpool(myCluster);
tic
A3 = cell(7500,1);
parfor ix = 1:7500
for jx = 1:7500
A3{ix}(jx) = ix + jx;
end
end
A3 = cell2mat(A3);
toc
end%function
end
I hope this will help people in my case. I just have some warnings but now the code is executed in parallel! Sébastien

  0 Comments

Sign in to comment.