how to increase the number of workers to 32 for parfor loop
50 次查看(过去 30 天)
显示 更早的评论
I am trying to increase the number of workers (cores) for parfor loop in Matalb, but after running the code the number of cores was limited to 12
parfor (i=1:size(data,2),32)
filename=[surfacename,num2str(sub),var,num2str(file_no(i)),'.raw'];
fullname=fullfile(Dir,filename);
fid = fopen(fullname,'rb'); % rb = read binary
NN=N*10;
data2 = fread(fid,NN,'single');
fclose(fid);
start=8;
data2=data2(start:length(data2));
len=length(data2)/no_variables;
if opt==1 ||opt==6;
data(:,i)=data2(1:len);
elseif opt==2;
data(:,i)=data2(len+1:2*len);
elseif opt==3;
data(:,i)=data2(2*len+1:3*len);
elseif opt==4;
data(:,i)=data2(3*len+1:4*len);
elseif opt==5;
data(:,i)=data2(4*len+1:5*len);
elseif opt==7;
F = scatteredInterpolant(x,y,z,data2(1:len),'linear','linear');
data_int=F(xq,yq,zq);
data_int_2= reshape(data_int,[],1);
data(:,i)=data_int_2;
elseif opt==8;
F = scatteredInterpolant(x,y,z,data2(len+1:2*len),'linear','linear');
data_int=F(xq,yq,zq);
data_int_2= reshape(data_int,[],1);
data(:,i)=data_int_2;
elseif opt==9;
F = scatteredInterpolant(x,y,z,data2(2*len+1:3*len),'linear','linear');
data_int=F(xq,yq,zq);
data_int_2= reshape(data_int,[],1);
data(:,i)=data_int_2;
elseif opt==10;
F = scatteredInterpolant(x,y,z,data2(3*len+1:4*len),'linear','linear');
data_int=F(xq,yq,zq);
data_int_2= reshape(data_int,[],1);
data(:,i)=data_int_2;
elseif opt==11;
F = scatteredInterpolant(x,y,z,data2(4*len+1:5*len),'linear','linear');
data_int=F(xq,yq,zq);
data_int_2= reshape(data_int,[],1);
data(:,i)=data_int_2;
end
if mod(i,500) == 0
fprintf('flie read %d...\n',i);
tt=toc/60
end
name=[name,i];
end
The output showed that the number of workers are only 12.Is there any method to increase them?
0 个评论
回答(1 个)
Raymond Norris
2022-4-10
Are you explicitly calling parpool?
parpool(32);
Alternatively, you can change the default by going to the Parallel preferences and changing Preferred number of workers in a parallel pool
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Parallel Computing Fundamentals 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!