Search code examples
c++cparallel-processingopenmpsigned

Why must loop variables be signed in a parallel for?


I'm just learning OpenMP from online tutorials and resources. I want to square a matrix (multiply it with itself) using a parallel for loop. In IBM compiler documentation, I found the requirement that "the iteration variable must be a signed integer." Is this also true in the GCC implementation? Is it specified in the OpenMP standard? If so, is there a reason for this requirement?

(It doesn't matter much as the expected dimensions are far smaller than INT_MAX, but it does cost me some casts.)


Solution

  • According to OpenMP 3.0 specification: http://www.openmp.org/mp-documents/spec30.pdf, for variable may be of a signed or unsigned integer type, see 2.5.1 Loop Construct. The question is whether given OpenMP implementation matches this latest specification.