1). How can I find out the worker name/number that is currently running??
I tried getCurrentTask, getCurrentWorker, but I only get [ ].
2). Also, in getCurrentTask doc it says:
"If the function is executed in a MATLAB session that is not a worker, you get an empty result". How can I find out if it's executing in a worker or not?
Note:
I have 8 workers running and I am simply running my code within parfor loop(of course accounting for all the 'Limitations' in 'Programming Considerations' and other basic setup stuff.)
Any help shall be appreciated. Thanks!
Any ideas/suggestions??
> I have an 8 core machine and I am trying to set up parfor looping for
> Parallel computing.
>
> 1). How can I find out the worker name/number that is currently running?? I
> tried getCurrentTask, getCurrentWorker, but I only get [ ].
Did you try something like this:
matlabpool local 8
parfor ii = 1:8
t = getCurrentTask();
id(ii) = t.ID;
end
> 2). Also, in getCurrentTask doc it says: "If the function is executed
> in a MATLAB session that is not a worker, you get an empty
> result". How can I find out if it's executing in a worker or not?
You could simply use the fact that the return of getCurrentTask is empty
to indicate whether you're on a worker
isOnWorker = ~isempty( getCurrentTask() ) % returns false
parfor ii = 1:8
isOnWorker(ii) = ~isempty( getCurrentTask() ) % all true
end
Cheers,
Edric.
It worked!! Thanks Edric..