1) Several bug fixes for making the remote threads work properly under the Always/Open mode;
2) small cosmethics;time-shift
parent
f743f0375d
commit
0e98d4266c
|
@ -47,6 +47,8 @@ function [fOutVar,nBlockPerCPU, totCPU] = masterParallelMan(Parallel,fBlock,nBlo
|
|||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
% Delete the traces (if exists) of last section computations.
|
||||
persistent initialize
|
||||
|
||||
if isempty(initialize),
|
||||
|
@ -59,6 +61,7 @@ end
|
|||
totCPU=0;
|
||||
|
||||
% Determine my hostname and my working directory
|
||||
|
||||
DyMo=pwd;
|
||||
fInputVar.DyMo=DyMo;
|
||||
if isunix || (~matlab_ver_less_than('7.4') && ismac) ,
|
||||
|
@ -67,6 +70,7 @@ if isunix || (~matlab_ver_less_than('7.4') && ismac) ,
|
|||
else
|
||||
[tempo, MasterName]=system('hostname');
|
||||
end
|
||||
|
||||
MasterName=deblank(MasterName);
|
||||
fInputVar.MasterName = MasterName;
|
||||
|
||||
|
@ -131,6 +135,7 @@ for j=1:totCPU,
|
|||
end
|
||||
pause(1); % wait for possibly local alive CPU to start the new job or close by internal criteria
|
||||
newInstance = 0;
|
||||
|
||||
if isempty( dir(['P_slave_',int2str(j),'End.txt'])); % check if j CPU is already alive
|
||||
fid1=fopen(['P_slave_',int2str(j),'End.txt'],'w+');
|
||||
fclose(fid1);
|
||||
|
@ -177,8 +182,7 @@ for j=1:totCPU,
|
|||
end
|
||||
end
|
||||
if remoteFlag,
|
||||
if j==nCPU0+1,
|
||||
if newInstance, % clean remote folder
|
||||
if (j==nCPU0+1) & newInstance, % clean remote folder
|
||||
if isunix || (~matlab_ver_less_than('7.4') && ismac),
|
||||
system(['ssh ',Parallel(indPC).user,'@',Parallel(indPC).PcName,' rm -fr ',Parallel(indPC).RemoteFolder,'/*']);
|
||||
else
|
||||
|
@ -194,7 +198,7 @@ for j=1:totCPU,
|
|||
end
|
||||
|
||||
if isunix || (~matlab_ver_less_than('7.4') && ismac),
|
||||
system(['scp ',fname,'_input.mat ',Parallel(indPC).user,'@',Parallel(indPC).PcName,':',Parallel(indPC).RemoteFolder]);
|
||||
% 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})
|
||||
system(['ssh ',Parallel(indPC).user,'@',Parallel(indPC).PcName,' mkdir -p ',Parallel(indPC).RemoteFolder,'/',NamFileInput{jfil,1}])
|
||||
|
@ -206,8 +210,11 @@ for j=1:totCPU,
|
|||
system(['scp slaveParallel_input',int2str(j),'.mat ',Parallel(indPC).user,'@',Parallel(indPC).PcName,':',Parallel(indPC).RemoteFolder]);
|
||||
end
|
||||
else
|
||||
copyfile([fname,'_input.mat'], ['\\',Parallel(indPC).PcName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteFolder]);
|
||||
% copyfile([fname,'_input.mat'], ['\\',Parallel(indPC).PcName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteFolder])
|
||||
for jfil=1:size(NamFileInput,1)
|
||||
if ~isempty(NamFileInput{jfil,1})
|
||||
mkdir(['\\',Parallel(indPC).PcName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteFolder,'\',NamFileInput{jfil,1}]);
|
||||
end
|
||||
copyfile([NamFileInput{jfil,1},NamFileInput{jfil,2}],['\\',Parallel(indPC).PcName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteFolder,'\',NamFileInput{jfil,1}])
|
||||
end
|
||||
copyfile(['slaveJob',int2str(j),'.mat'], ['\\',Parallel(indPC).PcName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteFolder]);
|
||||
|
@ -216,31 +223,30 @@ for j=1:totCPU,
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if newInstance,
|
||||
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,'\''\);" &'];
|
||||
command1=['ssh ',Parallel(indPC).user,'@',Parallel(indPC).PcName,' "cd ',Parallel(indPC).RemoteFolder, '; octave --eval slaveParallel\(',int2str(j),',',int2str(indPC),'\);" &'];
|
||||
else
|
||||
command1=['ssh ',Parallel(indPC).user,'@',Parallel(indPC).PcName,' "cd ',Parallel(indPC).RemoteFolder, '; matlab -nosplash -nodesktop -minimize -r fParallel\(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',\''',fname,'\''\);" &'];
|
||||
command1=['ssh ',Parallel(indPC).user,'@',Parallel(indPC).PcName,' "cd ',Parallel(indPC).RemoteFolder, '; matlab -nosplash -nodesktop -minimize -r slaveParallel\(',int2str(j),',',int2str(indPC),'\);" &'];
|
||||
end
|
||||
else
|
||||
if ~strcmp(Parallel(indPC).PcName,MasterName), % 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,'\ -a ',int2str(Parallel(indPC).NumCPU(j-nCPU0)), ...
|
||||
' -low octave --eval fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')'];
|
||||
' -low octave --eval 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,'\ -a ',int2str(Parallel(indPC).NumCPU(j-nCPU0)), ...
|
||||
' -low matlab -nosplash -nodesktop -minimize -r fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')'];
|
||||
' -low matlab -nosplash -nodesktop -minimize -r slaveParallel(',int2str(j),',',int2str(indPC),')'];
|
||||
end
|
||||
else % 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,'\ -a ',int2str(Parallel(indPC).NumCPU(j-nCPU0)), ...
|
||||
' -low octave --eval fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')'];
|
||||
' -low octave --eval slaveParallel(',int2str(j),',',int2str(indPC),')'];
|
||||
else
|
||||
command1=['start /B psexec \\',Parallel(indPC).PcName,' -e -W ',Parallel(indPC).RemoteDrive,':\',Parallel(indPC).RemoteFolder,'\ -a ',int2str(Parallel(indPC).NumCPU(j-nCPU0)), ...
|
||||
' -low matlab -nosplash -nodesktop -minimize -r fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')'];
|
||||
' -low matlab -nosplash -nodesktop -minimize -r slaveParallel(',int2str(j),',',int2str(indPC),')'];
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -283,10 +289,13 @@ else
|
|||
end
|
||||
pcerdone = NaN(1,totCPU);
|
||||
while (1)
|
||||
|
||||
waitbarString = '';
|
||||
statusString = '';
|
||||
pause(1)
|
||||
|
||||
stax = dir(['comp_status_',fname,'*.mat']);
|
||||
|
||||
for j=1:length(stax),
|
||||
|
||||
try
|
||||
|
@ -307,17 +316,33 @@ while (1)
|
|||
if exist('OCTAVE_VERSION'),
|
||||
printf([statusString,'\r'], 100 .* pcerdone);
|
||||
else
|
||||
|
||||
figure(hfigstatus),
|
||||
for j=1:length(stax),
|
||||
try
|
||||
for j=1:length(stax)
|
||||
|
||||
axes(hstatus(idCPU(j))),
|
||||
hpat = findobj(hstatus(idCPU(j)),'Type','patch');
|
||||
|
||||
|
||||
if ~isempty(hpat),
|
||||
set(hpat,'XData',[0 0 pcerdone(j) pcerdone(j)])
|
||||
else
|
||||
patch([0 0 pcerdone(j) pcerdone(j)],[0 1 1 0],'r','EdgeColor','r')
|
||||
end
|
||||
title([status_Title{j},' - ',status_String{j}]);
|
||||
|
||||
end
|
||||
catch
|
||||
|
||||
E='ERRORE in while cycle masterParallelMann!'
|
||||
j
|
||||
if j>1
|
||||
j=j-1
|
||||
end
|
||||
j
|
||||
end
|
||||
|
||||
end
|
||||
if isempty(dir(['P_',fname,'_*End.txt']))
|
||||
mydelete(['comp_status_',fname,'*.mat'])
|
||||
|
|
Loading…
Reference in New Issue