Static variables cause compiler error [OpenACC]

I was compiling my writing code for a simulation (with OpenACC) when I ran into this issue when the compiler wouldn’t compile and would crash with the following error:

nvc++ -std=c++17 -g -Minfo:accel -fast -ta:tesla -D GPUACC=1 -Iinclude -c src/simulation.cpp  -o src/simulation.o
nvc++-Fatal-/opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/bin/tools/cpp1 TERMINATED by signal 11
Arguments to /opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/bin/tools/cpp1
/opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/bin/tools/cpp1 --llalign -Dunix -D__unix -D__unix__ -Dlinux -D__linux -D__linux__ -D__NO_MATH_INLINES -D__LP64__ -D__x86_64 -D__x86_64__ -D__LONG_MAX__=9223372036854775807L '-D__SIZE_TYPE__=unsigned long int' '-D__PTRDIFF_TYPE__=long int' -D__amd64 -D__amd64__ -D__k8 -D__k8__ -D__MMX__ -D__SSE__ -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__SSE4_1__ -D__SSE4_2__ -D__AVX__ -D__AVX2__ -D__FMA__ -D__XSAVE__ -D__POPCNT__ -D__FXSR__ -D__PGI -D__NVCOMPILER -D_GNU_SOURCE -D_PGCG_SOURCE --c++17 -Iinclude -I- -I/opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/include-gcc70 -I/opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/include -I/usr/include/c++/11.1.0 -I/usr/include/c++/11.1.0/x86_64-pc-linux-gnu -I/usr/include/c++/11.1.0/backward -I/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include -I/usr/local/include -I/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include-fixed -I/usr/include -I/opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/include-gcc70 -I/opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/include -I/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include -I/usr/local/include -I/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include-fixed -I/usr/include -I/opt/nvidia/hpc_sdk/Linux_x86_64/21.5/cuda/11.3/include -D__PGLLVM__ -D__NVCOMPILER_LLVM__ -D__extension__= -D_ACCEL=201003 -D_OPENACC=201711 -DCUDA_VERSION=11030 -DPGI_TESLA_TARGET -DGPUACC=1 --preinclude _cplus_preinclude.h --preinclude_macros _cplus_macros.h --gnu_version=110100 -D__pgnu_vsn=110100 -g --dwarf2 --accel --preinclude openacc_predef.h -D_NVHPC_RDC -q -o /tmp/nvc++7pPcXmCsgx_b.il src/simulation.cpp
make: *** [Makefile:80: src/simulation.o] Error 127

I was able to trace it down (manually) to the declaration of static variables as such even outside a parallel region.

static bool flag = false;
static int shift = p.bufferSize;

I’m not sure why this is happening. I can work around it for now. This error appears when my accelerator target is tesla or multicore. The code compiles correctly if I compile for host.

P.S. I’m using the HPC_SDK Version 21.5

Hi debbh922,

It’s definitely a compiler issue but as to why it’s happening is unclear. Can you provide a reproducing example so I can report it?

I did try to write a simple program using static variables, but it worked fine. So the issue is something specific to your program rather than a general issue with statics.

-Mat

I’m very sorry, I moved away (modified) from the original piece of code where this issue arose. I tried reproducing the error now but it compiles correctly. Sorry for the false alarm.