Skip to content

Commit 161b94c

Browse files
authored
Merge pull request #5 from mathworks/v2.2.1
v2.2.1
2 parents 5b8bea9 + 33fee01 commit 161b94c

9 files changed

+59
-30
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ By modifying the plugins, you can add support for your own custom `AdditionalPro
139139
To manage work on the cluster, MATLAB calls the Grid Engine command line utilities.
140140
For example, the `qsub` command to submit work and `qstat` to query the state of submitted jobs.
141141
If your MATLAB session is running on a machine with the scheduler utilities available, the plugin scripts can call the utilities on the command line.
142-
Scheduler utilties are typically available if your MATLAB session is running on the Grid Engine cluster to which you want to submit.
142+
Scheduler utilities are typically available if your MATLAB session is running on the Grid Engine cluster to which you want to submit.
143143

144144
If MATLAB cannot directly access the scheduler utilities on the command line, the plugin scripts create an SSH session to the cluster and run scheduler commands over that connection.
145145
To configure your cluster to submit scheduler commands via SSH, set the `ClusterHost` field of `AdditionalProperties` to the name of the cluster node to which MATLAB connects via SSH.

communicatingJobWrapper.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# The following environment variables are set by Grid Engine:
1919
# PE_HOSTFILE - list of hostnames with their associated number of processors allocated to this Grid Engine job
2020

21-
# Copyright 2006-2023 The MathWorks, Inc.
21+
# Copyright 2006-2024 The MathWorks, Inc.
2222

2323
# If PARALLEL_SERVER_ environment variables are not set, assign any
2424
# available values with form MDCE_ for backwards compatibility
@@ -28,6 +28,9 @@ PARALLEL_SERVER_MATLAB_ARGS=${PARALLEL_SERVER_MATLAB_ARGS:="${MDCE_MATLAB_ARGS}"
2828
PARALLEL_SERVER_NUM_THREADS=${PARALLEL_SERVER_NUM_THREADS:="${MDCE_NUM_THREADS}"}
2929
PARALLEL_SERVER_DEBUG=${PARALLEL_SERVER_DEBUG:="${MDCE_DEBUG}"}
3030

31+
# Other environment variables to forward
32+
PARALLEL_SERVER_GENVLIST="${PARALLEL_SERVER_GENVLIST},HOME,USER"
33+
3134
# Echo the resources that the scheduler has allocated to this job:
3235
echo -e "The scheduler has allocated the following resources to this job (format is [hostname] [number of parallel processes to run on host] [queue name] [processor range]):\n$(cat ${PE_HOSTFILE:?"Host file undefined"})"
3336

@@ -42,12 +45,13 @@ if [ ! -z "${PARALLEL_SERVER_DEBUG}" ] && [ "${PARALLEL_SERVER_DEBUG}" != "false
4245
MPI_VERBOSE="${MPI_VERBOSE} -v -print-all-exitcodes"
4346
fi
4447

45-
# Unset the hostname variables to ensure they don't get forwarded by mpiexec
46-
unset HOST HOSTNAME
47-
4848
# Construct the command to run.
49-
CMD="\"${FULL_MPIEXEC}\" -bind-to core:${PARALLEL_SERVER_NUM_THREADS} ${MPI_VERBOSE} \
50-
\"${PARALLEL_SERVER_MATLAB_EXE}\" ${PARALLEL_SERVER_MATLAB_ARGS}"
49+
CMD="\"${FULL_MPIEXEC}\" \
50+
-genvlist ${PARALLEL_SERVER_GENVLIST} \
51+
-bind-to core:${PARALLEL_SERVER_NUM_THREADS} \
52+
${MPI_VERBOSE} \
53+
\"${PARALLEL_SERVER_MATLAB_EXE}\" \
54+
${PARALLEL_SERVER_MATLAB_ARGS}"
5155

5256
# Echo the command so that it is shown in the output log.
5357
echo $CMD

communicatingJobWrapperSmpd.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ PARALLEL_SERVER_CMR=${PARALLEL_SERVER_CMR:="${MDCE_CMR}"}
2424
PARALLEL_SERVER_MATLAB_EXE=${PARALLEL_SERVER_MATLAB_EXE:="${MDCE_MATLAB_EXE}"}
2525
PARALLEL_SERVER_MATLAB_ARGS=${PARALLEL_SERVER_MATLAB_ARGS:="${MDCE_MATLAB_ARGS}"}
2626

27+
# Other environment variables to forward
28+
PARALLEL_SERVER_GENVLIST="${PARALLEL_SERVER_GENVLIST},HOME,USER"
29+
2730
# Create full paths to mw_smpd/mw_mpiexec if needed
2831
FULL_SMPD=${PARALLEL_SERVER_CMR:+${PARALLEL_SERVER_CMR}/bin/}mw_smpd
2932
FULL_MPIEXEC=${PARALLEL_SERVER_CMR:+${PARALLEL_SERVER_CMR}/bin/}mw_mpiexec
@@ -102,11 +105,13 @@ launchSmpds() {
102105

103106
runMpiexec() {
104107

105-
ENVS_TO_FORWARD="PARALLEL_SERVER_DECODE_FUNCTION,PARALLEL_SERVER_STORAGE_LOCATION,PARALLEL_SERVER_STORAGE_CONSTRUCTOR,PARALLEL_SERVER_JOB_LOCATION,PARALLEL_SERVER_DEBUG,PARALLEL_SERVER_LICENSE_NUMBER,MLM_WEB_LICENSE,MLM_WEB_USER_CRED,MLM_WEB_ID"
106-
LEGACY_ENVS_TO_FORWARD="MDCE_DECODE_FUNCTION,MDCE_STORAGE_LOCATION,MDCE_STORAGE_CONSTRUCTOR,MDCE_JOB_LOCATION,MDCE_DEBUG,MDCE_LICENSE_NUMBER"
107-
CMD="\"${FULL_MPIEXEC}\" -smpd -phrase MATLAB -port ${SMPD_PORT} \
108-
-l ${MACHINE_ARG} -genvlist $ENVS_TO_FORWARD,$LEGACY_ENVS_TO_FORWARD \
109-
\"${PARALLEL_SERVER_MATLAB_EXE}\" ${PARALLEL_SERVER_MATLAB_ARGS}"
108+
CMD="\"${FULL_MPIEXEC}\" -smpd \
109+
-phrase MATLAB \
110+
-port ${SMPD_PORT} \
111+
-l ${MACHINE_ARG} \
112+
-genvlist $PARALLEL_SERVER_GENVLIST \
113+
\"${PARALLEL_SERVER_MATLAB_EXE}\" \
114+
${PARALLEL_SERVER_MATLAB_ARGS}"
110115

111116
# As a debug stage: echo the command line...
112117
echo $CMD

communicatingSubmitFcn.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function communicatingSubmitFcn(cluster, job, environmentProperties)
66
%
77
% See also parallel.cluster.generic.communicatingDecodeFcn.
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;
@@ -78,7 +78,8 @@ function communicatingSubmitFcn(cluster, job, environmentProperties)
7878
storageLocation = [storageLocation, fileSeparator];
7979
end
8080
end
81-
variables = {'PARALLEL_SERVER_DECODE_FUNCTION', decodeFunction; ...
81+
variables = { ...
82+
'PARALLEL_SERVER_DECODE_FUNCTION', decodeFunction; ...
8283
'PARALLEL_SERVER_STORAGE_CONSTRUCTOR', environmentProperties.StorageConstructor; ...
8384
'PARALLEL_SERVER_JOB_LOCATION', environmentProperties.JobLocation; ...
8485
'PARALLEL_SERVER_MATLAB_EXE', environmentProperties.MatlabExecutable; ...
@@ -99,6 +100,9 @@ function communicatingSubmitFcn(cluster, job, environmentProperties)
99100
% Trim the environment variables of empty values.
100101
nonEmptyValues = cellfun(@(x) ~isempty(strtrim(x)), variables(:,2));
101102
variables = variables(nonEmptyValues, :);
103+
% List of all the variables to forward through mpiexec to the workers
104+
variables = [variables; ...
105+
{'PARALLEL_SERVER_GENVLIST', strjoin(variables(:,1), ',')}];
102106

103107
% The job directory as accessed by this machine
104108
localJobDirectory = cluster.getJobFolder(job);

getJobStateFcn.m

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
% Set your cluster's PluginScriptsLocation to the parent folder of this
55
% function to run it when you query the state of a job.
66

7-
% Copyright 2010-2022 The MathWorks, Inc.
7+
% Copyright 2010-2024 The MathWorks, Inc.
88

99
% Store the current filename for the errors, warnings and
1010
% dctSchedulerMessages
@@ -62,18 +62,20 @@
6262
clusterState = iExtractJobState(cmdOut, schedulerIDs);
6363
dctSchedulerMessage(6, '%s: State %s was extracted from cluster output.', currFilename, clusterState);
6464

65-
% If we could determine the cluster's state, we'll use that, otherwise
66-
% stick with MATLAB's job state.
65+
% If we could determine the cluster's state, we'll use that. Otherwise, we assume
66+
% the scheduler is no longer tracking the job because the job has terminated.
6767
if ~strcmp(clusterState, 'unknown')
6868
state = clusterState;
69+
else
70+
state = 'finished';
6971
end
7072

7173
if ~cluster.HasSharedFilesystem
72-
% Decide what to do with mirroring based on the cluster's version of job state and whether or not
73-
% the job is currently being mirrored:
74+
% Decide what to do with mirroring based on the cluster's version of job
75+
% state and whether or not the job is currently being mirrored:
7476
% If job is not being mirrored, and job is not finished, resume the mirror
7577
% If job is not being mirrored, and job is finished, do the last mirror
76-
% If the job is being mirrored, and job is finished, do the last mirror.
78+
% If the job is being mirrored, and job is finished, do the last mirror
7779
% Otherwise (if job is not finished, and we are mirroring), do nothing
7880
remoteConnection = getRemoteConnection(cluster);
7981
isBeingMirrored = remoteConnection.isJobUsingConnection(job.ID);

independentJobWrapper.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# PARALLEL_SERVER_MATLAB_EXE - the MATLAB executable to use
66
# PARALLEL_SERVER_MATLAB_ARGS - the MATLAB args to use
77

8-
# Copyright 2010-2022 The MathWorks, Inc.
8+
# Copyright 2010-2024 The MathWorks, Inc.
99

1010
# If PARALLEL_SERVER_ environment variables are not set, assign any
1111
# available values with form MDCE_ for backwards compatibility

independentSubmitFcn.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ function independentSubmitFcn(cluster, job, environmentProperties)
8585
storageLocation = [storageLocation, fileSeparator];
8686
end
8787
end
88-
variables = {'PARALLEL_SERVER_DECODE_FUNCTION', decodeFunction; ...
88+
variables = { ...
89+
'PARALLEL_SERVER_DECODE_FUNCTION', decodeFunction; ...
8990
'PARALLEL_SERVER_STORAGE_CONSTRUCTOR', environmentProperties.StorageConstructor; ...
9091
'PARALLEL_SERVER_JOB_LOCATION', environmentProperties.JobLocation; ...
9192
'PARALLEL_SERVER_MATLAB_EXE', environmentProperties.MatlabExecutable; ...

private/createSubmitScript.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ function createSubmitScript(outputFilename, jobName, quotedLogFile, ...
22
quotedWrapperPath, additionalSubmitArgs, jobArrayString)
33
% Create a script that runs the Grid Engine qsub command.
44

5-
% Copyright 2010-2023 The MathWorks, Inc.
5+
% Copyright 2010-2024 The MathWorks, Inc.
66

77
if nargin < 6
88
jobArrayString = [];

private/getRemoteConnection.m

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
% getRemoteConnection will either retrieve a RemoteClusterAccess from the
55
% cluster's UserData or it will create a new RemoteClusterAccess.
66

7-
% Copyright 2010-2023 The MathWorks, Inc.
7+
% Copyright 2010-2024 The MathWorks, Inc.
88

99
% Store the current filename for the dctSchedulerMessages
1010
currFilename = mfilename;
@@ -70,7 +70,7 @@
7070
~strcmpi(remoteConnection.Hostname, clusterHost)
7171
% The connection stored in the user data does not match the cluster host requested
7272
warning('parallelexamples:GenericGridEngine:DifferentRemoteParameters', ...
73-
['The current cluster is already using cluster host.\n', ...
73+
['The current cluster is already using cluster host %s.\n', ...
7474
'The existing connection to %s will be replaced.'], ...
7575
remoteConnection.Hostname, remoteConnection.Hostname);
7676
cluster.UserData.RemoteConnection = [];
@@ -123,7 +123,7 @@
123123
% (true/false).
124124

125125
% Use the UI for prompts if MATLAB has been started with the desktop enabled
126-
useUI = desktop('-inuse');
126+
useUI = iShouldUseUI();
127127
username = iGetUsername(cluster, useUI);
128128

129129
% Decide which authentication mode to use
@@ -192,6 +192,17 @@
192192

193193
end
194194

195+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
196+
function useUI = iShouldUseUI()
197+
if verLessThan('matlab', '9.11')
198+
% Prior to R2021b, check for Java AWT components
199+
useUI = isempty(javachk('awt'));
200+
else
201+
% From R2021b onwards, can use the desktop function
202+
useUI = desktop('-inuse');
203+
end
204+
end
205+
195206
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
196207
function username = iGetUsername(cluster, useUI)
197208

@@ -217,7 +228,8 @@
217228
end
218229

219230
% useUI == false
220-
username = input(sprintf('Enter the username for %s:\n', cluster.AdditionalProperties.ClusterHost), 's');
231+
msg = sprintf('Enter the username for %s:\n ', cluster.AdditionalProperties.ClusterHost);
232+
username = input(msg, 's');
221233

222234
end
223235

@@ -244,7 +256,7 @@
244256

245257
% useUI == false
246258
validYesNoResponse = {'y', 'n'};
247-
passphraseMessage = 'Does the identity file require a password? (y or n)\n';
259+
passphraseMessage = sprintf('Does the identity file require a password? (y or n)\n ');
248260
passphraseResponse = iLoopUntilValidStringInput(passphraseMessage, validYesNoResponse);
249261
identityFileHasPassphrase = strcmpi(passphraseResponse, 'y');
250262

@@ -269,7 +281,8 @@
269281
end
270282
identityFile = fullfile(pathname, filename);
271283
else
272-
identityFile = input(sprintf('Please enter the full path to the Identity File to use:\n'), 's');
284+
msg = sprintf('Please enter the full path to the Identity File to use:\n ');
285+
identityFile = input(msg, 's');
273286
end
274287
end
275288

@@ -293,7 +306,7 @@
293306
else
294307
validResponses = {'1', '2', '3'};
295308
displayItems = [validResponses; options];
296-
identityFileMessage = [promptMessage, newline, sprintf('%s) %s\n', displayItems{:})];
309+
identityFileMessage = [promptMessage, newline, sprintf('%s) %s\n', displayItems{:}), ' '];
297310
response = iLoopUntilValidStringInput(identityFileMessage, validResponses);
298311
switch response
299312
case '1'

0 commit comments

Comments
 (0)