parallel efficiency problem in the loop

조회 수: 1 (최근 30일)
Guanfeng Gao
Guanfeng Gao 2015년 5월 18일
편집: Edric Ellis 2015년 5월 19일
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