Parallel par stall and low utilization

4 vues (au cours des 30 derniers jours)
karthick Gopalswamy
karthick Gopalswamy le 14 Juil 2020
% Picked 7 starts from the 30 we genrated earlier
Rstarts = [R1; R3; R5; R10; R12; R21; R22];
pathdot = simulation_path;
A=1;
% Lets make pertubations +-5
cSPSA=3;
a = 0.01;
% set size is decreasing but not the pertubation
cn = cSPSA;
path1 = simulation_path;
seeds = [11934,41900,61321,99410,87252,90467,90188,43116,87667,77541];
% seeds = seeds(6);
maxRuns = 30;
nStart = 7;
Release_final = zeros(length(seeds),nStart,length(Rstarts(1,:)));
PA = zeros(length(seeds),nStart,maxRuns);
for nruns = 4:5
alpha = 0.602;
gamma = -0.25;
% intialize variables
%In each of the runs assign R to one of the 7 starts
R = repmat(Rstarts(nruns,:),length(seeds),1);
% the orginal SA loop which uses R as the starting point
deltaJ_plus = zeros(length(seeds), length(R));
deltaJ_minus = zeros(length(seeds), length(R)*2);
for n= 1:maxRuns
an =a/(n)^0.7;
condition = 30;
parfor q=1:60
if q <= condition
ei = zeros(1, length(R));
ei(q)=1;
path2 = strcat('_',num2str(q));
pathdot = strcat(path1,path2);
delta_plus = zeros(length(seeds),1);
for i=1:length(seeds)
Rplus = R+(cn'*ei);
delta_plus(i) = fullsimcall_GA(Rplus(i,:),pathdot,seeds(i));
end
deltaJ_plus(:,q) = delta_plus;
else
ei = zeros(1, length(R));
ei(q-30)=1;
path2 = strcat('_',num2str(q));
pathdot = strcat(path1,path2);
delta_minus = zeros(length(seeds),1);
for i= 1:length(seeds)
Rminus = R-(cn'*ei);
delta_minus(i) = fullsimcall_GA(Rminus(i,:),pathdot,seeds(i));
end
deltaJ_minus(:,q) = delta_minus;
end
end
% cd back into matlab path (where the fullsimcall.m is located)
% The problem seems to be that after the parfor is executred we
% get struck in the simautlion folder and the next function call
% doesnt get exceuted
cd(matlab_path);
deltaJ = ((1/2*cn)').*(deltaJ_plus - deltaJ_minus(:,31:end));
Rnplus1 = R - an*deltaJ;
Rnplus1(Rnplus1<=0)=0.05;
parfor i = 1:length(seeds)
path2 = strcat('_',num2str(i));
pathdot = strcat(path1,path2);
Jnplus1 = fullsimcall_GA(Rnplus1(i,:),pathdot,seeds(i));
PA(i,nruns,n) = Jnplus1;
end
R = Rnplus1;
end
Release_final(:,nruns,:) = R;
cd(matlab_path);
end
I am trying to run this code on matlab parfor and the machine has 72 core. I ran the same code with 100 % utilization before but now the code only achieves 30% utilization and takes 3 times as long as it used to before. The fullsimcall_GA function calls take the input vector and a path and write the contents of the input in a text file in the path specified. Then an .exe file (c++) code is called which uses the input and returns output. Can someone help me out with this?
Thanks,
Karthick

Réponses (0)

Catégories

En savoir plus sur Parallel for-Loops (parfor) dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by