Parallel par stall and low utilization
조회 수: 3 (최근 30일)
이전 댓글 표시
% 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
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!