Code covered by the BSD License  

Highlights from
Getting Started with Parallel Computing using MATLAB

image thumbnail

Getting Started with Parallel Computing using MATLAB

by

 

28 Jan 2009 (Updated )

This is an older version of the introductory tutorial for running parallel MATLAB applications

getMyJob.m
%% This script submits a job with 3 tasks 
% This script is to show how to retrieve jobs 

%% Submitting job using default scheduler

sched = findResource();
job1 = createJob(sched,'Name', 'Job1');
createTask(job1, @sum, 1, {[1 1]}); 
createTask(job1, @sum, 1, {[2 2]});
createTask(job1, @sum, 1, {[3 3]});
submit(job1)

%%  Comment out command to wait until job is finished
% waitForState(job1, 'finished') 
display(job1) 

%% Clear job (replicate shutting down MATLAB/disconnecting from cluster)

clear job1

%% How to get the job back, do this when job is finished running

sched = findResource() ;  % find your resource

% You have several options, here are a few. 

% 1) get all jobs 

myJobs = sched.Jobs;

% 2) get all jobs sorted by state

[pending queued running finished] = findJob(sched);

% 3 You can get jobs by Name or State or by other descriptive property

job = findJob(sched,'State','finished', 'Name','Job1');

% Get output arguments.
%
% Note, this assumes we only have 1 job with that name
% but you can modify it to read from an array of jobs

results = getAllOutputArguments(job);

% destroy job when finished

destroy(job) % permanently removes job data



Contact us