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
% 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_
for j=1:length(options_.parallel),
@ -58,7 +68,7 @@ end
% parallel computations with Strategy == 1 delete the traces (if exists) of
% previous computations.
delete(['P_slave_*End.txt'])
delete(['P_slave_*End.txt']);
masterParallel(options_.parallel,[],[],[],[],[],[],options_.parallel_info,1);
return

View File

@ -4,11 +4,11 @@ function dirlist = dynareParallelDir(filename,PRCDir,Parallel)
%
% INPUTS
% o filename [] ...
% o PRCDir [] ...
% o Parallel [] ...
% o PRCDir [] ...
% o Parallel [] ...
%
% OUTPUTS
% o dirlist [] ...
% o dirlist [] ...
%
% Copyright (C) 2009-2010 Dynare Team
%
@ -31,21 +31,40 @@ dirlist=[];
for indPC=1:length(Parallel),
if ~ispc, %isunix || (~matlab_ver_less_than('7.4') && ismac),
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;
ax=[];
end
else
try
ax=ls(filename);
catch
ax=[];
if exist('OCTAVE_VERSION') % Patch for peculiar behaviour of ls under Linux.
% 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
dirlist = [dirlist, ax];
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,
ax0=dir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',filename]);
else
@ -59,7 +78,7 @@ for indPC=1:length(Parallel),
end
ax=char(ax{:});
end
else
if Parallel(indPC).Local==0,
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)
if Parallel(indPC).Local==0,
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
[NonServeS NonServeD]=mkdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir]);
end

View File

@ -37,11 +37,21 @@ end
for indPC=1:length(Parallel),
while (1)
if isunix
if ~ispc
stat = system(['ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' rm -fr ',Parallel(indPC).RemoteDirectory,'/',PRCDir]);
break;
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');
end
if stat==1,
break,
else

View File

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

View File

@ -45,19 +45,19 @@ diary( ['slaveParallel_',int2str(whoiam),'.log']);
dynareroot = dynare_config();
% Load input data.
load( ['slaveParallel_input',int2str(whoiam)])
load( ['slaveParallel_input',int2str(whoiam)]);
%Loads fGlobalVar Parallel.
if exist('fGlobalVar'),
globalVars = fieldnames(fGlobalVar);
for j=1:length(globalVars),
eval(['global ',globalVars{j},';'])
evalin('base',['global ',globalVars{j},';'])
eval(['global ',globalVars{j},';']);
evalin('base',['global ',globalVars{j},';']);
end
struct2local(fGlobalVar);
clear fGlobalVar
% 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','clear fGlobalVar');
end
@ -109,12 +109,12 @@ while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',in
for j=1:length(globalVars),
info_whos = whos(globalVars{j});
if isempty(info_whos) || ~info_whos.global,
eval(['global ',globalVars{j},';'])
evalin('base',['global ',globalVars{j},';'])
eval(['global ',globalVars{j},';']);
evalin('base',['global ',globalVars{j},';']);
end
end
struct2local(fGlobalVar);
evalin('base',['load( [''slaveJob',int2str(whoiam),'''],''fGlobalVar'')'])
evalin('base',['load( [''slaveJob',int2str(whoiam),'''],''fGlobalVar'')']);
evalin('base','struct2local(fGlobalVar)');
evalin('base','clear fGlobalVar');
end
@ -135,18 +135,18 @@ while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',in
if(whoiam)
% 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
delete(['P_',fname,'_',int2str(whoiam),'End.txt']);
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
catch ME
disp(['Job ',fname,' on CPU ',int2str(whoiam),' crashed.'])
disp(['Job ',fname,' on CPU ',int2str(whoiam),' crashed.']);
fOutputVar.error = ME;
save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' )
save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' );
waitbarString = fOutputVar.error.message;
if Parallel(ThisMatlab).Local,
waitbarTitle='Local ';
@ -163,7 +163,7 @@ while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',in
end
disp(['slaveParallel on CPU ',int2str(whoiam),' completed.'])
disp(['slaveParallel on CPU ',int2str(whoiam),' completed.']);
diary off;
delete(['P_slave_',int2str(whoiam),'End.txt']);