Skip to content

Commit 95d98e9

Browse files
authored
Merge pull request #10 from mathworks/v2.3.0
v2.3.0
2 parents 1aca5d5 + e284c6e commit 95d98e9

File tree

5 files changed

+54
-13
lines changed

5 files changed

+54
-13
lines changed

communicatingJobWrapper.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# The following environment variables are set by Slurm:
2020
# SLURM_NODELIST - list of hostnames allocated to this Slurm job
2121

22-
# Copyright 2015-2024 The MathWorks, Inc.
22+
# Copyright 2015-2025 The MathWorks, Inc.
2323

2424
# If PARALLEL_SERVER_ environment variables are not set, assign any
2525
# available values with form MDCE_ for backwards compatibility
@@ -47,10 +47,17 @@ if [ ! -z "${PARALLEL_SERVER_DEBUG}" ] && [ "${PARALLEL_SERVER_DEBUG}" != "false
4747
MPI_VERBOSE="${MPI_VERBOSE} -v -print-all-exitcodes"
4848
fi
4949

50+
if [ ! -z "${PARALLEL_SERVER_BIND_TO_CORE}" ] && [ "${PARALLEL_SERVER_BIND_TO_CORE}" != "false" ] ; then
51+
BIND_TO_CORE_ARG="-bind-to core:${PARALLEL_SERVER_NUM_THREADS}"
52+
else
53+
BIND_TO_CORE_ARG=""
54+
fi
55+
5056
# Construct the command to run.
5157
CMD="\"${FULL_MPIEXEC}\" \
58+
${PARALLEL_SERVER_MPIEXEC_ARG} \
5259
-genvlist ${PARALLEL_SERVER_GENVLIST} \
53-
-bind-to core:${PARALLEL_SERVER_NUM_THREADS} \
60+
${BIND_TO_CORE_ARG} \
5461
${MPI_VERBOSE} \
5562
-n ${PARALLEL_SERVER_TOTAL_TASKS} \
5663
\"${PARALLEL_SERVER_MATLAB_EXE}\" \

communicatingSubmitFcn.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,25 @@ function communicatingSubmitFcn(cluster, job, environmentProperties)
9393
'PARALLEL_SERVER_CMR', strip(cluster.ClusterMatlabRoot, 'right', '/'); ...
9494
'PARALLEL_SERVER_TOTAL_TASKS', num2str(environmentProperties.NumberOfTasks); ...
9595
'PARALLEL_SERVER_NUM_THREADS', num2str(cluster.NumThreads)};
96+
% Starting in R2025a, IntelMPI is supported via MPIImplementation="IntelMPI"
97+
if ~verLessThan('matlab', '25.1') && ...
98+
isprop(cluster.AdditionalProperties, 'MPIImplementation') %#ok<VERLESSMATLAB>
99+
mpiImplementation = cluster.AdditionalProperties.MPIImplementation;
100+
mustBeMember(mpiImplementation, ["IntelMPI", "MPICH"]);
101+
variables = [variables; {'PARALLEL_SERVER_MPIEXEC_ARG', ['-', char(mpiImplementation)]}];
102+
end
103+
104+
% Avoid "-bind-to core:N" if AdditionalProperties.UseBindToCore is false (default: true).
105+
if validatedPropValue(cluster.AdditionalProperties, 'UseBindToCore', 'logical', true)
106+
bindToCoreValue = 'true';
107+
else
108+
bindToCoreValue = 'false';
109+
end
110+
variables = [variables; {'PARALLEL_SERVER_BIND_TO_CORE', bindToCoreValue}];
111+
112+
if ~verLessThan('matlab', '25.1') %#ok<VERLESSMATLAB>
113+
variables = [variables; environmentProperties.JobEnvironment];
114+
end
96115
% Environment variable names different prior to 19b
97116
if verLessThan('matlab', '9.7')
98117
variables(:,1) = replace(variables(:,1), 'PARALLEL_SERVER_', 'MDCE_');
@@ -118,6 +137,11 @@ function communicatingSubmitFcn(cluster, job, environmentProperties)
118137
% Prior to R2019a, only the SMPD process manager is supported.
119138
if verLessThan('matlab', '9.6') || ...
120139
validatedPropValue(cluster.AdditionalProperties, 'UseSmpd', 'logical', false)
140+
if ~verLessThan('matlab', '25.1') %#ok<VERLESSMATLAB>
141+
% Starting in R2025a, smpd launcher is not supported.
142+
error('parallelexamples:GenericSLURM:SmpdNoLongerSupported', ...
143+
'The smpd process manager is no longer supported.');
144+
end
121145
jobWrapperName = 'communicatingJobWrapperSmpd.sh';
122146
else
123147
jobWrapperName = 'communicatingJobWrapper.sh';

