Unrecognized function or variable in parfor
Hi.
I am a beginner in MATLAB software and I use MATLAB online .The problem is in initializing a variable called 'estModel' in a parallel loop . I want to use parallel processing because the calculations take a long time to complete but this problem occurs when I use 'threads' in parpool instead of 'local' . In 'local' mode this problem does not exist and the code is executed correctly and the results are correct . But in the case of 'threads', the variable 'estModel' is not initialize in the parfor loop , and give this error : Unrecognized function or variable 'estModel' . In 'local' mode the number of workers are 2 but in 'threads' mode the number of workers are 8 . So I use 'threads' instead of 'local' . I do not know about parpool structure completely . Is there a problem in this part ( parpool : local or threads or ... and chooses 'threads' based on the number of workers ) ? Finally the three variables 'kh', 'model' and 'DATA' are completely initializing before parallel loop and the variable 'model' uses the arima function .
Can anyone help me to solve this problem?
part of code :
poolobj=parpool('threads');
parfor i=1:kh
estModel(i)=estimate(model(i),DATA);
end
delete(poolobj);
0 个评论
回答(1 个)
7 个评论
- On the great majority of CPUs, hyperthreading does not provide additional compute capacity. hyperthreading is more a fast-switch technology, so that as soon as a worker volunteers to give up control of a core (to wait for disk or an interrupt or for a user to respond or voluntary pause()), then the new worker gets activated quite quickly. Hyperthreading does not add any additional Arithmetic Logic Units or instruction decoders or so on.
- On some quite new CPUs, hyperthreading is able to dispatch instructions to the Integer Arithmetic Logic Unit while the main thread is busy doing floating point tasks. Using this effectively requires some very fine tuning.
- If you have more workers than you have effective available cores. then the operating system might try to schedule them "fairly" -- which might mean that it rolls a worker out and replaces it with another worker. This takes time lowers the overall efficiency compared to running one task to completion and then starting another
另请参阅
类别
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!