flag whether or not a program has been called by createTask
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Leo Simon
el 11 de En. de 2015
Editada: Edric Ellis
el 11 de En. de 2016
I run certain jobs either as standalone jobs, or in parallel, for example called by createTask. Is there some way to distinguish between these cases? obviously I could use brute force, use dbstack and related tools and check if the calling line had the word createTask in it, but I'd much prefer to do something more general/elegant. Since one can interact with programs in the former case, but not the latter, there must be something matlab knows that I can tap into...
Thanks very much for any help!
Leo
0 comentarios
Respuesta aceptada
Edric Ellis
el 12 de En. de 2015
Editada: Edric Ellis
el 12 de En. de 2015
One simple way is to check the return of getCurrentTask. This will always return empty in a desktop MATLAB session, and a parallel.Task object when running on a worker.
3 comentarios
Edric Ellis
el 11 de En. de 2016
Editada: Edric Ellis
el 11 de En. de 2016
Hm, I don't see the warning in R2015a. What are your precise reproduction steps to get that? Here's what I did, after opening a (local) parallel pool:
>> getCurrentTask
ans =
[]
>> spmd, getCurrentTask, end
Lab 1:
ans =
Task with properties:
ID: 1
State: running
Function: @distcomp.nop
Parent: Job 7
StartTime: Mon Jan 11 12:43:28 GMT 2016
Running Duration: 0 days 0h 0m 60s
ErrorIdentifier:
ErrorMessage:
>>
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!