Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titlesubmitParJobToCluster.m
function job = submitParJobToCluster()

if nargin==0, sz = 3; end

% Set the walltime to 5 minutes
ClusterInfo.setWallTime('00:05:00');                  % change this to the actual walltime that you need.
ClusterInfo.setEmailAddress('YourEmailAddressHere')   % include your email address here.
ClusterInfo.setUserDefinedOptions('-W x=NACCESSPOLICY:SINGLEJOB')   % restrict access to the compute node to your job only.  Node will not be shared.

job = batch(@frontDemo,2,{},'Matlabpool',sz,'CaptureDiary', true);   % this submits the frontDemo.m job.
           % @frontDemo is the function to submit.
           % 2 is the number of output arguments
           % {} is an empty array of input arguments
           % sz is the number of processor cores (workers)
           % CaptureDiary is set to true
job.wait                                                             % the MATLAB GUI will pause here until the job finishes
try
   error(job.Task.ErrorMessage)
   out = job.getAllOutputArguments();                                % get all output arguments from the completed job
   r = out{1}; v = out{2};
   plot(r,v)                                                         % plot the results
   job.diary
catch ME
   error(ME.message)
end

if nargout==0
   job.destroy
   clear job
end

...

Code Block
titlesubmitSpmdJobToCluster.m
function job = submitSpmdJobToCluster(sz)

if nargin==0, sz = 3; end

% Set the walltime to 5 minutes
ClusterInfo.setWallTime('00:05:00');                  % change this to the actual walltime that you need.
ClusterInfo.setEmailAddress('YourEmailAddressHere')   % include your email address here.
ClusterInfo.setUserDefinedOptions('-W x=NACCESSPOLICY:SINGLEJOB')   % restrict access to the compute node to your job only.  Node will not be shared.

job = batch(@calcPiSpmd,1,{sz},'Matlabpool',sz);      % this will submit the calicPiSpmd function
           % @calcPiSpmd is the function to submit.
           % 1 is the number of output arguments
           % {sz} is an array of input arguments
           % sz is the number of processor cores (workers)

job.wait                                              % the MATLAB GUI will pause here until the job finishes
try
    error(job.Task.ErrorMessage)
    out = job.getAllOutputArguments();                % get all output arguments from the completed job
    p = out{1}
catch ME
    error(ME.message)
end

if nargout==0
   job.destroy
   clear job
end

...