Merge pull request #1357 from rattoma/parallel
Provisions for new node option NumberOfThreadsPerJob. Document optiontime-shift
commit
90982d5fa0
|
@ -10834,6 +10834,10 @@ installation directory. The default is the empty string.
|
|||
The path to the MATLAB or Octave executable. The default value is
|
||||
@code{matlab}.
|
||||
|
||||
@item NumberOfThreadsPerJob = @var{INTEGER}
|
||||
For Windows nodes, sets the number of threads assigned to each remote MATLAB/Octave run. The default
|
||||
value is @code{1}.
|
||||
|
||||
@item SingleCompThread = @var{BOOLEAN}
|
||||
Whether or not to disable MATLAB's native multithreading. The default
|
||||
value is @code{false}. Option meaningless under Octave.
|
||||
|
|
|
@ -52,7 +52,12 @@ if any(strcmp('fig',cellstr(DynareOptions.graph_format)))
|
|||
error('Octave cannot create fig files!')
|
||||
else
|
||||
if DynareOptions.nodisplay
|
||||
set(h, 'Visible','on');
|
||||
% THE FOLLOWING LINES COULD BE USED IF BUGS/PROBLEMS ARE REPORTED USING LINE 60
|
||||
% set(h,'Units','Normalized')
|
||||
% mypos=get(h,'Position');
|
||||
% set(h,'Position',[-1 -1 mypos(3:4)])
|
||||
% set(h, 'Visible','on');
|
||||
set(h,'CreateFcn','set(gcf, ''Visible'',''on'')') ;
|
||||
end
|
||||
saveas(h,[fname '.fig']);
|
||||
end
|
||||
|
|
|
@ -58,6 +58,7 @@ dynareParallelMkDir(RemoteTmpFolder,DataInput);
|
|||
% see http://www.dynare.org/DynareWiki/ParallelDynare.
|
||||
% 2.1 [warning] The user asks to use more CPU's than those available.
|
||||
% 2.2 [warning] There are unused CPU's!
|
||||
% 2.3 [error] NumberOfThreadsPerJob is not a divisor of CPUnbr
|
||||
%
|
||||
%
|
||||
% Value 3: The remote computer is unreachable!!!
|
||||
|
@ -359,11 +360,16 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
|
|||
s4=['try,\n dynareroot = dynare_config();\n'];
|
||||
s41=([' fT = fopen(''DynareIsOk.txt'',''w+'');\n']);
|
||||
s42=' fclose(fT);\n';
|
||||
s5=['catch,end,\n'];
|
||||
s5=['catch,\n'];
|
||||
s51=([' fT = fopen(''DynareFailed.txt'',''w+'');\n']);
|
||||
s52=' fclose(fT);\n';
|
||||
s6=['end,\n'];
|
||||
s7=['if ismac,\n'];
|
||||
s71=([' fT = fopen(''IsMac.txt'',''w+'');\n']);
|
||||
s72=' fclose(fT);\n';
|
||||
s8=['end,\n'];
|
||||
send='exit';
|
||||
StrCommand=([s1,s2,s3,s4,s41,s42,s5,s51,s52,send]);
|
||||
StrCommand=([s1,s2,s3,s4,s41,s42,s5,s51,s52,s6,s7,s71,s72,s8,send]);
|
||||
|
||||
% Mettere controllo su NbW ...
|
||||
% if isoctave
|
||||
|
@ -488,6 +494,11 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
|
|||
return
|
||||
else
|
||||
disp('Check on Dynare Path remote machine ..... Ok!')
|
||||
if isempty(dynareParallelDir('IsMac.txt',RemoteTmpFolder,DataInput(Node)))
|
||||
RemoteEnvironment=Environment;
|
||||
else
|
||||
RemoteEnvironment=2;
|
||||
end
|
||||
skipline(2)
|
||||
end
|
||||
end
|
||||
|
@ -542,10 +553,16 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
|
|||
si0=[];
|
||||
de0=[];
|
||||
|
||||
Environment1=Environment;
|
||||
disp('Checking Hardware please wait ...');
|
||||
if (DataInput(Node).Local == 1)
|
||||
if Environment,
|
||||
if ~ismac
|
||||
[si0 de0]=system('grep processor /proc/cpuinfo');
|
||||
else
|
||||
[si0 de0]=system('sysctl -n hw.ncpu');
|
||||
Environment1=2;
|
||||
end
|
||||
else
|
||||
[si0 de0]=system(['psinfo \\']);
|
||||
end
|
||||
|
@ -557,7 +574,12 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
|
|||
ssh_token = '';
|
||||
end
|
||||
if OStargetUnix,
|
||||
if RemoteEnvironment ==1 ,
|
||||
[si0 de0]=system(['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' grep processor /proc/cpuinfo']);
|
||||
else % it is MAC
|
||||
[si0 de0]=system(['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' sysctl -n hw.ncpu']);
|
||||
Environment1=2;
|
||||
end
|
||||
else
|
||||
[si0 de0]=system(['ssh ',ssh_token,' ',DataInput(Node).UserName,'@',DataInput(Node).ComputerName,' psinfo']);
|
||||
end
|
||||
|
@ -569,13 +591,13 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
|
|||
|
||||
RealCPUnbr='';
|
||||
% keyboard;
|
||||
RealCPUnbr=GiveCPUnumber(de0,Environment);
|
||||
RealCPUnbr=GiveCPUnumber(de0,Environment1);
|
||||
|
||||
% Questo controllo penso che si possa MIGLIORARE!!!!!
|
||||
if isempty (RealCPUnbr) && Environment==0,
|
||||
if isempty (RealCPUnbr) && Environment1==0,
|
||||
[si0 de0]=system(['psinfo \\',DataInput(Node).ComputerName]);
|
||||
end
|
||||
RealCPUnbr=GiveCPUnumber(de0,Environment);
|
||||
RealCPUnbr=GiveCPUnumber(de0,Environment1);
|
||||
|
||||
if isempty (RealCPUnbr)
|
||||
% An error occurred when we try to know the Cpu/Cores
|
||||
|
@ -621,6 +643,15 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for'
|
|||
ErrorCode=2.2;
|
||||
end
|
||||
|
||||
if mod(length(DataInput(Node).CPUnbr),DataInput(Node).NumberOfThreadsPerJob)
|
||||
skipline()
|
||||
disp(['NumberOfThreadsPerJob = ',int2str(DataInput(Node).NumberOfThreadsPerJob),' is not an exact divisor of number of CPUs = ',int2str(DataInput(Node).CPUnbr),'!'])
|
||||
disp([' You must re-set properly NumberOfThreadsPerJob of node ' int2str(Node) ' ' DataInput(Node).ComputerName])
|
||||
disp(' in your configuration file')
|
||||
skipline()
|
||||
ErrorCode=2.3;
|
||||
end
|
||||
|
||||
disp(['Test for Cluster computation, computer ',DataInput(Node).ComputerName, ' ..... Passed!'])
|
||||
skipline(2)
|
||||
end
|
|
@ -69,4 +69,8 @@ switch Environment
|
|||
|
||||
nCPU=str2num(ComputerInformations(length(ComputerInformations)-1))+1;
|
||||
|
||||
case 2 %MAC-OS OPERATING SYSTEM
|
||||
|
||||
nCPU=str2num(ComputerInformations);
|
||||
|
||||
end
|
||||
|
|
|
@ -49,7 +49,14 @@ lP=length(Parallel);
|
|||
CPUWeight=ones(1,length(Parallel))*(-1);
|
||||
|
||||
for j=1:lP,
|
||||
nCPU(j)=length(Parallel(j).CPUnbr);
|
||||
if mod(length(Parallel(j).CPUnbr),Parallel(j).NumberOfThreadsPerJob)
|
||||
skipline()
|
||||
disp(['PARALLEL_ERROR:: NumberOfThreadsPerJob = ',int2str(Parallel(j).NumberOfThreadsPerJob),' is not an exact divisor of number of CPUs = ',int2str(length(Parallel(j).CPUnbr)),'!'])
|
||||
disp([' You must re-set properly NumberOfThreadsPerJob of node ' int2str(j) ' ' Parallel(j).ComputerName])
|
||||
disp([' in your configuration file'])
|
||||
error(['PARALLEL_ERROR:: NumberOfThreadsPerJob is not an exact divisor of CPUnbr'])
|
||||
end
|
||||
nCPU(j)=length(Parallel(j).CPUnbr)/Parallel(j).NumberOfThreadsPerJob;
|
||||
totCPU=totCPU+nCPU(j);
|
||||
CPUWeight(j)=str2num(Parallel(j).NodeWeight);
|
||||
end
|
||||
|
|
|
@ -259,6 +259,7 @@ for j=1:totCPU,
|
|||
compThread = '';
|
||||
end
|
||||
|
||||
nthreads=Parallel(indPC).NumberOfThreadsPerJob;
|
||||
if indPC>1
|
||||
nCPU0 = nCPU(indPC-1);
|
||||
else
|
||||
|
@ -322,6 +323,13 @@ for j=1:totCPU,
|
|||
|
||||
end
|
||||
|
||||
% set affinity range on win CPU's
|
||||
affinity_range = [1:nthreads]+(j-1-nCPU0)*nthreads;
|
||||
my_affinity = int2str(Parallel(indPC).CPUnbr(affinity_range(1)));
|
||||
for jaff=2:length(affinity_range),
|
||||
my_affinity = [my_affinity ',' int2str(Parallel(indPC).CPUnbr(affinity_range(jaff)))];
|
||||
end
|
||||
% % % int2str(Parallel(indPC).CPUnbr(j-nCPU0))
|
||||
% DA SINTETIZZARE:
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
@ -339,9 +347,9 @@ for j=1:totCPU,
|
|||
end
|
||||
else % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
|
||||
if regexpi([Parallel(indPC).MatlabOctavePath], 'octave')
|
||||
command1=['psexec -d -W "',DyMo, '" -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)),' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
|
||||
command1=['psexec -d -W "',DyMo, '" -a ',my_affinity,' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
|
||||
else
|
||||
command1=['psexec -d -W "',DyMo, '" -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)),' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
|
||||
command1=['psexec -d -W "',DyMo, '" -a ',my_affinity,' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
|
||||
end
|
||||
end
|
||||
else % 0.2 Parallel(indPC).Local==0: Run using network on remote machine or also on local machine.
|
||||
|
@ -377,20 +385,20 @@ for j=1:totCPU,
|
|||
if ~strcmpi(Parallel(indPC).ComputerName,MasterName), % 0.3 Run on a remote machine!
|
||||
% Hybrid computing Matlab(Master)-> Octave(Slaves) and Vice Versa!
|
||||
if regexpi([Parallel(indPC).MatlabOctavePath], 'octave')
|
||||
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)), ...
|
||||
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
|
||||
' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
|
||||
else
|
||||
|
||||
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)), ...
|
||||
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
|
||||
' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
|
||||
end
|
||||
else % 0.4 Run on the local machine via the network
|
||||
% Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
|
||||
if regexpi([Parallel(indPC).MatlabOctavePath], 'octave')
|
||||
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)), ...
|
||||
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
|
||||
' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
|
||||
else
|
||||
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)), ...
|
||||
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
|
||||
' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
|
||||
end
|
||||
end
|
||||
|
@ -408,9 +416,9 @@ for j=1:totCPU,
|
|||
end
|
||||
else % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
|
||||
if regexpi([Parallel(indPC).MatlabOctavePath], 'octave')
|
||||
command1=['psexec -d -W "',DyMo, '" -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)),' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7'');addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
|
||||
command1=['psexec -d -W "',DyMo, '" -a ',my_affinity,' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7'');addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
|
||||
else
|
||||
command1=['psexec -d -W "',DyMo, '" -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)),' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
|
||||
command1=['psexec -d -W "',DyMo, '" -a ',my_affinity,' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
|
||||
end
|
||||
end
|
||||
elseif Parallel(indPC).Local==0, % 1.2 Run using network on remote machine or also on local machine.
|
||||
|
@ -450,19 +458,19 @@ for j=1:totCPU,
|
|||
if ~strcmpi(Parallel(indPC).ComputerName,MasterName), % 1.3 Run on a remote machine.
|
||||
% Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
|
||||
if regexpi([Parallel(indPC).MatlabOctavePath], 'octave')
|
||||
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)), ...
|
||||
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
|
||||
' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7'');addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
|
||||
else
|
||||
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)), ...
|
||||
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
|
||||
' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
|
||||
end
|
||||
else % 1.4 Run on the local machine via the network.
|
||||
% Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
|
||||
if regexpi([Parallel(indPC).MatlabOctavePath], 'octave')
|
||||
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)), ...
|
||||
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
|
||||
' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
|
||||
else
|
||||
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)), ...
|
||||
command1=['psexec \\',Parallel(indPC).ComputerName,' -d -e -W "',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\" -a ',my_affinity, ...
|
||||
' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,8 @@ GlobalInitFile = ./init.m
|
|||
[node]
|
||||
Name = n1
|
||||
ComputerName = localhost
|
||||
CPUnbr = [1:2]
|
||||
CPUnbr = [1:8]
|
||||
NumberOfThreadsPerJob = 2
|
||||
|
||||
[paths]
|
||||
# comment
|
||||
|
|
Loading…
Reference in New Issue