Improving compiler error with OpenACC + OpenMP: "Internal compiler error. confused OMP private processing"

Hello,

This example has an error on user part but the error message could be better and hence I thought I should report it:

If we have simple example with OpenMP as well as OpenACC pragmas together (just for demonstration):

void test(){
  int N = 1e4;
  float *x = new float[N];
  float *y = new float[N];

  #pragma omp target teams distribute parallel for map(to: x[0:N]) map(from: y[0:N])
  #pragma acc parallel loop copyin(x[0:N]) copy(y[0:N])
  for(int i = 0; i < N; i++){
    for(int j = 0; j < 1000; j++){
      y[i] += 3*x[i];
    }
  }

  printf("%g\n", y[5]);

  delete [] x;
  delete [] y;
}

I can compile this with nvc++ -mp=gpu or nvc++ -acc as expected. But if I try to use both -mp=gpu -acc then we get:

NVC++-S-0000-Internal compiler error. confused OMP private processing        0  (test.cpp: 60)
nvc++-Fatal-/gpfs/bbp.cscs.ch/ssd/apps/hpc/jenkins/pulls/1334/deploy/externals/2021-10-15/linux-rhel7-x86_64/gcc-9.3.0/nvhpc-21.9-wsrbqb/Linux_x86_64/21.9/compilers/bin/tools/cpp2 TERMINATED by signal 11
Arguments to /gpfs/.../nvhpc-21.9-wsrbqb/Linux_x86_64/21.9/compilers/bin/tools/cpp2
/gpfs/.../nvhpc-21.9-wsrbqb/Linux_x86_64/21.9/compilers/bin/tools/cpp2 test.cpp -opt 2 -terse 1 -inform warn -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 17 -x 19 0x400000 -x 28 0x40000 -x 120 0x10000000 -x 70 0x8000 -x 122 1 -x 125 0x20000 -quad -x 59 4 -tp skylake -x 120 0x1000 -astype 0 -x 121 1 -fn test.cpp -il /gpfs/.../kumbhar/2790017/nvc++NsRr1NMx-Exe.il -x 117 0x200 -x 123 0x80000000 -x 123 4 -x 119 0x20 -def __pgnu_vsn=90300 -x 70 0x40000000 -x 183 4 -x 121 0x800 -x 6 0x20000 -x 249 110 -x 120 0x200000 -x 70 0x40000000 -x 8 0x40000000 -x 164 0x800000 -x 85 0x2000 -x 85 0x4000 -x 34 0x40000000 -x 53 0x800000 -x 206 0x02 -x 68 0x1 -x 39 4 -x 56 0x10 -x 26 0x10 -x 26 1 -x 56 0x4000 -accel tesla -accel tesla -accel host -x 180 0x4000400 -x 121 0xc00 -x 186 0x80 -x 163 0x1 -x 186 0x80000 -cudaver 11040 -x 194 0x40000 -x 176 0x100 -cudacap 70 -x 180 0x4000400 -x 121 0xc00 -x 186 0x80 -x 180 0x4000400 -x 121 0xc00 -x 194 0x40000 -x 163 0x1 -x 186 0x80000 -cudaver 11040 -x 176 0x100 -cudacap 70 -cudaroot /gpfs/.../nvhpc-21.9-wsrbqb/Linux_x86_64/21.9/cuda/11.4 -x 189 0x8000 -y 163 0xc0000000 -x 201 0xf0000000 -x 189 0x10 -y 189 0x4000000 -cudaroot /gpfs/.../nvhpc-21.9-wsrbqb/Linux_x86_64/21.9/cuda/11.4 -x 187 0x40000 -x 187 0x8000000 -mp -x 69 0x200 -x 69 0x400 -x 69 2 -x 0 0x1000000 -x 2 0x100000 -x 0 0x2000000 -x 161 16512 -x 162 16512 -gnuvsn 90300 -x 69 0x200 -x 123 0x400 -x 180 0x4000000 -x 194 0x20000000 -x 233 0x1 -x 205 2 -x 233 0x100 -x 233 0x400 -cmdline '+nvc++ /gpfs/.../kumbhar/2790017/nvc++NsRr1NMx-Exe.il -D__GCC_ATOMIC_TEST_AND_SET_TRUEVAL=1 -mp=gpu -acc -c -Minfo=accel,mp' -asm /gpfs/.../kumbhar/2790017/nvc++xsRrfA4ol_Tn.ll

This is with NVHPC 21.9. The error could be better here?

It’s obviously incorrect to try and use both parallel models’ compute regions on the same loop, but, yes, the compiler shouldn’t give an ICE. I added a problem report (TPR #30770) and sent to engineering for review.

Thanks!
Mat