1) Renamed options according ti WiKi table;

2) get rid of MasterName and DyMo;
3) more comments;
time-shift
Marco Ratto 2010-10-22 11:27:26 +02:00
parent cab8941c29
commit d8121365dd
27 changed files with 330 additions and 295 deletions

View File

@ -54,8 +54,6 @@ M_=myinputs.M_;
if whoiam
Parallel=myinputs.Parallel;
MasterName=myinputs.MasterName;
DyMo=myinputs.DyMo;
end
if ~exist('MhDirectoryName'),
MhDirectoryName = CheckPath('metropolis');
@ -70,9 +68,9 @@ if whoiam
if Parallel(ThisMatlab).Local,
waitbarTitle=['Local '];
else
waitbarTitle=[Parallel(ThisMatlab).PcName];
waitbarTitle=[Parallel(ThisMatlab).ComputerName];
end
fMessageStatus(0,whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab), MasterName, DyMo);
fMessageStatus(0,whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab));
end
for j=fpar:npar,
fprintf(' Parameter %d... ',j);
@ -121,7 +119,7 @@ for j=fpar:npar,
fprintf('Done! \n');
if whoiam,
waitbarString = [ 'Parameter ' int2str(j) '/' int2str(npar) ' done.'];
fMessageStatus((j-fpar+1)/(npar-fpar+1),whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab), MasterName, DyMo)
fMessageStatus((j-fpar+1)/(npar-fpar+1),whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab))
end
end

View File

@ -195,7 +195,7 @@ localVars.NumberOfIRFfiles_dsgevar=NumberOfIRFfiles_dsgevar;
localVars.ifil2=ifil2;
% Like sequential execution!
if isnumeric(options_.parallel),% | isunix, % For the moment exclude unix platform from parallel implementation.
if isnumeric(options_.parallel),
[fout] = PosteriorIRF_core1(localVars,1,B,0);
else
% Parallel execution!
@ -424,9 +424,9 @@ end
% The others file format are generated in parallel by PosteriorIRF_core2!
% Comment for testing!
% Comment for testing!
if ~exist('OCTAVE_VERSION')
if isnumeric(options_.parallel) % || (M_.exo_nbr*ceil(size(varlist,1)/MaxNumberOfPlotPerFigure))<8,% | isunix, % for the moment exclude unix platform from parallel implementation
if isnumeric(options_.parallel) || (M_.exo_nbr*ceil(size(varlist,1)/MaxNumberOfPlotPerFigure))<8,
[fout] = PosteriorIRF_core2(localVars,1,M_.exo_nbr,0);
else
globalVars = struct('M_',M_, ...

View File

@ -49,7 +49,6 @@ end
% Reshape 'myinputs' for local computation.
% In order to avoid confusion in the name space, the instruction struct2local(myinputs) is replaced by:
% Da CONTROLLARE con MARCO!
IRUN = myinputs.IRUN;
irun =myinputs.irun;
irun2=myinputs.irun2;
@ -77,12 +76,9 @@ MAX_nruns=myinputs.MAX_nruns;
NumberOfIRFfiles_dsge=myinputs.NumberOfIRFfiles_dsge;
NumberOfIRFfiles_dsgevar=myinputs.NumberOfIRFfiles_dsgevar;
ifil2=myinputs.ifil2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if whoiam
Parallel=myinputs.Parallel;
MasterName=myinputs.MasterName;
DyMo=myinputs.DyMo;
end
@ -95,10 +91,10 @@ if whoiam
if Parallel(ThisMatlab).Local,
waitbarTitle=['Local '];
else
waitbarTitle=[Parallel(ThisMatlab).PcName];
waitbarTitle=[Parallel(ThisMatlab).ComputerName];
RemoteFlag =1;
end
fMessageStatus(0,whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab), MasterName, DyMo);
fMessageStatus(0,whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab));
else
if exist('OCTAVE_VERSION')
diary off;
@ -130,7 +126,9 @@ if whoiam
NumberOfIRFfiles_dsgevar=NumberOfIRFfiles_dsgevar(whoiam);
end
while fpar<npar % Parallel 'while'!!!
% Parallel 'while' very good!!!
while fpar<npar
fpar = fpar + 1;
irun = irun+1;
irun2 = irun2+1;
@ -273,11 +271,10 @@ while fpar<npar % Parallel 'while'!!!
elseif ~whoiam
waitbar(fpar/npar,h);
end
% if mod(fpar,10)==0 & whoiam,
if whoiam,
fprintf('Done! \n');
waitbarString = [ 'Subdraw ' int2str(fpar) '/' int2str(npar) ' done.'];
fMessageStatus((fpar-fpar0)/(npar-fpar0),whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab), MasterName, DyMo);
fMessageStatus((fpar-fpar0)/(npar-fpar0),whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab));
end
end

View File

@ -65,8 +65,6 @@ MaxNumberOfPlotPerFigure=myinputs.MaxNumberOfPlotPerFigure;
% Necessary only for remote computing!
if whoiam
Parallel=myinputs.Parallel;
MasterName=myinputs.MasterName;
DyMo=myinputs.DyMo;
end
% To save the figures where the function is computed!
@ -79,10 +77,10 @@ if whoiam,
if Parallel(ThisMatlab).Local,
waitbarTitle=['Local '];
else
waitbarTitle=[Parallel(ThisMatlab).PcName];
waitbarTitle=[Parallel(ThisMatlab).ComputerName];
RemoteFlag = 1;
end
fMessageStatus(0,whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab), MasterName, DyMo);
fMessageStatus(0,whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab));
end
OutputFileName={};
@ -164,11 +162,11 @@ for i=fpar:npar,
if whoiam,
fprintf('Done! \n');
waitbarString = [ 'Exog. shocks ' int2str(i) '/' int2str(npar) ' done.'];
fMessageStatus((i-fpar+1)/(npar-fpar+1),whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab), MasterName, DyMo);
fMessageStatus((i-fpar+1)/(npar-fpar+1),whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab));
end
end% loop over exo_var
myoutput.OutputFileName = OutputFileName;

View File

@ -57,14 +57,12 @@ nruns=myinputs.nruns;
NewFile=myinputs.NewFile;
MAX_nruns=myinputs.MAX_nruns;
d=myinputs.d;
InitSizeArray=myinputs.InitSizeArray;
InitSizeArray=myinputs.InitSizeArray;
record=myinputs.record;
varargin=myinputs.varargin;
if whoiam
Parallel=myinputs.Parallel;
MasterName=myinputs.MasterName;
DyMo=myinputs.DyMo;
% initialize persistent variables in priordens()
priordens(xparam1,bayestopt_.pshape,bayestopt_.p6,bayestopt_.p7, ...
bayestopt_.p3,bayestopt_.p4,1);
@ -121,13 +119,13 @@ for b = fblck:nblck,
elseif whoiam
% keyboard;
waitbarString = ['Please wait... Metropolis-Hastings (' int2str(b) '/' int2str(options_.mh_nblck) ')...'];
% waitbarTitle=['Metropolis-Hastings ',options_.parallel(ThisMatlab).PcName];
% waitbarTitle=['Metropolis-Hastings ',options_.parallel(ThisMatlab).ComputerName];
if options_.parallel(ThisMatlab).Local,
waitbarTitle=['Local '];
else
waitbarTitle=[options_.parallel(ThisMatlab).PcName];
waitbarTitle=[options_.parallel(ThisMatlab).ComputerName];
end
fMessageStatus(0,whoiam,waitbarString, waitbarTitle, options_.parallel(ThisMatlab), MasterName, DyMo);
fMessageStatus(0,whoiam,waitbarString, waitbarTitle, options_.parallel(ThisMatlab));
else,
hh = waitbar(0,['Please wait... Metropolis-Hastings (' int2str(b) '/' int2str(options_.mh_nblck) ')...']);
set(hh,'Name','Metropolis-Hastings');
@ -138,7 +136,7 @@ for b = fblck:nblck,
irun = fline(b);
j = 1;
while j <= nruns(b)
par = feval(ProposalFun, xparam1, d * jscale, n);
par = feval(ProposalFun, xparam1, proposal_covariance, n);
if all( par(:) > mh_bounds(:,1) ) & all( par(:) < mh_bounds(:,2) )
try
logpost = - feval(TargetFun, par(:),varargin{:});
@ -149,8 +147,8 @@ for b = fblck:nblck,
logpost = -inf;
end
r = logpost - ilogpo2(b) + ...
log(feval(ProposalDensity, ix2(b,:), xparam1, d * jscale, n)) - ...
log(feval(ProposalDensity, par, xparam1, d * jscale, n));
log(feval(ProposalDensity, ix2(b,:), xparam1, proposal_covariance, n)) - ...
log(feval(ProposalDensity, par, xparam1, proposal_covariance, n));
if (logpost > -inf) && (log(rand) < r)
x2(irun,:) = par;
ix2(b,:) = par;
@ -174,7 +172,7 @@ for b = fblck:nblck,
if mod(j,50)==0 & whoiam,
% keyboard;
waitbarString = [ '(' int2str(b) '/' int2str(options_.mh_nblck) '), ' sprintf('accept. %3.f%%%%', 100 * isux/j)];
fMessageStatus(prtfrc,whoiam,waitbarString, '', options_.parallel(ThisMatlab), MasterName, DyMo)
fMessageStatus(prtfrc,whoiam,waitbarString, '', options_.parallel(ThisMatlab))
end
else
if mod(j, 3)==0 & ~whoiam
@ -182,7 +180,7 @@ for b = fblck:nblck,
elseif mod(j,50)==0 & whoiam,
% keyboard;
waitbarString = [ '(' int2str(b) '/' int2str(options_.mh_nblck) ') ' sprintf('%f done, acceptation rate %f',prtfrc,isux/j)];
fMessageStatus(prtfrc,whoiam,waitbarString, waitbarTitle, options_.parallel(ThisMatlab), MasterName, DyMo)
fMessageStatus(prtfrc,whoiam,waitbarString, waitbarTitle, options_.parallel(ThisMatlab))
end
end

