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.)
A loop is appropriate for explicit parallelization if: It is a DO loop, but not a DO WHILE or Fortran 95 array syntax. The values of array variables for each iteration of the loop do not depend on the values of array variables for any other iteration of the loop.
The OpenMP clause: #pragma omp parallel. creates a parallel region with a team of threads , where each thread will execute the entire block of code that the parallel region encloses.
To answer your first question about gcc
. No, it seems that gcc
easily accepts unsigned
or size_t
loop variables in something like
#pragma omp parallel for
for (size_t i = 0; i < N; ++i) {
/* do it */
}
at least mine (gcc v 4.4 on a 64bit ubuntu) doesn't complain and does the right thing.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With