Possible bug or violation of OpenMP standard

Dear all,

Please find below a minimal example that mimics a code fragment of the Eigen library

include <iostream>
#include <omp.h>

void processRow(int i)
{
  int a=i;
}

int main()
{
  int threads = 4;
  int n = 100;
#pragma omp parallel for schedule(dynamic,(n+threads*4-1)/(threads*4)) num_threads(threads)
  for(int i=0; i<n; ++i)
    processRow(i);

  return 0;
}

The PGI C++ compiler (pgc++ -mp test.cpp -o test) stops compilation with the following error message

"test.cpp", line 14: error: expected an integer constant
#pragma omp parallel for schedule(dynamic,(n+threads*4-1)/(threads*4)) num_threads(threads)

Is this a bug in PGI (same error in 20.9 and older versions) or a violation of the OpenMP standard? This code compiles well with other compilers, e.g., GCC or ICC.

Kind regards,
Matthias

Thanks Matthias. Looks like a parse error where we’re not handling the parentheses in the chunk size’s integer expression. I couldn’t find anything in the OpenMP standard that specifically states if parentheses are allowed in integer expressions, but it makes sense that they should be.

I added a problem report (TPR #29162) and sent it to engineering for further evaluation. The work around is to compute the chunk size to a local variable and then use that variable in the schedule clause.

-Mat

This has been fixed in our 21.7 release, which is just out.

1 Like