In a parfor loop of Matlab when workers finish their execution they stays active (0 CPU usage) until the rest of workers complete their computing since the
matlabpool close command is outside the
parfor loop. Could I control worker execution individually and free workers dynamically as they finish?.
Not if you're using
matlabpool explicitly reserves the use of those workers for you until you release them with
If you set up your algorithm to use
Tasks, they will be freed up dynamically when they've finished their allotted tasks. Although
parfor is typically as easy as it gets to implement simple parallelisation, for many algorithms it's not really much harder to implement it using
Tasks once you've worked it out for the first time.