View File

@ -1,5 +1,6 @@
function [ErrorCode] = AnalyseComputationalEnviroment(DataInput)
% PARALLEL CONTEXT
% In a parallel context, this function is used to check the user computational request.
% If no error happen the function return 0.
@ -9,19 +10,21 @@ function [ErrorCode] = AnalyseComputationalEnviroment(DataInput)
% DataInput is the strcture option_.parallel, with the follow fields:
%
% Local Define the computation place: 1 is on local machine, 0 remote
% PcName Intuitive: contain the computer name.
% NumCPU Intuitive: contain the CPU number.
% user Intuitive: contain the use name for the PcName.
% passwd Intuitive: contain the password for the user name in PcName.
% ComputerName Intuitive: contain the computer name.
% CPUnbr Intuitive: contain the CPU number.
% UserName Intuitive: contain the use name for the ComputerName.
% passwd Intuitive: contain the password for the user name in ComputerName.
% RemoteDrive Drive used for Local/Remote computation (data exchange, etc) must be contain 'RemoteFolder'.
% RemoteFolder Folder in RemoteDrive used for Local/Remote computation.
% RemoteDirectory Folder in RemoteDrive used for Local/Remote computation.
% MatlabOctavePath []
% DynarePath []
%
% This information is typed by the user using the *.mod file,
% the goal of this function is to check if it correct.
%
%
% The variable ErrorCode is initialized at 0. If there are non problems with
% Local, PcName connections,... in general with parallel software execution,
% Local, ComputerName connections,... in general with parallel software execution,
% the ErrorCode is unchanged, in the others cases 1, 2 , ... The values
% table is below.
%
@ -34,7 +37,7 @@ function [ErrorCode] = AnalyseComputationalEnviroment(DataInput)
%
% Value 1: The variable 'Local' has a bad value!
%
% Value 2: The variable 'NumCPU' has a bad value. Parallel Dynare
% Value 2: The variable 'CPUnbr' has a bad value. Parallel Dynare
% require an input data like [s:d] with s<=d, in this case we
% have s>d!
% 2.1 The user asks to use more CPU of those available.
@ -91,14 +94,14 @@ end
%%%%%%%%%% Local Machine %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% In this case we need to check only the variable 'NumCPU'.
% In this case we need to check only the variable 'CPUnbr'.
% We run the parallel code on local computer, so the others fields are automatically
% fixed by Dynare. Then the user can also fill them with wrong values.
if (DataInput.Local == 1)
yn=isempty(DataInput.NumCPU);
yn=isempty(DataInput.CPUnbr);
if yn==1
ErrorCode=2;
@ -112,23 +115,23 @@ if (DataInput.Local == 1)
[si0 de0]=system(['psinfo \\']);
RealNumCPU=-1;
RealNumCPU=GiveCPUnumber(de0);
RealCPUnbr=-1;
RealCPUnbr=GiveCPUnumber(de0);
% Trasforming the input data provided in a form [n1:n2] in a single numerical
% value.
DataInput.NumCPU=length(DataInput.NumCPU);
DataInput.CPUnbr=length(DataInput.CPUnbr);
if DataInput.NumCPU == RealNumCPU
if DataInput.CPUnbr == RealCPUnbr
% It is Ok!
end
if DataInput.NumCPU > RealNumCPU
if DataInput.CPUnbr > RealCPUnbr
ErrorCode=2.1;
end
if DataInput.NumCPU < RealNumCPU
if DataInput.CPUnbr < RealCPUnbr
ErrorCode=2.2;
end
end
@ -143,7 +146,7 @@ if (DataInput.Local == 0)
si1=[];
de1=[];
[si1 de1]=system(['ping ', DataInput.PcName]);
[si1 de1]=system(['ping ', DataInput.ComputerName]);
if si1==1
% It is impossiblie to be connected to the
@ -160,7 +163,7 @@ if (DataInput.Local == 0)
% possible to exchange data with them.
if (isempty(DataInput.user)) || (isempty(DataInput.passwd))
if (isempty(DataInput.UserName)) || (isempty(DataInput.Password))
% The fields user name and/or password are/is empty!
@ -170,13 +173,21 @@ if (DataInput.Local == 0)
end
% Now we very if RemoteDrive and/or RemoteFolder exist on remote
% Now we very if RemoteDrive and/or RemoteDirectory exist on remote
% computer
StartPwd=pwd;
if (isempty(DataInput.RemoteDirectory))
disp 'Remote Drive and/or Remote Folder not exist!';
ErrorCode=5;
return
end
try
cd(['\\',DataInput.PcName,'\',DataInput.RemoteDrive,'$\',DataInput.RemoteFolder]);
cd(['\\',DataInput.ComputerName,'\',DataInput.RemoteDrive,'$\',DataInput.RemoteDirectory]);
catch
cd ([StartPwd]);
@ -187,18 +198,28 @@ if (DataInput.Local == 0)
end
cd ([StartPwd]);
% Now we verify if it possible to exchange data with the remote
% computer:
fT = fopen('WriteTest.txt', 'w+');
fclose(fT);
Status=copyfile('WriteTest.txt', ['\\',DataInput.ComputerName,'\',DataInput.RemoteDrive,'$\',DataInput.RemoteDirectory]);
Status=copyfile('Tracing.m', ['\\',DataInput.PcName,'\',DataInput.RemoteDrive,'$\',DataInput.RemoteFolder]);
if Status==1
% Remote Drive/Folder exist on Remote computer and
% it is possible to exchange data with him.
%Delete Traces (local and remotely)
delete ('WriteTest.txt')
delete(['\\',DataInput.ComputerName,'\',DataInput.RemoteDrive,'$\',DataInput.RemoteDirectory,'\WriteTest.txt']);
else
ErrorCode=6;
@ -207,12 +228,12 @@ if (DataInput.Local == 0)
% Now we verify if it is possible execute a matlab section on remote
% machine when the user is .user with password .passwd
% machine when the user is .UserName with password .Password
si2=[];
de2=[];
[si2 de2]=system(['start /B /WAIT psexec \\',DataInput.PcName,' -e -u ',DataInput.user,' -p ',DataInput.passwd,' -W ',DataInput.RemoteDrive,':\',DataInput.RemoteFolder, ' -low matlab -nosplash -nodesktop -minimize -r Tracing']);
[si2 de2]=system(['start /B /WAIT psexec \\',DataInput.ComputerName,' -e -u ',DataInput.UserName,' -p ',DataInput.Password,' -W ',DataInput.RemoteDrive,':\',DataInput.RemoteDirectory, ' -low matlab -nosplash -nodesktop -minimize -r Tracing']);
NoError='error code 0';
@ -228,34 +249,34 @@ if (DataInput.Local == 0)
else
% No error it is possible execute a matlab section on remote
% machine when the user is .user with password .passwd
% machine when the user is .UserName with password .Password
end
% At this point we can to analyze the remote computer hardware.
RealNumCPU=-1;
RealCPUnbr=-1;
[si0 de0]=system(['psinfo \\']);
RealNumCPU=GiveCPUnumber(de0);
RealCPUnbr=GiveCPUnumber(de0);
% Trasforming the input data provided in a form [n1:n2] in a single numerical
% value.
DataInput.NumCPU=length(DataInput.NumCPU);
DataInput.CPUnbr=length(DataInput.CPUnbr);
if DataInput.NumCPU == RealNumCPU
if DataInput.CPUnbr == RealCPUnbr
% It is Ok!
end
if DataInput.NumCPU > RealNumCPU
if DataInput.CPUnbr > RealCPUnbr
ErrorCode=2.1;
end
if DataInput.NumCPU < RealNumCPU
if DataInput.CPUnbr < RealCPUnbr
ErrorCode=2.2;
end

View File

@ -1,11 +1,12 @@
function [TiSt] = CreateTimeString()
% PARALLEL CONTEXT
% In a parallel context, this is ...
%
%
% INPUT/OUTPUT description:
% In a parallel context, this is a specialized version of clock() function.
%
% INPUTS
% None
%
% OUTPUTS
% o TiSt [] ...
%
% Copyright (C) 2009-2010 Dynare Team
%

View File

@ -1,26 +1,15 @@
function [ErrorCode] = InitializeComputationalEnviroment(DataInput)
function InitializeComputationalEnviroment(DataInput)
% PARALLEL CONTEXT
% In a parallel context, this function is used to Initialize the computational enviroment according with
% the user request.
% If no error happen the function return 0.
%
% INPUT/OUTPUT description:
% INPUTS
% o DataInput [] ...
%
% OUTPUTS
% None
%
%
%
% The variable ErrorCode is initialized at 0. If there are non problems
% the ErrorCode is unchanged, in the others cases is set equak to 1, 2 , ... The values
% table is below.
%
%
% Table for ErrorCode Values.
%
%
% Then at the point call of this function it is possible react in a best way, in accord
% with the ErrorCode.
% Copyright (C) 2009-2010 Dynare Team
%
% This file is part of Dynare.
@ -38,13 +27,13 @@ function [ErrorCode] = InitializeComputationalEnviroment(DataInput)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
ErrorCode=0;
% Invoke masterParallel with 8 arguments and the last equal to 1. With this shape
% for input data, masterParallel only create a new directory for remote
% computation. The name of this directory is time depending. For local
% parallel computations with Strategy == 1 delete the traces (if exists) of
% previous computations.
% previous computations.
delete(['P_slave_*End.txt'])
masterParallel(DataInput.parallel,[],[],[],[],[],[],DataInput.parallel_info,1);

View File

@ -1,11 +1,16 @@
function closeSlave(Parallel,TmpFolder),
% PARALLEL CONTEXT
% In parallel context, this utility closes all remote matlab instances
% called by masterParallel with strategy (1) i.e. always open (which leaves
% called by masterParallel when strategy (1) is active i.e. always open (which leaves
% open remote matlab instances).
%
% INPUTS
% o Parallel [struct vector] copy of options_.parallel.
% o TmpFolder string if islocal==0, is the name of didectory devoted to remote computation.
% This directory is named using current date
% and is used only one time and then deleted.
% If islocal==1, TmpFolder=''.
%
%
% OUTPUTS
% None
@ -27,15 +32,17 @@ function closeSlave(Parallel,TmpFolder),
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
for indPC=1:length(Parallel),
if (Parallel(indPC).Local==0),
dynareParallelDelete( 'slaveParallel_input*.mat',TmpFolder,Parallel(indPC));
else
end
%else
delete( 'slaveParallel_input*.mat');
pause(1)
delete(['slaveParallel_*.log']);
end
%end
delete ConcurrentCommand1.bat;
end
while(1)

View File

@ -14,8 +14,8 @@ function [nCPU, totCPU, nBlockPerCPU, totSLAVES] = distributeJobs(Parallel, fBlo
% threads run on that CPU
% o totCPU [int] total number of CPU used (can be lower than
% the number of CPU declared in "Parallel", if
% the number of required threads is lower)
% o nCPU he number of CPU in user format.
% the number of required threads is lower!)
% o nCPU the number of CPU in user format.
% Copyright (C) 2010 Dynare Team
%
@ -36,7 +36,7 @@ function [nCPU, totCPU, nBlockPerCPU, totSLAVES] = distributeJobs(Parallel, fBlo
totCPU=0;
for j=1:length(Parallel),
nCPU(j)=length(Parallel(j).NumCPU);
nCPU(j)=length(Parallel(j).CPUnbr);
totCPU=totCPU+nCPU(j);
end

View File

@ -2,10 +2,13 @@ function dynareParallelDelete(fname,pname,Parallel)
% PARALLEL CONTEXT
% In a parallel context, this is a specialized version of delete() function.
%
% INPUTS
% o fname [] ...
% o pname [] ...
% o Parallel [] ...
%
% INPUT/OUTPUT description:
%
%
% OUTPUTS
% None
%
%
% Copyright (C) 2009-2010 Dynare Team
@ -38,9 +41,9 @@ end
for indPC=1:length(Parallel),
if isunix
system(['ssh ',Parallel(indPC).user,'@',Parallel(indPC).PcName,' rm -f ',Parallel(indPC).RemoteFolder,'/',pname,fname]);
system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' rm -f ',Parallel(indPC).RemoteDirectory,'/',pname,fname]);
else
delete(['\\',Parallel(indPC).PcName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteFolder,'\',pname,fname]);
delete(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',pname,fname]);
end
end

View File

@ -1,11 +1,14 @@
function dirlist = dynareParallelDir(filename,PRCDir,Parallel)
% PARALLEL CONTEXT
% In a parallel context, this is ...
%
%
% INPUT/OUTPUT description:
% In a parallel context, this is a specialized version of dir() function.
%
% INPUTS
% o filename [] ...
% o PRCDir [] ...
% o Parallel [] ...
%
% OUTPUTS
% o dirlist [] ...
%
% Copyright (C) 2009-2010 Dynare Team
%
@ -28,7 +31,7 @@ dirlist=[];
for indPC=1:length(Parallel),
if isunix || (~matlab_ver_less_than('7.4') && ismac),
if Parallel(indPC).Local==0,
[check, ax]=system(['ssh ',Parallel(indPC).user,'@',Parallel(indPC).PcName,' ls ',Parallel(indPC).RemoteFolder,'/',PRCDir,'/',filename]);
[check, ax]=system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' ls ',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',filename]);
if check ~ 0
ax=[];
end
@ -43,7 +46,7 @@ for indPC=1:length(Parallel),
dirlist = [dirlist, ax];
else
if Parallel(indPC).Local==0,
ax=ls(['\\',Parallel(indPC).PcName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteFolder,'\',PRCDir,'\',filename]);
ax=ls(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',filename]);
else
ax=ls(filename);
end

View File

@ -1,9 +1,16 @@
function dynareParallelGetFiles(NamFileInput,PRCDir,Parallel)
% PARALLEL CONTEXT
% In a parallel context, this is ...
% In a parallel context, this is a specialized mono-directional (Remote to Local) version of copy()
% function.
%
%
% INPUT/OUTPUT description:
% INPUTS
% o NamFileInput [] ...
% o PRCDir [] ...
% o Parallel [] ...
%
% OUTPUTS
% None
%
%
%
@ -37,13 +44,13 @@ for indPC=1:length(Parallel),
if isunix || (~matlab_ver_less_than('7.4') && ismac),
for jfil=1:size(NamFileInput,1),
% if ~isempty(dynareParallelDir(NamFileInput{jfil,2},[PRCDir,filesep,NamFileInput{jfil,1}],Parallel(indPC))),
system(['scp ',Parallel(indPC).user,'@',Parallel(indPC).PcName,':',Parallel(indPC).RemoteFolder,'/',PRCDir,'/',NamFileInput{jfil,1},NamFileInput{jfil,2},' ',NamFileInput{jfil,1}]);
system(['scp ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,':',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1},NamFileInput{jfil,2},' ',NamFileInput{jfil,1}]);
% end
end
else
for jfil=1:size(NamFileInput,1),
if ~isempty(dynareParallelDir(NamFileInput{jfil,2},[PRCDir,filesep,NamFileInput{jfil,1}],Parallel(indPC))),
copyfile(['\\',Parallel(indPC).PcName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteFolder,'\',PRCDir,'\',NamFileInput{jfil,1},NamFileInput{jfil,2}],NamFileInput{jfil,1})
copyfile(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',NamFileInput{jfil,1},NamFileInput{jfil,2}],NamFileInput{jfil,1})
end
end
end

View File

@ -2,16 +2,14 @@ function dynareParallelMkDir(PRCDir,Parallel)
% PARALLEL CONTEXT
% In a parallel context, this is a specialized version of rmdir() function.
%
% INPUTS
% o PRCDir [] ...
% o Parallel [] ...
%
% INPUT/OUTPUT description:
% OUTPUTS
% None
%
%
%
%
%
% Then at the point call of this function it is possible react in a best way, in accord
% with the ErrorCode.
% Copyright (C) 2009-2010 Dynare Team
%
% This file is part of Dynare.
@ -39,9 +37,9 @@ end
for indPC=1:length(Parallel)
if Parallel(indPC).Local==0,
if isunix || (~matlab_ver_less_than('7.4') && ismac),
system(['ssh ',Parallel(indPC).user,'@',Parallel(indPC).PcName,' mkdir -p ',Parallel(indPC).RemoteFolder,'/',PRCDir])
system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' mkdir -p ',Parallel(indPC).RemoteDirectory,'/',PRCDir])
else
[NonServeS NonServeD]=mkdir(['\\',Parallel(indPC).PcName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteFolder,'\',PRCDir]);
[NonServeS NonServeD]=mkdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir]);
end
end
end

View File

@ -2,16 +2,15 @@ function dynareParallelRmDir(PRCDir,Parallel)
% PARALLEL CONTEXT
% In a parallel context, this is a specialized version of rmdir() function.
%
% INPUTS
% o PRCDir [] ...
% o Parallel [] ...
%
% INPUT/OUTPUT description:
% OUTPUTS
% None
%
%
%
%
%
% Then at the point call of this function it is possible react in a best way, in accord
% with the ErrorCode.
% Copyright (C) 2009-2010 Dynare Team
%
% This file is part of Dynare.
@ -38,12 +37,11 @@ end
for indPC=1:length(Parallel),
while (1)
% keyboard;
if isunix
stat = system(['ssh ',Parallel(indPC).user,'@',Parallel(indPC).PcName,' rm -fr ',Parallel(indPC).RemoteFolder,'/',PRCDir]);
stat = system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' rm -fr ',Parallel(indPC).RemoteDirectory,'/',PRCDir]);
break;
else
[stat, mess, id] = rmdir(['\\',Parallel(indPC).PcName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteFolder,'\',PRCDir],'s');
[stat, mess, id] = rmdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir],'s');
if stat==1,
break,
else

View File

@ -1,9 +1,16 @@
function dynareParallelSendFiles(NamFileInput,PRCDir,Parallel)
% PARALLEL CONTEXT
% In a parallel context, this is ...
% In a parallel context, this is a specialized mono-directional (Local to Remote) version of copy()
% function.
%
%
% INPUT/OUTPUT description:
% INPUTS
% o NamFileInput [] ...
% o PRCDir [] ...
% o Parallel [] ...
%
% OUTPUTS
% None
%
%
%
@ -37,18 +44,18 @@ for indPC=1:length(Parallel),
if isunix || (~matlab_ver_less_than('7.4') && ismac),
for jfil=1:size(NamFileInput,1),
if ~isempty(NamFileInput{jfil,1})
system(['ssh ',Parallel(indPC).user,'@',Parallel(indPC).PcName,' mkdir -p ',Parallel(indPC).RemoteFolder,'/',PRCDir,'/',NamFileInput{jfil,1}])
system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' mkdir -p ',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1}])
end
system(['scp ',NamFileInput{jfil,1},NamFileInput{jfil,2},' ',Parallel(indPC).user,'@',Parallel(indPC).PcName,':',Parallel(indPC).RemoteFolder,'/',PRCDir,'/',NamFileInput{jfil,1}]);
system(['scp ',NamFileInput{jfil,1},NamFileInput{jfil,2},' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,':',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',NamFileInput{jfil,1}]);
end
else
for jfil=1:size(NamFileInput,1)
if ~isempty(NamFileInput{jfil,1})
if isempty(dynareParallelDir(NamFileInput{jfil,1},PRCDir,Parallel(indPC)))
mkdir(['\\',Parallel(indPC).PcName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteFolder,'\',PRCDir,'\',NamFileInput{jfil,1}]);
mkdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',NamFileInput{jfil,1}]);
end
end
copyfile([NamFileInput{jfil,1},NamFileInput{jfil,2}],['\\',Parallel(indPC).PcName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteFolder,'\',PRCDir,'\',NamFileInput{jfil,1}])
copyfile([NamFileInput{jfil,1},NamFileInput{jfil,2}],['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',NamFileInput{jfil,1}])
end
end
end

View File

@ -1,4 +1,4 @@
function fMessageStatus(prtfrc, njob, waitbarString, waitbarTitle, Parallel, MasterName, DyMo)
function fMessageStatus(prtfrc, njob, waitbarString, waitbarTitle, Parallel)
% PARALLEL CONTEXT
% In parallel context, this function is launched on slave
% machines, and acts as a message passing device for the master machine.
@ -9,9 +9,7 @@ function fMessageStatus(prtfrc, njob, waitbarString, waitbarTitle, Parallel, Mas
% cluster
% o waitbarString [char] running message string to be displayed in the monitor window on master machine
% o waitbarTitle [char] title to be displayed in the monitor window on master machine
% o Parallel [struct] options_.parallel(ThisMatlab), i.e. the paralle settings for this slave machine in the cluster
% o MasterName [char] IP address or PC name of the master
% o DyMo [char] working directory of the master machine
% o Parallel [struct] options_.parallel(ThisMatlab), i.e. the parallel settings for this slave machine in the cluster.
%
% OUTPUTS
% o None

View File

@ -15,8 +15,8 @@ function fParallel(fblck,nblck,whoiam,ThisMatlab,fname)
% (entry in options_.parallel)
% o fname [string] function to be run, containing the computing task
%
% OUTPUTS
% None
% OUTPUTS
% None
%
% Copyright (C) 2006-2008,2010 Dynare Team
%
@ -43,14 +43,13 @@ warning off;
diary off;
delete( [fname,'_',int2str(whoiam),'.log']);
diary( [fname,'_',int2str(whoiam),'.log']);
% Configure dynare environment.
dynareroot = dynare_config();
% Load input data.
load( [fname,'_input'])
load( [fname,'_input'])
if exist('fGlobalVar') && ~isempty (fGlobalVar)
globalVars = fieldnames(fGlobalVar);
@ -64,15 +63,13 @@ if exist('fGlobalVar') && ~isempty (fGlobalVar)
evalin('base','struct2local(fGlobalVar)');
end
fInputVar.Parallel = Parallel;
% Launch the routine to be run in parallel.
try,
tic,
fOutputVar = feval(fname, fInputVar ,fblck, nblck, whoiam, ThisMatlab);
toc,
if isfield(fOutputVar,'OutputFileName'),
@ -81,11 +78,8 @@ try,
OutputFileName = '';
end
if(whoiam)
% Save the output result.
save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' )
end
disp(['fParallel ',int2str(whoiam),' completed.'])
@ -94,11 +88,11 @@ catch ME
fOutputVar.error = ME;
save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' )
waitbarString = fOutputVar.error.message;
% waitbarTitle=['Metropolis-Hastings ',options_.parallel(ThisMatlab).PcName];
% waitbarTitle=['Metropolis-Hastings ',options_.parallel(ThisMatlab).ComputerName];
if Parallel(ThisMatlab).Local,
waitbarTitle='Local ';
else
waitbarTitle=[Parallel(ThisMatlab).PcName];
waitbarTitle=[Parallel(ThisMatlab).ComputerName];
end
fMessageStatus(NaN,whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab));

View File

@ -29,26 +29,28 @@ function [fOutVar,nBlockPerCPU, totCPU] = masterParallel(Parallel,fBlock,nBlock,
% INPUTS
% o Parallel [struct vector] copy of options_.parallel
% o fBlock [int] index number of the first thread
% (between 1 and nBlock)
% (between 1 and nBlock)
% o nBlock [int] index number of the last thread
% o NamFileInput [cell array] containins the list of input files to be
% copied in the working directory of remote slaves
% 2 columns, as many lines as there are files
% - first column contains directory paths
% - second column contains filenames
% copied in the working directory of remote slaves
% 2 columns, as many lines as there are files
% - first column contains directory paths
% - second column contains filenames
% o fname [string] name of the function to be parallelized, and
% which will be run on the slaves
% which will be run on the slaves
% o fInputVar [struct] structure containing local variables to be used
% by fName on the slaves
% by fName on the slaves
% o fGlobalVar [struct] structure containing global variables to be used
% by fName on the slaves
% by fName on the slaves
% o Parallel_info []
% o initialize []
%
% OUTPUT
% o fOutVar [struct vector] result of the parallel computation, one
% o fOutVar [struct vector] result of the parallel computation, one
% struct per thread
% o nBlockPerCPU [int vector] for each CPU used, indicates the number of
% o nBlockPerCPU [int vector] for each CPU used, indicates the number of
% threads run on that CPU
% o totCPU [int] total number of CPU used (can be lower than
% o totCPU [int] total number of CPU used (can be lower than
% the number of CPU declared in "Parallel", if
% the number of required threads is lower)
@ -76,7 +78,7 @@ function [fOutVar,nBlockPerCPU, totCPU] = masterParallel(Parallel,fBlock,nBlock,
% is used only one time and then deleted.
persistent PRCDir
% PRCDir= Present Remote Computational Directory!
% PRCDir = Present Remote Computational Directory!
Strategy=Parallel_info.leaveSlaveOpen;
@ -99,13 +101,21 @@ if nargin>8 && initialize==1
return
end
% The default value for the new field MatlabOctavePath now is 'matlab' or
% 'octave'.
for j=1:length(Parallel),
if isempty(Parallel(j).MatlabPath),
Parallel(j).MatlabPath = 'matlab';
if isempty(Parallel(j).MatlabOctavePath),
Parallel(j).MatlabOctavePath = 'matlab';
end
end
% Only for testing!
% To test AnalyseComputationalEnviroment.m function
% save('Parallel.mat','-struct', 'Parallel');
% Only for testing!
% if Strategy==0
% disp('User Strategy Now Is Open/Close (0)');
% else
@ -129,7 +139,6 @@ end
MasterName=deblank(MasterName);
fInputVar.MasterName = MasterName;
% keyboard;
% Save input data for use by the slaves.
switch Strategy
@ -163,11 +172,12 @@ mydelete(['comp_status_',fname,'*.mat'])
mydelete(['P_',fname,'*End.txt'])
% Create a shell script containing the commands to launch the required tasks on the slaves
% Create a shell script containing the commands to launch the required
% tasks on the slaves.
fid = fopen('ConcurrentCommand1.bat','w+');
% Creo la directory in cui effettuare i calcoli in remoto ...
% Create the directory devoted to remote computation.
if isempty(PRCDir) && ~islocal,
error('PRCDir not initialized!')
else
@ -190,9 +200,8 @@ for j=1:totCPU,
end
offset = sum(nBlockPerCPU(1:j-1))+offset0;
% Creo un file che mi serve per sapere se la computazione di un
% blocco parallelo (una core) è terminata oppure no!
% Create a file used to monitoring if a parallel block (core)
% computation is finished or not.
fid1=fopen(['P_',fname,'_',int2str(j),'End.txt'],'w+');
fclose(fid1);
@ -214,7 +223,7 @@ for j=1:totCPU,
pause(1);
newInstance = 0;
% Check if j CPU is already alive.
% Check if j CPU is already alive.
if isempty(dynareParallelDir(['P_slave_',int2str(j),'End.txt'],PRCDir,Parallel(indPC)));
fid1=fopen(['P_slave_',int2str(j),'End.txt'],'w+');
fclose(fid1);
@ -230,9 +239,10 @@ for j=1:totCPU,
end
else
% Se la computazione è remota, lo creo in locale, lo copio directory remota (creata
% sopra) e lo cancello in locale. Lo stesso vale per gli altri
% dati.
% If the computation is executed remotely all the necessary files
% are created localy, then copied in remote directory and then
% deleted (loacal)!
save( ['slaveParallel_input',int2str(j)],'Parallel');
if Parallel(indPC).Local==0,
@ -241,9 +251,9 @@ for j=1:totCPU,
dynareParallelSendFiles(['slaveParallel_input',int2str(j),'.mat'],PRCDir,Parallel(indPC));
delete(['slaveParallel_input',int2str(j),'.mat']);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -251,22 +261,22 @@ for j=1:totCPU,
switch Strategy
case 0
if Parallel(indPC).Local == 1, %Run on the local machine (localhost).
if Parallel(indPC).Local == 1, % 0.1 Run on the local machine (localhost).
if isunix || (~matlab_ver_less_than('7.4') && ismac),
if exist('OCTAVE_VERSION')
command1=['octave --eval "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')" &'];
else
command1=[Parallel(indPC).MatlabPath,' -nosplash -nodesktop -minimize -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')" &'];
command1=[Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')" &'];
end
else
if exist('OCTAVE_VERSION')
command1=['start /B psexec -W ',DyMo, ' -a ',int2str(Parallel(indPC).NumCPU(j-nCPU0)),' -low octave --eval "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
command1=['start /B psexec -W ',DyMo, ' -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)),' -low octave --eval "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
else
command1=['start /B psexec -W ',DyMo, ' -a ',int2str(Parallel(indPC).NumCPU(j-nCPU0)),' -low ',Parallel(indPC).MatlabPath,' -nosplash -nodesktop -minimize -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
command1=['start /B psexec -W ',DyMo, ' -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)),' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize -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 % Parallel(indPC).Local==0: Run using network on remote machine or also on local machine.
else % 0.2 Parallel(indPC).Local==0: Run using network on remote machine or also on local machine.
if j==nCPU0+1,
dynareParallelSendFiles([fname,'_input.mat'],PRCDir,Parallel(indPC));
dynareParallelSendFiles(NamFileInput,PRCDir,Parallel(indPC));
@ -274,26 +284,26 @@ for j=1:totCPU,
if isunix || (~matlab_ver_less_than('7.4') && ismac),
if exist('OCTAVE_VERSION'),
command1=['ssh ',Parallel(indPC).user,'@',Parallel(indPC).PcName,' "cd ',Parallel(indPC).RemoteFolder,'/',PRCDir, '; octave --eval \"addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''');\" " &'];
command1=['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' "cd ',Parallel(indPC).RemoteDirectory,'/',PRCDir, '; octave --eval \"addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''');\" " &'];
else
command1=['ssh ',Parallel(indPC).user,'@',Parallel(indPC).PcName,' "cd ',Parallel(indPC).RemoteFolder,'/',PRCDir, '; ',Parallel(indPC).MatlabPath,' -nosplash -nodesktop -minimize -r \"addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''');\" " &'];
command1=['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' "cd ',Parallel(indPC).RemoteDirectory,'/',PRCDir, '; ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize -r \"addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''');\" " &'];
end
else
if ~strcmp(Parallel(indPC).PcName,MasterName), % Run on a remote machine!
if ~strcmp(Parallel(indPC).ComputerName,MasterName), % 0.3 Run on a remote machine!
if exist('OCTAVE_VERSION'),
command1=['start /B psexec \\',Parallel(indPC).PcName,' -e -u ',Parallel(indPC).user,' -p ',Parallel(indPC).passwd,' -W ',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteFolder,'\',PRCDir,'\ -a ',int2str(Parallel(indPC).NumCPU(j-nCPU0)), ...
command1=['start /B psexec \\',Parallel(indPC).ComputerName,' -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W ',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\ -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)), ...
' -low octave --eval "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
else
command1=['start /B psexec \\',Parallel(indPC).PcName,' -e -u ',Parallel(indPC).user,' -p ',Parallel(indPC).passwd,' -W ',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteFolder,'\',PRCDir,'\ -a ',int2str(Parallel(indPC).NumCPU(j-nCPU0)), ...
' -low ',Parallel(indPC).MatlabPath,' -nosplash -nodesktop -minimize -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
command1=['start /B psexec \\',Parallel(indPC).ComputerName,' -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W ',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\ -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)), ...
' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
end
else % Run on the local machine via the network
else % 0.4 Run on the local machine via the network
if exist('OCTAVE_VERSION'),
command1=['start /B psexec \\',Parallel(indPC).PcName,' -e -W ',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteFolder,'\',PRCDir,'\ -a ',int2str(Parallel(indPC).NumCPU(j-nCPU0)), ...
command1=['start /B psexec \\',Parallel(indPC).ComputerName,' -e -W ',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\ -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)), ...
' -low octave --eval "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
else
command1=['start /B psexec \\',Parallel(indPC).PcName,' -e -W ',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteFolder,'\',PRCDir,'\ -a ',int2str(Parallel(indPC).NumCPU(j-nCPU0)), ...
' -low ',Parallel(indPC).MatlabPath,' -nosplash -nodesktop -minimize -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
command1=['start /B psexec \\',Parallel(indPC).ComputerName,' -e -W ',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\ -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)), ...
' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"'];
end
end
end
@ -301,25 +311,21 @@ for j=1:totCPU,
case 1
if Parallel(indPC).Local == 1 & newInstance, % Run on the local machine.
if Parallel(indPC).Local == 1 & newInstance, % 1.1 Run on the local machine.
if isunix || (~matlab_ver_less_than('7.4') && ismac),
if exist('OCTAVE_VERSION')
%command1=['octave --eval fParallel\(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',\''',fname,'\''\) &'];
command1=['octave --eval "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')" &'];
else
%command1=[Parallel(indPC).MatlabPath,' -nosplash -nodesktop -minimize -r fParallel\(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',\''',fname,'\''\) &'];
command1=[Parallel(indPC).MatlabPath,' -nosplash -nodesktop -minimize -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')" &'];
command1=[Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')" &'];
end
else
if exist('OCTAVE_VERSION')
%command1=['start /B psexec -W ',DyMo, ' -a ',int2str(Parallel(indPC).NumCPU(j-nCPU0)),' -low octave --eval fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')'];
command1=['start /B psexec -W ',DyMo, ' -a ',int2str(Parallel(indPC).NumCPU(j-nCPU0)),' -low octave --eval "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
command1=['start /B psexec -W ',DyMo, ' -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)),' -low octave --eval "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
else
%command1=['start /B psexec -W ',DyMo, ' -a ',int2str(Parallel(indPC).NumCPU(j-nCPU0)),' -low ',Parallel(indPC).MatlabPath,' -nosplash -nodesktop -minimize -r fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')'];
command1=['start /B psexec -W ',DyMo, ' -a ',int2str(Parallel(indPC).NumCPU(j-nCPU0)),' -low ',Parallel(indPC).MatlabPath,' -nosplash -nodesktop -minimize -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
command1=['start /B psexec -W ',DyMo, ' -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)),' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
end
end
elseif Parallel(indPC).Local==0, % Run using network on remote machine or also on local machine.
elseif Parallel(indPC).Local==0, % 1.2 Run using network on remote machine or also on local machine.
if j==nCPU0+1,
dynareParallelSendFiles(NamFileInput,PRCDir,Parallel(indPC));
end
@ -331,26 +337,26 @@ for j=1:totCPU,
dynareParallelSendFiles(['slaveParallel_input',int2str(j),'.mat'],PRCDir,Parallel(indPC))
if isunix || (~matlab_ver_less_than('7.4') && ismac),
if exist('OCTAVE_VERSION'),
command1=['ssh ',Parallel(indPC).user,'@',Parallel(indPC).PcName,' "cd ',Parallel(indPC).RemoteFolder,'/',PRCDir '; octave --eval \"addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),');\" " &'];
command1=['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' "cd ',Parallel(indPC).RemoteDirectory,'/',PRCDir '; octave --eval \"addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),');\" " &'];
else
command1=['ssh ',Parallel(indPC).user,'@',Parallel(indPC).PcName,' "cd ',Parallel(indPC).RemoteFolder,'/',PRCDir '; ',Parallel(indPC).MatlabPath,' -nosplash -nodesktop -minimize -r \"addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),');\" " &'];
command1=['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' "cd ',Parallel(indPC).RemoteDirectory,'/',PRCDir '; ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize -r \"addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),');\" " &'];
end
else
if ~strcmp(Parallel(indPC).PcName,MasterName), % Run on a remote machine.
if ~strcmp(Parallel(indPC).ComputerName,MasterName), % 1.3 Run on a remote machine.
if exist('OCTAVE_VERSION'),
command1=['start /B psexec \\',Parallel(indPC).PcName,' -e -u ',Parallel(indPC).user,' -p ',Parallel(indPC).passwd,' -W ',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteFolder,'\',PRCDir,'\ -a ',int2str(Parallel(indPC).NumCPU(j-nCPU0)), ...
command1=['start /B psexec \\',Parallel(indPC).ComputerName,' -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W ',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\ -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)), ...
' -low octave --eval "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
else
command1=['start /B psexec \\',Parallel(indPC).PcName,' -e -u ',Parallel(indPC).user,' -p ',Parallel(indPC).passwd,' -W ',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteFolder,'\',PRCDir,'\ -a ',int2str(Parallel(indPC).NumCPU(j-nCPU0)), ...
' -low ',Parallel(indPC).MatlabPath,' -nosplash -nodesktop -minimize -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
command1=['start /B psexec \\',Parallel(indPC).ComputerName,' -e -u ',Parallel(indPC).UserName,' -p ',Parallel(indPC).Password,' -W ',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\ -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)), ...
' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
end
else % Run on the local machine via the network.
else % 1.4 Run on the local machine via the network.
if exist('OCTAVE_VERSION'),
command1=['start /B psexec \\',Parallel(indPC).PcName,' -e -W ',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteFolder,'\',PRCDir,'\ -a ',int2str(Parallel(indPC).NumCPU(j-nCPU0)), ...
command1=['start /B psexec \\',Parallel(indPC).ComputerName,' -e -W ',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\ -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)), ...
' -low octave --eval "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
else
command1=['start /B psexec \\',Parallel(indPC).PcName,' -e -W ',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteFolder,'\',PRCDir,'\ -a ',int2str(Parallel(indPC).NumCPU(j-nCPU0)), ...
' -low ',Parallel(indPC).MatlabPath,' -nosplash -nodesktop -minimize -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
command1=['start /B psexec \\',Parallel(indPC).ComputerName,' -e -W ',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\ -a ',int2str(Parallel(indPC).CPUnbr(j-nCPU0)), ...
' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"'];
end
end
end
@ -364,6 +370,14 @@ for j=1:totCPU,
end
fclose(fid);
% In This way we are sure that the file 'ConcurrentCommand1.bat' is
% closed and then it can be deleted!
while (1)
StatusOfCC1_bat = fclose(fid);
if StatusOfCC1_bat==0
break
end
end
% Run the slaves.
if isunix || (~matlab_ver_less_than('7.4') && ismac),
@ -374,9 +388,7 @@ else
end
% Wait for the slaves to finish their job, and display some progress
% information meanwhile.
% Create a parallel (local/remote) specialized computational status bars!
if exist('OCTAVE_VERSION'),
diary off;
@ -411,7 +423,7 @@ else
'box','on','xtick',[],'ytick',[],'xlim',[0 1],'ylim',[0 1]);
hpat(j) = patch([0 0 0 0],[0 1 1 0],'r','EdgeColor','r');
htit(j) = title(['Initialize ...']);
end
cumBlockPerCPU = cumsum(nBlockPerCPU);
@ -421,6 +433,11 @@ idCPU = NaN(1,totCPU);
delete(['comp_status_',fname,'*.mat']);
% Wait for the slaves to finish their job, and display some progress
% information meanwhile.
ForEver=1;
while (ForEver)
@ -428,10 +445,8 @@ while (ForEver)
waitbarString = '';
statusString = '';
pause(1)
pause(1)
try
if islocal ==0,
dynareParallelGetFiles(['comp_status_',fname,'*.mat'],PRCDir,Parallel(1:totSlaves));
@ -439,11 +454,10 @@ while (ForEver)
catch
end
% stax = dir(['comp_status_',fname,'*.mat']);
for j=1:totCPU, %length(stax),
for j=1:totCPU,
try
if ~isempty(['comp_status_',fname,int2str(j),'.mat'])
load(['comp_status_',fname,int2str(j),'.mat']);% (stax(j).name)
load(['comp_status_',fname,int2str(j),'.mat']);
end
pcerdone(j) = prtfrc;
idCPU(j) = njob;
@ -453,30 +467,23 @@ while (ForEver)
status_String{j} = waitbarString;
status_Title{j} = waitbarTitle;
end
% if prtfrc==1, delete(stax(j).name), end
catch
% pcerdone(j) = NaN;
% idCPU(j) = NaN;
% if j>1
% j=j-1;
% end
catch % ME
% To define!
end
end
if exist('OCTAVE_VERSION'),
printf([statusString,'\r'], 100 .* pcerdone);
else
for j=1:totCPU, %length(stax)
for j=1:totCPU,
try
set(hpat(j),'XData',[0 0 pcerdone(j) pcerdone(j)]);
set(htit(j),'String',[status_Title{j},' - ',status_String{j}]);
catch ME
end
end
end
if isempty(dynareParallelDir(['P_',fname,'_*End.txt'],PRCDir,Parallel(1:totSlaves)));
HoTuttiGliOutput=0;
for j=1:totCPU,
@ -499,12 +506,9 @@ while (ForEver)
disp('Waiting for output files from slaves ...')
end
end
end
% keyboard;
% Create return value.
iscrash = 0;
for j=1:totCPU,
@ -528,19 +532,19 @@ for j=1:totCPU,
end
end
if iscrash,
error('Remote jobs crashed');
error('Remote jobs crashed');
end
pause(1), % wait for all remote diary off completed
% Cleanup. (Only if the computing is executed remotly).
pause(1), % Wait for all remote diary off completed
% Cleanup.
dynareParallelGetFiles('*.log',PRCDir,Parallel(1:totSlaves));
switch Strategy
case 0
for indPC=1:length(Parallel)
if Parallel(indPC).Local == 0
dynareParallelRmDir(PRCDir,Parallel(indPC));
dynareParallelRmDir(PRCDir,Parallel(indPC));
end
if isempty(dir('dynareParallelLogFiles'))
@ -551,13 +555,11 @@ switch Strategy
copyfile('*.log','dynareParallelLogFiles');
delete([fname,'*.log']);
%%%%%%%% E' GIUSTO??? %%%%%%%%%%%%%
mydelete(['*_core*_input*.mat']);
if Parallel(indPC).Local == 1
delete(['slaveParallel_input*.mat']);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% if Parallel(indPC).Local == 1
% delete(['slaveParallel_input*.mat']);
% end
end
delete ConcurrentCommand1.bat

View File

@ -8,9 +8,9 @@ function slaveParallel(whoiam,ThisMatlab)
%
%
% INPUTS
% o whoiam [int] index number of this CPU among all CPUs in the
% o whoiam [int] index number of this CPU among all CPUs in the
% cluster.
% o ThisMatlab [int] index number of this slave machine in the cluster.
% o ThisMatlab [int] index number of this slave machine in the cluster.
%
% OUTPUTS
% None
@ -41,12 +41,11 @@ delete( ['slaveParallel_',int2str(whoiam),'.log']);
diary( ['slaveParallel_',int2str(whoiam),'.log']);
% configure dynare environment
% Configure dynare environment
dynareroot = dynare_config();
% Load input data.
load( ['slaveParallel_input',int2str(whoiam)])
% keyboard;
%Loads fGlobalVar Parallel.
if exist('fGlobalVar'),
@ -73,10 +72,7 @@ while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',in
end
% I wait for 20 min or while mater asks to exit (i.e. it cancels fslave file)
pause(1);
% -> Da Sistemare!!!!!!!!!!!!!!!!
% Con testing su reti vere e con core reali!!!!
fjob = dir(['slaveJob',int2str(whoiam),'.mat']);
if ~isempty(fjob),
@ -95,13 +91,13 @@ while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',in
else
% Only for testing, will be remouved!
if isunix
E1=fopen('/home/ivano/Works/Errore-slaveParallel.txt','w+');
fclose(E1);
else
E1=fopen('c:\dynare_calcs\Errore-slaveParallel.txt','w+');
fclose(E1);
end
% if isunix
% E1=fopen('/home/ivano/Works/Errore-slaveParallel.txt','w+');
% fclose(E1);
% else
% E1=fopen('c:\dynare_calcs\Errore-slaveParallel.txt','w+');
% fclose(E1);
% end
end
end
@ -155,7 +151,7 @@ while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',in
if Parallel(ThisMatlab).Local,
waitbarTitle='Local ';
else
waitbarTitle=[Parallel(ThisMatlab).PcName];
waitbarTitle=[Parallel(ThisMatlab).ComputerName];
end
fMessageStatus(NaN,whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab));
delete(['P_',fname,'_',int2str(whoiam),'End.txt']);

View File

@ -1,10 +1,16 @@
function storeGlobalVars(fname,append)
% Stores all global vars in structure fGlobalVar and saves it in the file fname.mat
% PARALLEL CONTEXT
% In a parallel context, this function stores all global vars in structure
% fGlobalVar and saves it in the file fname.mat
%
% INPUTS
% fname [str] name of the file
% Copyright (C) 2009 Dynare Team
% fname [str] name of the file
%
% OUTPUTS
% None
%
%
% Copyright (C) 2009-2010 Dynare Team
%
% This file is part of Dynare.
%
@ -21,8 +27,9 @@ function storeGlobalVars(fname,append)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
GlobalNames = who('global');
varlist = '';
% varlist = '';
for j=1:length(GlobalNames);
eval(['global ',GlobalNames{j},';']);
eval(['fGlobalVar.',GlobalNames{j},'=',GlobalNames{j},';']);

View File

@ -1,10 +1,16 @@
function struct2local(S),
% The argument is a structure possibly containing several fields.
% This function will create, in the workspace of the calling function,
function struct2local(S)
% PARALLEL CONTEXT
% In a parallel context, this function will create, in the workspace of the calling function,
% as many variables as there are fields in the structure, assigning
% them the value of the fields.
% Copyright (C) 2009 Dynare Team
%
% INPUTS
% o S [struc] This structure possibly containing several fields ...
%
% OUTPUTS
% None
%
% Copyright (C) 2009-2010 Dynare Team
%
% This file is part of Dynare.
%
@ -21,6 +27,7 @@ function struct2local(S),
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
vnam = fieldnames(S);
for j=1:length(vnam),

View File

@ -4,7 +4,7 @@ function myoutput=pm3_core(myinputs,fpar,nvar,whoiam, ThisMatlab)
% Core functionality for pm3.m function, which can be parallelized.
% INPUTS
% See See the comment in random_walk_metropolis_hastings_core.m funtion.
% See the comment in random_walk_metropolis_hastings_core.m funtion.
% OUTPUTS
% o myoutput [struc]
@ -52,8 +52,6 @@ Mean=myinputs.Mean;
if whoiam
Parallel=myinputs.Parallel;
MasterName=myinputs.MasterName;
DyMo=myinputs.DyMo;
end
@ -65,9 +63,9 @@ if whoiam
if Parallel(ThisMatlab).Local,
waitbarTitle=['Local '];
else
waitbarTitle=[Parallel(ThisMatlab).PcName];
waitbarTitle=[Parallel(ThisMatlab).ComputerName];
end
fMessageStatus(0,whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab), MasterName, DyMo);
fMessageStatus(0,whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab));
end
@ -126,7 +124,7 @@ for i=fpar:nvar
if whoiam,
waitbarString = [ 'Variable ' int2str(i) '/' int2str(nvar) ' done.'];
fMessageStatus((i-fpar+1)/(nvar-fpar+1),whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab), MasterName, DyMo);
fMessageStatus((i-fpar+1)/(nvar-fpar+1),whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab));
end

View File

@ -194,9 +194,9 @@ end
b=0;
% Like sequential execution!
if isnumeric(options_.parallel),% | isunix, % For the moment exclude unix platform from parallel implementation!
if isnumeric(options_.parallel),
[fout] = prior_posterior_statistics_core(localVars,1,B,0);
% Parallel execution!
% Parallel execution!
else
[nCPU, totCPU, nBlockPerCPU] = distributeJobs(options_.parallel, 1, B);
for j=1:totCPU-1,
@ -214,8 +214,8 @@ else
ifil(6,j+1) =ifil(6,j)+nfiles;
nfiles = ceil(nBlockPerCPU(j)/MAX_nforc2);
ifil(7,j+1) =ifil(7,j)+nfiles;
% nfiles = ceil(nBlockPerCPU(j)/MAX_momentsno);
% ifil(8,j+1) =ifil(8,j)+nfiles;
% nfiles = ceil(nBlockPerCPU(j)/MAX_momentsno);
% ifil(8,j+1) =ifil(8,j)+nfiles;
end
localVars.ifil = ifil;
globalVars = struct('M_',M_, ...
@ -243,8 +243,8 @@ save([DirectoryName '/' M_.fname '_data.mat'],'stock_gend','stock_data');
if ~isnumeric(options_.parallel),
leaveSlaveOpen = options_.parallel_info.leaveSlaveOpen;
if options_.parallel_info.leaveSlaveOpen == 0,
% Commenting for testing!
% options_.parallel_info.leaveSlaveOpen = 1; % Force locally to leave open remote matlab sessions (repeated pm3 calls)
% Commenting for testing!!!
% options_.parallel_info.leaveSlaveOpen = 1; % Force locally to leave open remote matlab sessions (repeated pm3 calls)
end
end

View File

@ -48,7 +48,6 @@ global options_ oo_ M_ bayestopt_ estim_params_
% Reshape 'myinputs' for local computation.
% In order to avoid confusion in the name space, the instruction struct2local(myinputs) is replaced by:
% Da CONTROLLARE con MARCO!
type=myinputs.type;
run_smoother=myinputs.run_smoother;
gend=myinputs.gend;
@ -87,8 +86,6 @@ if ~strcmpi(type,'prior'),
end
if whoiam
Parallel=myinputs.Parallel;
MasterName=myinputs.MasterName;
DyMo=myinputs.DyMo;
end
DirectoryName = CheckPath('metropolis');
@ -105,9 +102,9 @@ if whoiam
if Parallel(ThisMatlab).Local,
waitbarTitle=['Local '];
else
waitbarTitle=[Parallel(ThisMatlab).PcName];
waitbarTitle=[Parallel(ThisMatlab).ComputerName];
end
fMessageStatus(0,whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab), MasterName, DyMo);
fMessageStatus(0,whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab));
else
if exist('OCTAVE_VERSION')
diary off;
@ -298,11 +295,11 @@ for b=fpar:B
elseif ~whoiam,
waitbar(b/B,h);
end
% if mod(b,10)==0 & whoiam,
if whoiam,
fprintf('Done! \n');
waitbarString = [ 'Subdraw ' int2str(b) '/' int2str(B) ' done.'];
fMessageStatus((b-fpar+1)/(B-fpar+1),whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab), MasterName, DyMo);
fMessageStatus((b-fpar+1)/(B-fpar+1),whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab));
end
end

View File

@ -63,6 +63,19 @@ InitSizeArray = min([repmat(MAX_nruns,nblck,1) fline+nruns-1],[],2);
load([MhDirectoryName '/' ModelName '_mh_history.mat'],'record');
% Only for test parallel results!!!
% To check the equivalence between parallel and seria computation!
% First run in serial mode, and then comment the follow line.
% save('recordSerial.mat','-struct', 'record');
% For parllel runs after serial runs with the abobe line active.
% TempRecord=load('recordSerial.mat');
% record.Seeds=TempRecord.Seeds;
% Snapshot of the current state of computing. It necessary for the parallel
% execution (i.e. to execute in a corretct way portion of code remotely or
% on many core). The mandatory variables for local/remote parallel

View File

@ -95,8 +95,6 @@ varargin=myinputs.varargin;
% Necessary only for remote computing!
if whoiam
Parallel=myinputs.Parallel;
MasterName=myinputs.MasterName;
DyMo=myinputs.DyMo;
% initialize persistent variables in priordens()
priordens(xparam1,bayestopt_.pshape,bayestopt_.p6,bayestopt_.p7, ...
bayestopt_.p3,bayestopt_.p4,1);
@ -154,13 +152,13 @@ for b = fblck:nblck,
elseif whoiam
% keyboard;
waitbarString = ['Please wait... Metropolis-Hastings (' int2str(b) '/' int2str(options_.mh_nblck) ')...'];
% waitbarTitle=['Metropolis-Hastings ',options_.parallel(ThisMatlab).PcName];
% waitbarTitle=['Metropolis-Hastings ',options_.parallel(ThisMatlab).ComputerName];
if options_.parallel(ThisMatlab).Local,
waitbarTitle=['Local '];
else
waitbarTitle=[options_.parallel(ThisMatlab).PcName];
waitbarTitle=[options_.parallel(ThisMatlab).ComputerName];
end
fMessageStatus(0,whoiam,waitbarString, waitbarTitle, options_.parallel(ThisMatlab), MasterName, DyMo);
fMessageStatus(0,whoiam,waitbarString, waitbarTitle, options_.parallel(ThisMatlab));
else,
hh = waitbar(0,['Please wait... Metropolis-Hastings (' int2str(b) '/' int2str(options_.mh_nblck) ')...']);
set(hh,'Name','Metropolis-Hastings');
@ -204,7 +202,7 @@ for b = fblck:nblck,
if mod(j,50)==0 & whoiam
% keyboard;
waitbarString = [ '(' int2str(b) '/' int2str(options_.mh_nblck) '), ' sprintf('accept. %3.f%%%%', 100 * isux/j)];
fMessageStatus(prtfrc,whoiam,waitbarString, '', options_.parallel(ThisMatlab), MasterName, DyMo);
fMessageStatus(prtfrc,whoiam,waitbarString, '', options_.parallel(ThisMatlab));
end
else
if mod(j, 3)==0 & ~whoiam
@ -212,7 +210,7 @@ for b = fblck:nblck,
elseif mod(j,50)==0 & whoiam,
% keyboard;
waitbarString = [ '(' int2str(b) '/' int2str(options_.mh_nblck) ') ' sprintf('%f done, acceptation rate %f',prtfrc,isux/j)];
fMessageStatus(prtfrc,whoiam,waitbarString, waitbarTitle, options_.parallel(ThisMatlab), MasterName, DyMo);
fMessageStatus(prtfrc,whoiam,waitbarString, waitbarTitle, options_.parallel(ThisMatlab));
end
end