How can I find out the names of the workers that are running a certain job?

9 views (last 30 days)
I am using the Parallel Computing Toolbox to run a job with about fifteen tasks. I would like to determine the names of the workers on my cluster that are running on eack task.
Is there a way to find out the names of the workers?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The names of workers executing a certain job can be obtained in several ways; using either the Worker.Name property or the getCurrentWorker method.
1) If you have access to the job object created by the CREATEJOB command, the Worker.Name property can directly be accessed as follows:
submit(job1)
waitForState(job1,'finished')
task1 = findTask(job1,'ID',1)
task1.Worker.Name
If you do not directly have access to the job object, it can be obtained by querying the scheduler as follows:
sched = findResource;
[pending queued running finished] = findJob(sched);
Depending on the status of the job, it will be returned in one of the output arguments.
Once you have located your job object, you may then use FINDTASK as described previously and access its Worker.Name property.
2) If you are using commands like SPMD or PARFOR, the following code can be used to get the names of the workers:
spmd
w = getCurrentWorker();
w = w.Name
end
Note that it is not correct to send a worker object outside of a SPMD/PARFOR block because it is a handle and will not exist after execution of the SPMD/PARFOR loop. Therefore, here the variable 'w' is overwritten with the value of the Worker object's property: Name.

More Answers (0)

Products


Release

R2009a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!