From 34bdacfdaabae6d32fc88650f696c922a75c7a49 Mon Sep 17 00:00:00 2001 From: Marco Ratto <marco.ratto@ec.europa.eu> Date: Sat, 1 May 2021 23:47:13 +0200 Subject: [PATCH] For local clusters only, allow using start instead of psexec with windows, to properly allocate affinity when there are more than 32 cores. Manual updated accordingly. --- doc/manual/source/running-dynare.rst | 7 +++++++ matlab/default_option_values.m | 1 + matlab/parallel/masterParallel.m | 30 ++++++++++++++++++++++++---- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/doc/manual/source/running-dynare.rst b/doc/manual/source/running-dynare.rst index b7ca7d7dd7..59a9b924cf 100644 --- a/doc/manual/source/running-dynare.rst +++ b/doc/manual/source/running-dynare.rst @@ -357,6 +357,13 @@ by the ``dynare`` command. without executing the ``.mod`` file. See :ref:`conf-file`, for more information about the configuration file. + .. option:: parallel_use_psexec=INTEGER + + For local execution under Windows operating system, + set ``parallel_use_psexec=0`` to use ``start`` + instead of ``psexec``, to properly allocate affinity when there are + more than 32 cores in the local machine. [default=1] + .. option:: -DMACRO_VARIABLE=MACRO_EXPRESSION Defines a macro-variable from the command line (the same effect as diff --git a/matlab/default_option_values.m b/matlab/default_option_values.m index 1a6b3883ed..7c479dae5e 100644 --- a/matlab/default_option_values.m +++ b/matlab/default_option_values.m @@ -465,6 +465,7 @@ options_.parallel = 0; options_.parallel_info.isHybridMatlabOctave = false; options_.parallel_info.leaveSlaveOpen = 0; options_.parallel_info.RemoteTmpFolder = ''; +options_.parallel_info.use_psexec = true; options_.number_of_grid_points_for_kde = 2^9; quarter = 1; years = [1 2 3 4 5 10 20 30 40 50]; diff --git a/matlab/parallel/masterParallel.m b/matlab/parallel/masterParallel.m index 1c102ecf47..89581db984 100644 --- a/matlab/parallel/masterParallel.m +++ b/matlab/parallel/masterParallel.m @@ -353,10 +353,21 @@ if parallel_recover ==0 command1=[Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')" &']; end else % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa! + if Parallel_info.use_psexec + token1 = ['psexec -accepteula -d -W "',DyMo, '" -a ',my_affinity,' -low ']; + else + itmp = intmin('uint64'); + cpus = eval([ '[' my_affinity ']' ])+1; + for icpu=1:length(cpus) + itmp = bitset(itmp,cpus(icpu)); + end + hex_affinity = dec2hex(itmp); + token1 = ['start /B /D "',DyMo, '" /affinity ',hex_affinity,' /LOW ']; + end if regexpi([Parallel(indPC).MatlabOctavePath], 'octave') - command1=['psexec -accepteula -d -W "',DyMo, '" -a ',my_affinity,' -low ',Parallel(indPC).MatlabOctavePath,' -f --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=[token1,Parallel(indPC).MatlabOctavePath,' -f --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 - command1=['psexec -accepteula -d -W "',DyMo, '" -a ',my_affinity,' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"']; + command1=[token1,Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); fParallel(',int2str(offset+1),',',int2str(sum(nBlockPerCPU(1:j))),',',int2str(j),',',int2str(indPC),',''',fname,''')"']; end end else % 0.2 Parallel(indPC).Local==0: Run using network on remote machine or also on local machine. @@ -424,10 +435,21 @@ if parallel_recover ==0 command1=[Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')" &']; end else % Hybrid computing Matlab(Master)->Octave(Slaves) and Vice Versa! + if Parallel_info.use_psexec + token1 = ['psexec -accepteula -d -W "',DyMo, '" -a ',my_affinity,' -low ']; + else + itmp = intmin('uint64'); + cpus = eval([ '[' my_affinity ']' ])+1; + for icpu=1:length(cpus) + itmp = bitset(itmp,cpus(icpu)); + end + hex_affinity = dec2hex(itmp); + token1 = ['start /B /D "',DyMo, '" /affinity ',hex_affinity,' /LOW ']; + end if regexpi([Parallel(indPC).MatlabOctavePath], 'octave') - command1=['psexec -accepteula -d -W "',DyMo, '" -a ',my_affinity,' -low ',Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7'');addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"']; + command1=[token1,Parallel(indPC).MatlabOctavePath,' -f --eval "default_save_options(''-v7'');addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"']; else - command1=['psexec -accepteula -d -W "',DyMo, '" -a ',my_affinity,' -low ',Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"']; + command1=[token1,Parallel(indPC).MatlabOctavePath,' -nosplash -nodesktop -minimize ',compThread,' -r "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')"']; end end elseif Parallel(indPC).Local==0 % 1.2 Run using network on remote machine or also on local machine. -- GitLab