V20.9: Compiler crash with #pragma acc declare and extern variables

Hello,

In one of our large C/C++ codes we have a handful of global values defined as extern and accessed within acc parallel regions. With previous versions of the PGI compiler we would handle this by calling #pragma acc declare as shown below:

extern double epsTol_;
#pragma acc declare create copyin(epsTol_)

With PGI 20.9 every instance of #pragma acc declare throws the following error:
NVC+±S-0000-Internal compiler error. BAD sptr in var_refsym 0 (source file)
NVC++/x86-64 Linux 20.9-0: compilation completed with severe errors

Strangely, I was unable to reproduce this behavior with a standalone reproducer program.

Has anyone encountered this problem? As a short term workaround I have hard coded the extern variables in the accelerated routines, but I certainly can’t commit this workaround.

Thanks,

-David

Hi David,

This looks like a compiler error where is can’t find the symbol for some reason. I’ve seen the error before, but it’s rather generic so could be caused by a number of things. Though since you can’t reproduce it in a smaller reproducer means that it’s something contextual in your code.

Though, in looking through our open issues, I do see one that looks very similar:

% cat case2.h
#define N 10000
extern int n;
extern float a[N], b[N], c[N];

class vt_double {
private:
    double* a;
public:
    vt_double() {
     a = new double[N];
#pragma acc enter data create(a[0 : N])
    }
    ~vt_double () {
#pragma acc exit data delete(a[0 : N])
     delete a;
    }
};
% cat case2.cpp
#include <math.h>
#include <stdio.h>
#include <openacc.h>
#include <string.h>
#include "case2.h"

int xyz[N];
#pragma acc declare create(xyz)
#pragma acc declare create(a, b, c)

vt_double xxx;
extern int test();

int main( int argc, char* argv[] )
{
    test();
    return 0;
}
% nvc++ -c -acc case2.cpp
NVC++-S-0000-Internal compiler error. BAD sptr in var_refsym       0  (case2.cpp)
NVC++-S-0000-Internal compiler error. BAD sptr in var_refsym       0  (case2.cpp)
NVC++-S-0000-Internal compiler error. BAD sptr in var_refsym       0  (case2.cpp)
NVC++/x86-64 Linux Rel Dev-r195798: compilation completed with severe errors

If you think this is the same problem as yours, I’ll add you to the ticket and let them know that an external user has encounter it as well. This was found internally and is believed to be a problem with the front-end C++ compiler’s processing of the declare create with “extern” variable.

I can work around the above issue by removing the “extern” on a, b, and c, as well as moving the “declare create” directive into the header file. But this would be problematic is the header file was included in multiple source files.

-Mat

Hi Mat,

Thanks for the response. Yes, this looks like it could be the same issue.

Unfortunately the header is included in hundreds of source files. For now I’ll focus on just hard coding the values in the few places where they are needed in device regions.

Thanks,

-David

FYI, this is being tracked as TPR #28858. I’ve also asked our compiler engineering manager to see if he can bump up the priority. No guarantees since the C++ team has a lot on their plate right now, but given that this issue was now seen “in the wild”, hopefully it will get some attention.

Thanks Mat,

On my end I have a deadline of October 30 for this work, so I’ll have to convince my release manager to allow the hard coded workaround for now. It helps to know that the issue is being tracked by NVIDIA, this gives me some ammunition.

-David