Compiling errors with OpenMP and switch statements with pgCC

When the code has an OpenMP region inside a switch/case statement that uses the OpenMP collapse functionality, pgCC fails with signal 11. For example, the following code demonstrates this

// test switch and threading
#include <stdlib.h>     // new, delete
#include <stdio.h>      // printf()
#include <omp.h>        // threading

int main(int argc, char **argv)
{

  int n = 10, i, j, k, l;
  double test[10][10][10], sol[10][10][10], ans, result;

  for (i=0; i<n; i++)
    for (j=0; j<n; j++)
      for (k=0; k<n; k++)
        test[i][j][k] = (double) i*j*k;

  ans = 0.0;
  for (i=0; i<n; i++)
    for (j=0; j<n; j++)
      for (k=0; k<n; k++)
        ans += (double) i*j*k;

  for (l=0; l<3; l++) {

    switch(l) {

      case 0:
      
        #pragma omp parallel for default(shared) private(i,j,k) collapse(3)
        for (i=0; i<n; i++)
          for (j=0; j<n; j++)
             for (k=0; k<n; k++)
                sol[i][j][k] = 3.0*test[i][j][k];

        break;

      case 1:
      
        #pragma omp parallel for default(shared) private(i,j,k) collapse(3)
        for (i=0; i<n; i++)
          for (j=0; j<n; j++)
             for (k=0; k<n; k++)
                sol[i][j][k] = 5.0*test[i][j][k];

        break;
 
 
      default:
        printf("doing nothing ... \n");
        break;
    }

    result = 0.0;
    #pragma omp parallel for default(shared) private(i,j,k) reduction(+:result) collapse(3)
    for (i=0; i<n; i++)
      for (j=0; j<n; j++)
         for (k=0; k<n; k++)
            result += sol[i][j][k];

    printf("result = %g \t ans = %g \n", result, ans);
  }

}

Compiling with ‘pgCC -mp’, produces the following

pgc++-Fatal-/grid/software/pgi-13.2/linux86-64/13.2/bin/pggpp2 TERMINATED by signal 11
Arguments to /grid/software/pgi-13.2/linux86-64/13.2/bin/pggpp2
/grid/software/pgi-13.2/linux86-64/13.2/bin/pggpp2 test.cpp -opt 1 -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 -x 59 4 -tp nehalem -x 120 0x1000 -astype 0 -fn test.cpp -il /tmp/pgc++-dre9yeLFv8N.il -x 117 0x600 -x 123 0x80000000 -x 123 4 -x 2 0x400 -x 119 0x20 -def __pgnu_vsn=40102 -alwaysinline /grid/software/pgi-13.2/linux86-64/13.2/lib/libintrinsics.il 4 -x 120 0x200000 -mp -x 69 0x200 -x 69 0x400 -gnuvsn 40102 -x 69 0x200 -x 123 0x400 -cmdline '+pgc++ /tmp/pgc++-dre9yeLFv8N.il -mp -o test.x' -asm /tmp/pgc++3dreLGhPo2hD.s

Compiling without ‘-mp’ seems to work as does removing the collapses. Additionally, everything seems fine if the switch/case statements are changed to if/else statements.

pgCC --version

pgCC 13.2-0 64-bit target on x86-64 Linux -tp nehalem

Hi jlagrone,

Thanks for the report. This bug appears to have been fixed as of the PGI 13.7 release. Please update your compiler installation to PGI 13.7 or later, and give it another try.

Hope this helps.

Best regards,

+chris