diff --git a/matlab/fMessageStatus.m b/matlab/fMessageStatus.m index ca7e4c9b319f4ba002365265c2050e1e40b68b93..0cc6d3b31e4491a565292f77692394b34c661dca 100644 --- a/matlab/fMessageStatus.m +++ b/matlab/fMessageStatus.m @@ -1,4 +1,14 @@ function fMessageStatus(prtfrc, njob, waitbarString, waitbarTitle, Parallel, MasterName, DyMo) +% In a parallelization context, this function is launched on slave +% machines, and acts as a message passing device for the master machine. +% prtfrc [double], fraction of iteration performed +% njob [int], index number of this CPU among all CPUs in the +% cluster +% waitbarString [char], running message string to be displayed in the monitor window on master machine +% waitbarTitle [char], title to be displayed in the monitor window on master machine +% Parallel [struct], options_.parallel(ThisMatlab), i.e. the paralle settings for this slave machine in the cluster +% MasterName [char], IP address or PC name of the master +% DyMo [char], working directory of the master machine % Copyright (C) 2009 Dynare Team % @@ -25,7 +35,7 @@ end save(['comp_status_',funcName,int2str(njob),'.mat'],'prtfrc','njob','waitbarString','waitbarTitle'); if Parallel.Local==0, - if isunix, + if isunix || (~matlab_ver_less_than('7.4') && ismac), system(['scp comp_status_',funcName,int2str(njob),'.mat ',Parallel.user,'@',MasterName,':',DyMo]); else copyfile(['comp_status_',funcName,int2str(njob),'.mat'],['\\',MasterName,'\',DyMo(1),'$\',DyMo(4:end),'\']); diff --git a/matlab/fParallel.m b/matlab/fParallel.m index c8d3200201abcb5d7d6729131a08b45e0b788b59..aaa509636bd3c4b455337cac6aef64750fe4fccf 100644 --- a/matlab/fParallel.m +++ b/matlab/fParallel.m @@ -6,7 +6,7 @@ function fParallel(fblck,nblck,whoiam,ThisMatlab,fname) % INPUTS % fblck [int] index number of the first thread to run in this % MATLAB instance -% nblck [int] index number of the first thread to run in this +% nblck [int] number of threads to run in this % MATLAB instance % whoiam [int] index number of this CPU among all CPUs in the % cluster @@ -58,19 +58,20 @@ if exist('fGlobalVar'), end % On UNIX, mount the master working directory through SSH FS -if isunix & Parallel(ThisMatlab).Local==0, - system(['mkdir ~/MasterRemoteMirror_',fname,'_',int2str(whoiam)]); - system(['sshfs ',Parallel(ThisMatlab).user,'@',fInputVar.MasterName,':/',fInputVar.DyMo,' ~/MasterRemoteMirror_',fname,'_',int2str(whoiam)]); -end - -% Special hack for MH directory -if isfield(fInputVar,'MhDirectoryName') & Parallel(ThisMatlab).Local==0, - if isunix, - fInputVar.MhDirectoryName = ['~/MasterRemoteMirror_',fname,'_',int2str(whoiam),'/',fInputVar.MhDirectoryName]; - else - fInputVar.MhDirectoryName = ['\\',fInputVar.MasterName,'\',fInputVar.DyMo(1),'$\',fInputVar.DyMo(4:end),'\',fInputVar.MhDirectoryName]; - end -end +% if (isunix | (~matlab_ver_less_than('7.4') & ismac) ) & Parallel(ThisMatlab).Local==0, +% system(['mkdir ~/MasterRemoteMirror_',fname,'_',int2str(whoiam)]); +% system(['sshfs ',Parallel(ThisMatlab).user,'@',fInputVar.MasterName,':/',fInputVar.DyMo,' ~/MasterRemoteMirror_',fname,'_',int2str(whoiam)]); +% end + +% Special hack for MH directory: possibly no longer needed ?????? now all +% files are managed locally and sent backwards later on in this routine! +% if isfield(fInputVar,'MhDirectoryName') & Parallel(ThisMatlab).Local==0, +% if isunix | (~matlab_ver_less_than('7.4') & ismac), +% fInputVar.MhDirectoryName = ['~/MasterRemoteMirror_',fname,'_',int2str(whoiam),'/',fInputVar.MhDirectoryName]; +% else +% fInputVar.MhDirectoryName = ['\\',fInputVar.MasterName,'\',fInputVar.DyMo(1),'$\',fInputVar.DyMo(4:end),'\',fInputVar.MhDirectoryName]; +% end +% end fInputVar.Parallel = Parallel; % Launch the routine to be run in parallel @@ -92,7 +93,7 @@ if(whoiam) if Parallel(ThisMatlab).Local delete(['P_',fname,'_',int2str(whoiam),'End.txt']); else - if isunix, + if isunix || (~matlab_ver_less_than('7.4') && ismac), for j=1:size(OutputFileName,1), system(['scp ',OutputFileName{j,1},OutputFileName{j,2},' ',Parallel(ThisMatlab).user,'@',fInputVar.MasterName,':',fInputVar.DyMo,'/',OutputFileName{j,1}]); end diff --git a/matlab/masterParallel.m b/matlab/masterParallel.m index 8510c5276244e4813489c99667bd17665cb47ea5..0709e98fb0ddb1767274237468ec1be222776128 100644 --- a/matlab/masterParallel.m +++ b/matlab/masterParallel.m @@ -51,8 +51,9 @@ totCPU=0; % Determine my hostname and my working directory DyMo=pwd; fInputVar.DyMo=DyMo; -if isunix, - [tempo, MasterName]=system(['ifconfig | grep ''inet addr:''| grep -v ''127.0.0.1'' | cut -d: -f2 | awk ''{ print $1}''']); +if isunix || (~matlab_ver_less_than('7.4') && ismac) , +% [tempo, MasterName]=system(['ifconfig | grep ''inet addr:''| grep -v ''127.0.0.1'' | cut -d: -f2 | awk ''{ print $1}''']); + [tempo, MasterName]=system('hostname --fqdn'); else [tempo, MasterName]=system('hostname'); end @@ -105,7 +106,7 @@ for j=1:totCPU, fclose(fid1); if Parallel(indPC).Local == 1, % run on the local machine - if isunix, + 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,'\''\) &']; else @@ -119,8 +120,9 @@ for j=1:totCPU, end end else - if isunix, - [tempo, RemoteName]=system(['ssh ',Parallel(indPC).user,'@',Parallel(indPC).PcName,' "ifconfig | grep \''inet addr:\''| grep -v \''127.0.0.1\'' | cut -d: -f2 | awk \''{ print $1}\''"']); + if isunix || (~matlab_ver_less_than('7.4') && ismac), +% [tempo, RemoteName]=system(['ssh ',Parallel(indPC).user,'@',Parallel(indPC).PcName,' "ifconfig | grep \''inet addr:\''| grep -v \''127.0.0.1\'' | cut -d: -f2 | awk \''{ print $1}\''"']); + [tempo, RemoteName]=system(['ssh ',Parallel(indPC).user,'@',Parallel(indPC).PcName,' "hostname --fqdn"']); RemoteName=RemoteName(1:end-1); RemoteFolder = Parallel(indPC).RemoteFolder; else @@ -137,7 +139,7 @@ for j=1:totCPU, end if remoteFlag, if j==nCPU0+1, - if isunix, + if isunix || (~matlab_ver_less_than('7.4') && ismac), system(['ssh ',Parallel(indPC).user,'@',Parallel(indPC).PcName,' rm -fr ',Parallel(indPC).RemoteFolder,'/*']); else mydelete('*.*',['\\',Parallel(indPC).PcName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteFolder,'\']); @@ -150,7 +152,7 @@ for j=1:totCPU, end end - if isunix, + if isunix || (~matlab_ver_less_than('7.4') && ismac), system(['scp ',fname,'_input.mat ',Parallel(indPC).user,'@',Parallel(indPC).PcName,':',Parallel(indPC).RemoteFolder]); for jfil=1:size(NamFileInput,1) if ~isempty(NamFileInput{jfil,1}) @@ -167,7 +169,7 @@ for j=1:totCPU, end end - if isunix, + 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, '; octave --eval fParallel\(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',\''',fname,'\''\);" &']; else @@ -199,7 +201,7 @@ end fclose(fid); % Run the slaves -if isunix, +if isunix || (~matlab_ver_less_than('7.4') && ismac), system('sh ConcurrentCommand1.bat &'); pause(1) else