Merge remote branch 'ratto/master'

time-shift
Sébastien Villemot 2011-02-02 09:58:58 +01:00
commit 8111b671ff
6 changed files with 66 additions and 27 deletions

View File

@ -33,6 +33,16 @@ function InitializeComputationalEnvironment()
% 'octave'. Then if the field is empty it is necessary to fill it with the % 'octave'. Then if the field is empty it is necessary to fill it with the
% default value. % default value.
% Deactivate some 'Parallel/Warning' message in Octave!
% Comment the line 'warning('off');' in order to view the warning message
% in Octave!
if exist('OCTAVE_VERSION'),
warning('off');
end
global options_ global options_
for j=1:length(options_.parallel), for j=1:length(options_.parallel),
@ -58,7 +68,7 @@ end
% parallel computations with Strategy == 1 delete the traces (if exists) of % parallel computations with Strategy == 1 delete the traces (if exists) of
% previous computations. % previous computations.
delete(['P_slave_*End.txt']) delete(['P_slave_*End.txt']);
masterParallel(options_.parallel,[],[],[],[],[],[],options_.parallel_info,1); masterParallel(options_.parallel,[],[],[],[],[],[],options_.parallel_info,1);
return return

View File

@ -4,11 +4,11 @@ function dirlist = dynareParallelDir(filename,PRCDir,Parallel)
% %
% INPUTS % INPUTS
% o filename [] ... % o filename [] ...
% o PRCDir [] ... % o PRCDir [] ...
% o Parallel [] ... % o Parallel [] ...
% %
% OUTPUTS % OUTPUTS
% o dirlist [] ... % o dirlist [] ...
% %
% Copyright (C) 2009-2010 Dynare Team % Copyright (C) 2009-2010 Dynare Team
% %
@ -31,21 +31,40 @@ dirlist=[];
for indPC=1:length(Parallel), for indPC=1:length(Parallel),
if ~ispc, %isunix || (~matlab_ver_less_than('7.4') && ismac), if ~ispc, %isunix || (~matlab_ver_less_than('7.4') && ismac),
if Parallel(indPC).Local==0, if Parallel(indPC).Local==0,
[check, ax]=system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' ls ',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',filename]); if exist('OCTAVE_VERSION') % Patch for peculiar behaviour of ssh-ls under Linux.
% It is necessary to capture the ls warning message.
% To do it under the ssh protocol it is necessary to redirect the ls message in a text file.
% The file is 'OctaveStandardOutputMessage.txt' and it is
% saved in the Model directory.
[check, ax]=system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' ls ',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',filename, ' 2> OctaveStandardOutputMessage.txt']);
else
[check, ax]=system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' ls ',Parallel(indPC).RemoteDirectory,'/',PRCDir,'/',filename]);
end
if check ~ 0; if check ~ 0;
ax=[]; ax=[];
end end
else else
try
ax=ls(filename); if exist('OCTAVE_VERSION') % Patch for peculiar behaviour of ls under Linux.
catch
ax=[]; % It is necessary to capture the ls warning message and properly manage the jolly char '*'!
[check ax]=system(['ls ' ,filename, ' 2> OctaveStandardOutputMessage.txt']);
if check ~ 0;
ax=[];
end
else
try
ax=ls(filename);
catch
ax=[];
end
end end
end end
dirlist = [dirlist, ax]; dirlist = [dirlist, ax];
else else
if exist('OCTAVE_VERSION'), % patch for peculiar behaviour of ls under Windows if exist('OCTAVE_VERSION'), % Patch for peculiar behaviour of ls under Windows.
if Parallel(indPC).Local==0, if Parallel(indPC).Local==0,
ax0=dir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',filename]); ax0=dir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',filename]);
else else
@ -59,7 +78,7 @@ for indPC=1:length(Parallel),
end end
ax=char(ax{:}); ax=char(ax{:});
end end
else else
if Parallel(indPC).Local==0, if Parallel(indPC).Local==0,
ax=ls(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',filename]); ax=ls(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',filename]);

View File

@ -37,7 +37,7 @@ end
for indPC=1:length(Parallel) for indPC=1:length(Parallel)
if Parallel(indPC).Local==0, if Parallel(indPC).Local==0,
if ~ispc, %isunix || (~matlab_ver_less_than('7.4') && ismac), if ~ispc, %isunix || (~matlab_ver_less_than('7.4') && ismac),
system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' mkdir -p ',Parallel(indPC).RemoteDirectory,'/',PRCDir]); [NonServeS NonServeD]=system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' mkdir -p ',Parallel(indPC).RemoteDirectory,'/',PRCDir]);
else else
[NonServeS NonServeD]=mkdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir]); [NonServeS NonServeD]=mkdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir]);
end end

View File

@ -37,11 +37,21 @@ end
for indPC=1:length(Parallel), for indPC=1:length(Parallel),
while (1) while (1)
if isunix if ~ispc
stat = system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' rm -fr ',Parallel(indPC).RemoteDirectory,'/',PRCDir]); stat = system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' rm -fr ',Parallel(indPC).RemoteDirectory,'/',PRCDir]);
break; break;
else else
if exist('OCTAVE_VERSION'), % Patch for peculiar behaviour of rmdir under Windows.
% It is necessary because the command rmdir always ask at the user to confirm your decision before
% deleting a directory: this stops the computation! The Octave native function 'confirm_recursive_rmdir'
% disable this mechanism.
val = confirm_recursive_rmdir (false);
[stat, mess, id] = rmdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir],'s');
else
[stat, mess, id] = rmdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir],'s'); [stat, mess, id] = rmdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir],'s');
end
if stat==1, if stat==1,
break, break,
else else

View File

@ -44,6 +44,6 @@ end
fslave = dir( ['slaveParallel_input',int2str(njob),'.mat']); fslave = dir( ['slaveParallel_input',int2str(njob),'.mat']);
if isempty(fslave), if isempty(fslave),
error('Master asked to break the job') error('Master asked to break the job');
end end

View File

@ -45,19 +45,19 @@ diary( ['slaveParallel_',int2str(whoiam),'.log']);
dynareroot = dynare_config(); dynareroot = dynare_config();
% Load input data. % Load input data.
load( ['slaveParallel_input',int2str(whoiam)]) load( ['slaveParallel_input',int2str(whoiam)]);
%Loads fGlobalVar Parallel. %Loads fGlobalVar Parallel.
if exist('fGlobalVar'), if exist('fGlobalVar'),
globalVars = fieldnames(fGlobalVar); globalVars = fieldnames(fGlobalVar);
for j=1:length(globalVars), for j=1:length(globalVars),
eval(['global ',globalVars{j},';']) eval(['global ',globalVars{j},';']);
evalin('base',['global ',globalVars{j},';']) evalin('base',['global ',globalVars{j},';']);
end end
struct2local(fGlobalVar); struct2local(fGlobalVar);
clear fGlobalVar clear fGlobalVar
% create global variables in the base workspace as well % create global variables in the base workspace as well
evalin('base',['load( [''slaveParallel_input',int2str(whoiam),'''],''fGlobalVar'')']) evalin('base',['load( [''slaveParallel_input',int2str(whoiam),'''],''fGlobalVar'')']) ;
evalin('base','struct2local(fGlobalVar)'); evalin('base','struct2local(fGlobalVar)');
evalin('base','clear fGlobalVar'); evalin('base','clear fGlobalVar');
end end
@ -109,12 +109,12 @@ while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',in
for j=1:length(globalVars), for j=1:length(globalVars),
info_whos = whos(globalVars{j}); info_whos = whos(globalVars{j});
if isempty(info_whos) || ~info_whos.global, if isempty(info_whos) || ~info_whos.global,
eval(['global ',globalVars{j},';']) eval(['global ',globalVars{j},';']);
evalin('base',['global ',globalVars{j},';']) evalin('base',['global ',globalVars{j},';']);
end end
end end
struct2local(fGlobalVar); struct2local(fGlobalVar);
evalin('base',['load( [''slaveJob',int2str(whoiam),'''],''fGlobalVar'')']) evalin('base',['load( [''slaveJob',int2str(whoiam),'''],''fGlobalVar'')']);
evalin('base','struct2local(fGlobalVar)'); evalin('base','struct2local(fGlobalVar)');
evalin('base','clear fGlobalVar'); evalin('base','clear fGlobalVar');
end end
@ -135,18 +135,18 @@ while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',in
if(whoiam) if(whoiam)
% Save the output result. % Save the output result.
save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' ) save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' );
% Inform the master that the job is finished, and transfer the output data % Inform the master that the job is finished, and transfer the output data
delete(['P_',fname,'_',int2str(whoiam),'End.txt']); delete(['P_',fname,'_',int2str(whoiam),'End.txt']);
end end
disp(['Job ',fname,' on CPU ',int2str(whoiam),' completed.']) disp(['Job ',fname,' on CPU ',int2str(whoiam),' completed.']);
t0 =clock; % Re-set waiting time of 20 mins t0 =clock; % Re-set waiting time of 20 mins
catch ME catch ME
disp(['Job ',fname,' on CPU ',int2str(whoiam),' crashed.']) disp(['Job ',fname,' on CPU ',int2str(whoiam),' crashed.']);
fOutputVar.error = ME; fOutputVar.error = ME;
save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' ) save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' );
waitbarString = fOutputVar.error.message; waitbarString = fOutputVar.error.message;
if Parallel(ThisMatlab).Local, if Parallel(ThisMatlab).Local,
waitbarTitle='Local '; waitbarTitle='Local ';
@ -163,7 +163,7 @@ while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',in
end end
disp(['slaveParallel on CPU ',int2str(whoiam),' completed.']) disp(['slaveParallel on CPU ',int2str(whoiam),' completed.']);
diary off; diary off;
delete(['P_slave_',int2str(whoiam),'End.txt']); delete(['P_slave_',int2str(whoiam),'End.txt']);