问题描述:

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?.

Regards

网友答案:

Not if you're using matlabpool and parfor. matlabpool explicitly reserves the use of those workers for you until you release them with matlabpool close.

If you set up your algorithm to use Jobs and 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 Jobs and Tasks once you've worked it out for the first time.

相关阅读:
Top