diff --git a/doc/manual/source/running-dynare.rst b/doc/manual/source/running-dynare.rst index b7ca7d7dd7203454ae8753702b964c4428e0c5e5..59a9b924cf35c6ae6bb70dbca4202c58f5674c99 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 1a6b3883edf9e1b518b91633dad6170a9cbcf3a4..7c479dae5e183f18404c8e042f0dc911df5846ea 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 1c102ecf47860a82e3f53de5ee6b3c6ea89fe1ce..89581db984a0e549782db7d643503cf139b9cdf1 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.