I have a loop in my C++/OpenMP code that looks like this:
#pragma omp parallel for
for(unsigned int i=0; i
According to the OpenMP 2.0 C/C++ API specification (pdf), section 2.4.1, that's one of the restrictions of the for
loop. No reason is given for it, but I suspect it's just to simplify the assumptions that the code and compiler have to make, since there's special code to ensure that the range doesn't overflow the maximum value of the type.
OpenMP 3.0 apparently allows for unsigned types too, but I haven't seen it in action yet.
The Microsoft C/C++ Compiler 12.0 integrated with Visual Studio 2013 still only support OpenMP 2.5 and doesn't allow unsigned int
for the loop counter.
GCC support OpenMP 3.0 since its version 4.4 and allows unsigned int
for the loop counter.