Dear engineer friends in this community,
I'm having a issue with the parfor.
Actually, I have a pre-defined the function, which was not built with the idea of 'parfor'. So it is very hard (for me) to alter it to fit the 'parfor' principle. Let's note it as 'f()'.
But the good part is, this function f() need to be run for many times to acquire enough results of data. So previously, I open several matlab in my computer to run it 'parallel' to speed up the running time.
Like below,
%matlab 1
for iteration 1:5000 f();end%matlab 2
for iteration 5001:10000 f()end...
But it is not a wise way, since I know we have the 'parfor' function to automatically do this work for me. Then I look up the tutorial, the 'parfor' could divide the iterations to several parts, as long as each iteration are independent. (if my understanding is correct)
So I tried this:
parfor 1: 1000000 f();end
But the matlab gives me error says the it violates the classifications of the variables for 'parfor'…
I am wondering, if anyone could enlight me, when we use 'parfor', is it that I have to make sure every inner for-loop is also self-independent? Why is that???
I can manually do 'parallel', why can't 'parfor' do it??
Best Answer