independentSubmitFcn.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function independentSubmitFcn(cluster, job, environmentProperties)
66
%
77
% See also parallel.cluster.generic.independentDecodeFcn.
88

9-
% Copyright 2010-2023 The MathWorks, Inc.
9+
% Copyright 2010-2024 The MathWorks, Inc.
1010

1111
% Store the current filename for the errors, warnings and dctSchedulerMessages.
1212
currFilename = mfilename;
@@ -97,6 +97,9 @@ function independentSubmitFcn(cluster, job, environmentProperties)
9797
'MLM_WEB_ID', environmentProperties.LicenseWebID; ...
9898
'PARALLEL_SERVER_LICENSE_NUMBER', environmentProperties.LicenseNumber; ...
9999
'PARALLEL_SERVER_STORAGE_LOCATION', storageLocation};
100+
if ~verLessThan('matlab', '25.1') %#ok<VERLESSMATLAB>
101+
variables = [variables; environmentProperties.JobEnvironment];
102+
end
100103
% Environment variable names different prior to 19b
101104
if verLessThan('matlab', '9.7')
102105
variables(:,1) = replace(variables(:,1), 'PARALLEL_SERVER_', 'MDCE_');

private/createSubmitScript.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ function createSubmitScript(outputFilename, jobName, quotedLogFile, ...
2121
% Specify shell to use
2222
fprintf(fid, '#!/bin/sh\n');
2323

24-
% Unset all SLURM_ and SBATCH_ variables to avoid conflicting options in nested jobs
24+
% Unset all SLURM_ and SBATCH_ variables to avoid conflicting options in
25+
% nested jobs, except for SLURM_CONF which is required for the Slurm
26+
% utilities to work
2527
fprintf(fid, '%s\n', ...
26-
'for VAR_NAME in $(env | cut -d= -f1 | grep -E ''^(SLURM_|SBATCH_)''); do', ...
28+
'for VAR_NAME in $(env | cut -d= -f1 | grep -E ''^(SLURM_|SBATCH_)'' | grep -v ''^SLURM_CONF$''); do', ...
2729
' unset "$VAR_NAME"', ...
2830
'done');
2931

private/runSchedulerCommand.m

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function [status, result] = runSchedulerCommand(cluster, cmd)
22
%RUNSCHEDULERCOMMAND Run a command on the cluster.
33

4-
% Copyright 2019-2022 The MathWorks, Inc.
4+
% Copyright 2019-2024 The MathWorks, Inc.
55

66
persistent wrapper
77

@@ -17,17 +17,22 @@
1717
% the system call to the scheduler on UNIX within a shell script to
1818
% sanitize any exit codes in this range.
1919
if isempty(wrapper)
20-
if verLessThan('matlab', '9.7') % folder renamed in 19b
21-
dirName = 'distcomp';
22-
else
23-
dirName = 'parallel';
24-
end
25-
wrapper = fullfile(toolboxdir(dirName), ...
26-
'bin', 'util', 'shellWrapper.sh'); %#ok<*DCRENAME>
20+
wrapper = iBuildWrapperPath();
2721
end
2822
cmd = sprintf('%s %s', wrapper, cmd);
2923
end
3024
[status, result] = system(cmd);
3125
end
3226

3327
end
28+
29+
function wrapper = iBuildWrapperPath()
30+
if verLessThan('matlab', '9.7')
31+
pctDir = toolboxdir('distcomp'); %#ok<*DCRENAME>
32+
elseif verLessThan('matlab', '25.1') %#ok<*VERLESSMATLAB>
33+
pctDir = toolboxdir('parallel');
34+
else
35+
pctDir = fullfile(matlabroot, 'toolbox', 'parallel');
36+
end
37+
wrapper = fullfile(pctDir, 'bin', 'util', 'shellWrapper.sh');
38+
end

0 commit comments

Comments
 (0)