parallel efficiency problem in the loop

2 次查看(过去 30 天)
I have a question while using the parallel in Matlab.
parfor ii=1:100
[a]=function(x1, x2, x3,....)
end
Each loop takes approximately 1.75s. I open 4 workers. I am not satisfied with the speed.
Besides, the input of 'function' has a cell whose dimension is 62*1, and the it has totally 8187292256 bytes. I guess that maybe this large input cause a lot of time when I use the parallel! So, I make this input equal to 1(8 bytes) and replace the part with a pause function(pause(1.25)), I find that in this case the parallel efficiency is good.
So I am confused with the variables in the parallel, will each worker has one copy of the variable or all the workers have one, and they will access the same one at the same time? If so, is there any method to help to solve the problem!!!!!

回答(1 个)

Walter Roberson
Walter Roberson 2015-5-18
Try the Worker Object Wrapper File Contribution
  3 个评论
Guanfeng Gao
Guanfeng Gao 2015-5-19
I have a question. I want to use one cell variable in parfor loop and call the C code by mex file. It shows an error!!!! I know that the type of the Worker Object Wrapper output is already cell, so that the mex file could not work!!! Is there some simple way to solve that problem!!!
Walter Roberson
Walter Roberson 2015-5-19
What error are you receiving?
To confirm, you are attempting to pass a cell array into a mex file?
As you are already using C code, have you considered the possibility of having your C code be the place that runs the parallel code, perhaps using standard threading libraries?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by