Am I inside a parfor?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
There are certain functions I don't want to execute in parallel, and I would like to throw an error if they are. Is there anyway to know if I am inside a parfor?
Thanks Joan
0 commentaires
Réponse acceptée
Sarah Wait Zaranek
le 25 Fév 2011
You can check to see if you are currently running on a worker (aka running in parallel) by using the following commands.
parfor ii = 1:2
job = getCurrentJob;
if isempty(job)
display('not running in parallel')
else
display('running in parallel')
end
end
If you are not running in parallel, the function should return an empty. If you are running in parallel, it will return a job object corresponding to the job you are inside.
0 commentaires
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Parallel for-Loops (parfor) dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!