MATLAB PARALLEL COMPUTING TOOLBOX - S Podręcznik Użytkownika Strona 166

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
Przeglądanie stron 165
6 Programming Overview
6-26
disp(['Finished task: ' num2str(task.ID)])
Create a job and set its QueuedFcn, RunningFcn, and FinishedFcn properties, using a
function handle to an anonymous function that sends information to the display.
c = parcluster('MyMJS');
j = createJob(c,'Name','Job_52a');
j.QueuedFcn = @(job,eventdata) disp([job.Name ' now ' job.State]);
j.RunningFcn = @(job,eventdata) disp([job.Name ' now ' job.State]);
j.FinishedFcn = @(job,eventdata) disp([job.Name ' now ' job.State]);
Create a task whose FinishedFcn is a function handle to the separate function.
createTask(j,@rand,1,{2,4}, ...
'FinishedFcn',@clientTaskCompleted);
Run the job and note the output messages from both the job and task callbacks.
submit(j)
Job_52a now queued
Job_52a now running
Finished task: 1
Job_52a now finished
To use the same callbacks for any jobs and tasks on a given cluster, you should set these
properties in the cluster profile. For details on editing profiles in the profile manager, see
“Clusters and Cluster Profiles” on page 6-14. These property settings apply to any jobs
and tasks created using a cluster derived from this profile. The sequence is important,
and must occur in this order:
1
Set the callback property values for the profile in the profile manager.
2
Use the cluster profile to create a cluster object in MATLAB.
3
Use the cluster object to create jobs and then tasks.
Set Callbacks in a Cluster Profile
This example shows how to set several job and task callback properties using the profile
manager.
Edit your MJS cluster profile in the profile manager so that you can set the callback
properties to the same values in the previous example. The saves profile looks like this:
Przeglądanie stron 165
1 2 ... 161 162 163 164 165 166 167 168 169 170 171 ... 655 656

Komentarze do niniejszej Instrukcji

Brak uwag