Rewrite the loop like this and it should work:
int maxII = min( N*C-o, C*n);
#pragma omp parallel for schedule(dynamic, 1)
for ( int ii=i; ii<maxII; ii++ )
buf[ii] = (a[ii]-b[ii])*(a[ii]-b[ii]);
OpenMP for loops have to follow a "Canonical Loop Form" as described in the standard chapter 2.6
EDIT: "Could you please explain me what was wrong with my code?"
Well, the loop form you used isn't compliant with OpenMP's "Canonical Loop Form" which basically (I over-simply here, sorry) asks that:
- the loop index is clearly defined;
- the lower bound of the loop is given in the initialisation part;
- the test is one of the following operators:
<
, <=
, >
or >=
; and
- the increment is clear.
I simply rewrote your loop to abide to these simple rules. It was easy enough, as it is in most cases.