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
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,72 +1,76 @@
|
|||
function [nCPU]= GiveCPUnumber (ComputerInformations, Environment)
|
||||
% PARALLEL CONTEXT
|
||||
% In a parallel context this function return the CPUs or cores numer avaiable
|
||||
% on the computer used for run parallel code.
|
||||
%
|
||||
% INPUTS
|
||||
% an array contained several fields that describe the hardaware
|
||||
% software enviroments of a generic computer.
|
||||
%
|
||||
% OUTPUTS
|
||||
% The CPUs or Cores numbers of computer.
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2010-2013 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
nCPU='';
|
||||
|
||||
if nargin < 2,
|
||||
% Determine a specific operating system or software version when necessary
|
||||
% for different command (sintax, name, ...).
|
||||
Environment=~ispc;
|
||||
end
|
||||
|
||||
switch Environment
|
||||
case 0 %WINDOWS OPERATING SYSTEM
|
||||
|
||||
OffSet=27;
|
||||
|
||||
SringPosition=strfind(ComputerInformations, 'Processors:');
|
||||
nCPU=ComputerInformations(SringPosition+OffSet);
|
||||
|
||||
% We check if there are Processors/Cores more than 9.
|
||||
|
||||
|
||||
t0=ComputerInformations(SringPosition+OffSet+1);
|
||||
t1=str2num(t0);
|
||||
t1=isempty(t1);
|
||||
|
||||
% if t1 is 0 the machine have more than 9 CPU.
|
||||
|
||||
if t1==0
|
||||
nCPU=strcat(nCPU,t0);
|
||||
end
|
||||
|
||||
nCPU=str2num(nCPU);
|
||||
|
||||
return
|
||||
case 1 %LIKE UNIX OPERATING SYSTEM
|
||||
|
||||
% Da generalizzare a un numero di CPu maggiore di 9!!!
|
||||
|
||||
nCPU=str2num(ComputerInformations(length(ComputerInformations)-1))+1;
|
||||
|
||||
end
|
||||
function [nCPU]= GiveCPUnumber (ComputerInformations, Environment)
|
||||
% PARALLEL CONTEXT
|
||||
% In a parallel context this function return the CPUs or cores numer avaiable
|
||||
% on the computer used for run parallel code.
|
||||
%
|
||||
% INPUTS
|
||||
% an array contained several fields that describe the hardaware
|
||||
% software enviroments of a generic computer.
|
||||
%
|
||||
% OUTPUTS
|
||||
% The CPUs or Cores numbers of computer.
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2010-2013 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
nCPU='';
|
||||
|
||||
if nargin < 2,
|
||||
% Determine a specific operating system or software version when necessary
|
||||
% for different command (sintax, name, ...).
|
||||
Environment=~ispc;
|
||||
end
|
||||
|
||||
switch Environment
|
||||
case 0 %WINDOWS OPERATING SYSTEM
|
||||
|
||||
OffSet=27;
|
||||
|
||||
SringPosition=strfind(ComputerInformations, 'Processors:');
|
||||
nCPU=ComputerInformations(SringPosition+OffSet);
|
||||
|
||||
% We check if there are Processors/Cores more than 9.
|
||||
|
||||
|
||||
t0=ComputerInformations(SringPosition+OffSet+1);
|
||||
t1=str2num(t0);
|
||||
t1=isempty(t1);
|
||||
|
||||
% if t1 is 0 the machine have more than 9 CPU.
|
||||
|
||||
if t1==0
|
||||
nCPU=strcat(nCPU,t0);
|
||||
end
|
||||
|
||||
nCPU=str2num(nCPU);
|
||||
|
||||
return
|
||||
case 1 %LIKE UNIX OPERATING SYSTEM
|
||||
|
||||
% Da generalizzare a un numero di CPu maggiore di 9!!!
|
||||
|
||||
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