|
I guess that's because the condition "i<k" has to be evaluated after each loop, and C/C++ allows changes to k during the loop.
Other languages (like MATLAB) would run through that loop for k_0-times, with k_0 being the value of k when entering the loop. Changes to k will be ignored. In this case its possible to parallize that loop (called "parfor" in MATLAB):
parfor i=0:k-1
...
end
But in C/C++ you have to check the expression each time, therefore it's just not possible to parallize that loop, because you do NOT know in advance how many times you have to run through that loop if k is a non-constant variable.
Maybe you should try a "const int k" to see if that gets parallized.
|