How does the client send data to the workes, when calling parfor?
3 次查看(过去 30 天)
显示 更早的评论
Hi, let assume I want to use the parfor with my function (in this case, it just computes the routine without retrieving data from the workers, except for the last operation), i.e.:
parfor i=1:n
err = my_fnc(A,B,exp_pts(i));
end
where my_fnc is a time-expensive routine, exp_pts is a vector of n different numbers, A and B are always the same, very large matrices. I would know how the client transfers these data to all the available workers, that's to say: does it transfer data first to the worker 1, after to the worker 2, and so on? If it does, it means that, when working with very large (and dense) data, worker 1 starts working first and it could becomes idle when worker 2 is working, and so on.. (it's like an unbalanced load). Also, with matrices of this type, it's hard for the "true" operational time to overcome the time needed for the transfer of data, then the parfor is not so useful for these data. Do you agree? Thank you in advance.
0 个评论
采纳的回答
Edric Ellis
2013-8-20
A and B are sent once to each worker at the start of the PARFOR loop. There are certainly cases where the data transfer time dominates the computational time - but if my_fnc is truly time-expensive, this should not be the case. If you have multiple PARFOR loops using the same 'A' and 'B', you could use my Worker Object Wrapper to ensure they are transferred only once.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!