Problem using -ccbin pgc++ and -cuda options to nvcc

Hello all,

I am unable to build mvapich2-2.3 with PGI-18.10. It fails during the compilation of a CUDA source file named pack_unpack.cu. Mvapich uses a 2-step build procedure to compile a CUDA source file. Step 1 involves generating a .cpp file by using the ‘-cuda’ option to nvcc. Step 2 involves compiling the .cpp file with the host compiler. The error occurs during the compilation of the .cpp file (step 2). This build procedure works fine with GNU compiler but fails with PGI compiler. Can someone please help? Is there a flag I can pass to the PGI compiler to enable this 2-step build procedure?

$ nvcc -cuda -ccbin pgc++ --output-file pack_unpack.cpp pack_unpack.cu && pgc++ -c pack_unpack.cpp -o pack_unpack.o && file pack_unpack.o
"/global/opt/pgi/linux86-64/18.10/include/_cplus_preinclude.h", line 16: error:
          identifier "__pgi_tag" is undefined
  typedef __pgi_tag __pgi_va_list[1]; 
          ^

"/global/opt/pgi/linux86-64/18.10/include/_cplus_preinclude.h", line 16: error:
          invalid redeclaration of type name "__pgi_va_list" (declared at line
          25)
  typedef __pgi_tag __pgi_va_list[1]; 
                    ^

2 errors detected in the compilation of "pack_unpack.cpp".

It should work as follows. See GNU compiler output.

$ nvcc -cuda -ccbin g++ --output-file pack_unpack.cpp pack_unpack.cu && g++ -c pack_unpack.cpp -o pack_unpack.o && file pack_unpack.o
pack_unpack.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped

The following alternative build works with pgc++. However, it is unlikely to be straightforward to modify the Mvapich Makefile to use this build procedure instead.

$ nvcc -ccbin pgc++ pack_unpack.cu -c -o pack_unpack.o && file pack_unpack.o
pack_unpack.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped

Thanks,
Chris

Hi Chris,

Try adding “–no_preincludes --nvcchost” to the pgc++ compile:

nvcc -cuda -ccbin pgc++ --output-file pack_unpack.cpp pack_unpack.cu && pgc++ --no_preincludes --nvcchost -c pack_unpack.cpp -o pack_unpack.o && file pack_unpack.o

The problem being that pgc++ doesn’t know by default that the post-process code is NVCC host code (hence the added flag --nvcchost). The “–no_preincludes” prevents the compiler from adding the default headers a second time.

Hope this helps,
Mat

Thanks Mat. This worked.