List of functions that cannot be used in a parfor
I have a problem using the Parallel Toolbox from Matlab. Indeed, I want to untar a series of archive in a parfor loop, and it seems that neither untar
nor system
are working. They do not cause an error, they simply do not produce any result.
The very same code works without any problem as soon as I deactivate the parallelism.
Is there a reference that lists the functions that cannot be used in parfor
loops? I couldn't find it easily in the parallel toolbo开发者_如何学编程x documentation.
system
should work correctly inside a PARFOR loop - providing that the executable you invoke does not require user input.
>> matlabpool('size')
ans =
3
>> parfor ii=1:2, system('pwd'), end
/tmp
ans =
0
/tmp
ans =
0
The main constraints on functions which cannot be used directly inside a PARFOR loop body relate to "workspace transparency" - you cannot use functions that modify the workspace such as assignin
, load
, clear
etc. See this page for more on that. (You can of course call a function from the body of a PARFOR loop which calls load
etc.)
You can try something like this.
function parallel_stuff
parfor i = 1:10
b = my_untar(a)
end
end
function b = my_untar(a)
b = untar(a)
end
精彩评论