parallel efficiency problem in the loop

1 visualizzazione (ultimi 30 giorni)
Guanfeng Gao
Guanfeng Gao il 18 Mag 2015
Modificato: Edric Ellis il 19 Mag 2015
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!!!!!

Risposte (1)

Walter Roberson
Walter Roberson il 18 Mag 2015
Try the Worker Object Wrapper File Contribution
  3 Commenti
Guanfeng Gao
Guanfeng Gao il 19 Mag 2015
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 il 19 Mag 2015
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?

Accedi per commentare.

Categorie

Scopri di più su Parallel for-Loops (parfor) in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by