Commit 64e6de59 authored by Marco Ratto's avatar Marco Ratto
Browse files

last provisions for hybrid unix <-> win clusters

parent 15274080
...@@ -291,7 +291,7 @@ for j=1:totCPU, ...@@ -291,7 +291,7 @@ for j=1:totCPU,
if Parallel(indPC).Local == 1, % 0.1 Run on the local machine (localhost). if Parallel(indPC).Local == 1, % 0.1 Run on the local machine (localhost).
if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem), % Hybrid computing Windows(Master)-> Unix(Slaves)! if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem), % Hybrid computing Windows <-> Unix!
if strfind([Parallel(indPC).MatlabOctavePath], 'octave') % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa! if strfind([Parallel(indPC).MatlabOctavePath], 'octave') % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
command1=['octave --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=['octave --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 else
...@@ -310,23 +310,24 @@ for j=1:totCPU, ...@@ -310,23 +310,24 @@ for j=1:totCPU,
dynareParallelSendFiles(NamFileInput,PRCDir,Parallel(indPC)); dynareParallelSendFiles(NamFileInput,PRCDir,Parallel(indPC));
end end
if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem), % Hybrid computing Windows(Master)-> Unix(Slaves)! if (~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)), % Hybrid computing Windows <-> Unix!
if ispc, token='start /B '; if ispc, token='start /B ';
else token = ''; else token = '';
end end
remote_file=['remote_dynare',int2str(j)]; % To manage the diferences in Unix/Windows OS syntax.
fidRemote=fopen([remote_file,'.m'],'w+'); remoteFile=['remoteDynare',int2str(j)];
fidRemote=fopen([remoteFile,'.m'],'w+');
if strfind([Parallel(indPC).MatlabOctavePath], 'octave'),% Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa! if strfind([Parallel(indPC).MatlabOctavePath], 'octave'),% Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
remote_str=['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,''')']; remoteString=['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=[token, 'ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' "cd ',Parallel(indPC).RemoteDirectory,'/',PRCDir, '; octave --eval ',remote_file,' " &']; command1=[token, 'ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' "cd ',Parallel(indPC).RemoteDirectory,'/',PRCDir, '; octave --eval ',remoteFile,' " &'];
else else
remote_str=['addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')']; remoteString=['addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')'];
command1=[token, 'ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' "cd ',Parallel(indPC).RemoteDirectory,'/',PRCDir, '; ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r ',remote_file,';" &']; command1=[token, 'ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' "cd ',Parallel(indPC).RemoteDirectory,'/',PRCDir, '; ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r ',remoteFile,';" &'];
end end
fprintf(fidRemote,'%s\n',remote_str) fprintf(fidRemote,'%s\n',remoteString);
fclose(fidRemote), fclose(fidRemote);
dynareParallelSendFiles([remote_file,'.m'],PRCDir,Parallel(indPC)); dynareParallelSendFiles([remoteFile,'.m'],PRCDir,Parallel(indPC));
delete([remote_file,'.m']); delete([remoteFile,'.m']);
else else
if ~strcmp(Parallel(indPC).ComputerName,MasterName), % 0.3 Run on a remote machine! if ~strcmp(Parallel(indPC).ComputerName,MasterName), % 0.3 Run on a remote machine!
% Hybrid computing Matlab(Master)-> Octave(Slaves) and Vice Versa! % Hybrid computing Matlab(Master)-> Octave(Slaves) and Vice Versa!
...@@ -352,10 +353,9 @@ for j=1:totCPU, ...@@ -352,10 +353,9 @@ for j=1:totCPU,
case 1 case 1
if Parallel(indPC).Local == 1 && newInstance, % 1.1 Run on the local machine. if Parallel(indPC).Local == 1 && newInstance, % 1.1 Run on the local machine.
if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem), % Hybrid computing Windows(Master)-> Unix(Slaves)! if (~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)), % Hybrid computing Windows <-> Unix!
% Hybrid computing Matlab(Master)-> Octave(Slaves) and Vice Versa! if strfind([Parallel(indPC).MatlabOctavePath], 'octave') % Hybrid computing Matlab(Master)-> Octave(Slaves) and Vice Versa!
if strfind([Parallel(indPC).MatlabOctavePath], 'octave')
command1=['octave --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')" &']; command1=['octave --eval "default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')" &'];
else else
command1=[Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')" &']; command1=[Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')" &'];
...@@ -377,16 +377,24 @@ for j=1:totCPU, ...@@ -377,16 +377,24 @@ for j=1:totCPU,
dynareParallelSendFiles(['slaveJob',int2str(j),'.mat'],PRCDir,Parallel(indPC)); dynareParallelSendFiles(['slaveJob',int2str(j),'.mat'],PRCDir,Parallel(indPC));
delete(['slaveJob',int2str(j),'.mat']); delete(['slaveJob',int2str(j),'.mat']);
dynareParallelSendFiles(['slaveParallel_input',int2str(j),'.mat'],PRCDir,Parallel(indPC)) dynareParallelSendFiles(['slaveParallel_input',int2str(j),'.mat'],PRCDir,Parallel(indPC))
if ~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem), % Hybrid computing Windows(Master)-> Unix(Slaves)! if (~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)), % Hybrid computing Windows <-> Unix!
if ispc, token='start /B '; if ispc, token='start /B ';
else token = ''; else token = '';
end end
% Hybrid computing Matlab(Master)-> Octave(Slaves) and Vice Versa! % To manage the diferences in Unix/Windows OS syntax.
if strfind([Parallel(indPC).MatlabOctavePath], 'octave') remoteFile=['remoteDynare',int2str(j)];
command1=[token, 'ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' "cd ',Parallel(indPC).RemoteDirectory,'/',PRCDir '; octave --eval \"default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),');\" " &']; fidRemote=fopen([remoteFile,'.m'],'w+');
if strfind([Parallel(indPC).MatlabOctavePath], 'octave') % Hybrid computing Matlab(Master)-> Octave(Slaves) and Vice Versa!
remoteString=['default_save_options(''-v7''); addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),');'];
command1=[token, 'ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' "cd ',Parallel(indPC).RemoteDirectory,'/',PRCDir '; octave --eval ',remoteFile,' " &'];
else else
command1=[token, 'ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' "cd ',Parallel(indPC).RemoteDirectory,'/',PRCDir '; ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r \"addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),');\" " &']; remoteString=['addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),');'];
command1=[token, 'ssh ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' "cd ',Parallel(indPC).RemoteDirectory,'/',PRCDir '; ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r ',remoteFile,';" &'];
end end
fprintf(fidRemote,'%s\n',remoteString);
fclose(fidRemote);
dynareParallelSendFiles([remoteFile,'.m'],PRCDir,Parallel(indPC));
delete([remoteFile,'.m']);
else else
if ~strcmp(Parallel(indPC).ComputerName,MasterName), % 1.3 Run on a remote machine. if ~strcmp(Parallel(indPC).ComputerName,MasterName), % 1.3 Run on a remote machine.
% Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa! % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa!
...@@ -438,7 +446,6 @@ while (1) ...@@ -438,7 +446,6 @@ while (1)
break break
end end
end end
% Snapshot of the contents of all the directories involved in parallel % Snapshot of the contents of all the directories involved in parallel
% computing. This is necessary when I want to copy continuously the files produced by % computing. This is necessary when I want to copy continuously the files produced by
% the slaves ... % the slaves ...
...@@ -449,8 +456,7 @@ if Strategy==0 || newInstance, % See above. ...@@ -449,8 +456,7 @@ if Strategy==0 || newInstance, % See above.
% Run the slaves. % Run the slaves.
if ~ispc, %isunix || (~matlab_ver_less_than('7.4') && ismac), if ~ispc, %isunix || (~matlab_ver_less_than('7.4') && ismac),
% keyboard system('sh ConcurrentCommand1.bat &');
system('sh ConcurrentCommand1.bat & 2> concurrent.txt');
pause(1) pause(1)
else else
...@@ -579,7 +585,6 @@ global NuoviFilecopiati ...@@ -579,7 +585,6 @@ global NuoviFilecopiati
NuoviFilecopiati=zeros(1,totSlaves); NuoviFilecopiati=zeros(1,totSlaves);
% End % End
ForEver=1; ForEver=1;
statusString = ''; statusString = '';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment