Using PGI as a host compiler

Hello everyone,

I want to use PGI compiler as a host compiler on CentOS 7.2 with CUDA 7.5.

The cuda installation guide says that “PGI 15.4+” is supported in CUDA 7.5.
http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#axzz44YpfyKZe

When I tried to use my PGI compiler,
compilation failure occurred with the following message.

$cd /usr/local/cuda/samples/0_Simple/cppIntegration/
$make HOST_COMPILER=pgc++

“/usr/local/cuda-7.5/bin/…/targets/x86_64-linux/include/host_config.h”, line 89: catastrophic error:
#error directive: – unsupported pgc++ configuration! Only pgc++
15.4 on Linux x86_64 is supported!
#error – unsupported pgc++ configuration! Only pgc++ 15.4 on Linux x86_64 is supported!

The PGI version I’m using is 15.10.

So my question is,
what does PGI 15.4"+" mean?
Does it mean “15.4 and later” or not?

…I suppose that I have to downgrade PGI compiler to 15.4,
but if you have any useful information, please let me know.

Thanx,

Seki

It’s fairly evident from the relevant line of code in host_config.h that the only version that will pass the test is 15.4:

#if defined(__PGIC__)

#if __PGIC__ != 15 || __PGIC_MINOR__ != 4 || !defined(__GNUC__) || !defined(__LP64__)  <-only 15.4 will pass

#error -- unsupported pgc++ configuration! Only pgc++ 15.4 on Linux x86_64 is supported!

I can’t explain the discrepancy between that and the documentation - it appears to be an oversight.

It’s quite likely that the only version of the PGI toolchain that CUDA 7.5 was officially tested with was 15.4, and so the restriction was placed that way in the host_config.h file.

In my experience (being doing this for years), you can relax the checks for minor numbers in host_config.h with no side effects.
Unfortunately some of them are now in nvcc and then you have no remedy (aside from using an hex editor).

Thank you very much for your answers.

I could relax the version checks by editing the code in host_config.h, as mfatica said.
But another problem has arisen.

[command]
nvcc -ccbin pgc++ -m64 -std=c++11 -v -Xcudafe
–c++11 -Xcompiler -std=c++11 -Xcompiler -O1 -Xcompiler -Kieee
-Xcompiler -v -gencode arch=compute_52,code=sm_52 -gencode
arch=compute_52,code=compute_52 -o pgi_test.o -c pgi_test.cu

[std error]
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/stddef.h(432): error: identifier “nullptr” is undefined

It seems that pgc++ doesn’t support C++11 code when it is used as a hostcompiler of nvcc.
Does anyone know about this problem?

// System includes
#include <stdlib.h>
#include <stdio.h>
/*
#include <string.h>
#include <math.h>
#include <assert.h>
*/
#include <vector>

// CUDA runtime
#include <cuda_runtime.h>


__global__ void kernel(unsigned int len)
{
	const unsigned int tid = blockIdx.x * blockDim.x + threadIdx.x;

	if (tid < len) {
		printf("tid[%d]\n", tid);
	}
}

int
main(int argc, char **argv)
{
	std::vector<int>	ttt = {1, 99, 10};
    ttt.emplace_back(4);
    printf("size:%d\n", ttt.size());
    printf("__cplusplus[%d]\n", __cplusplus);

	const unsigned int	len = 32;
    const unsigned int	num_threads = (len > 1024) ? 1024 : len;
    const unsigned int	num_grid = (len + num_threads - 1) / num_threads;

    // setup execution parameters
    dim3 grid(num_grid, 1, 1);
    dim3 threads(num_threads, 1, 1);

    // execute the kernel (Warmup!!!)
    kernel<<< grid, threads >>>(len);

    cudaDeviceReset();

	printf("CUDA Test End\n");
}

I have never used the PGI C++ compiler, but I wonder whether ‘-Xcompiler -std=c++11’, which instructs the host compiler to compile for C++11 should instead be ‘-Xcompiler --c++11’? I tried to find a compiler flag reference for PGI C++ by a quick internet search, but have yet to locate one.

I would simply get rid of these switches:

-Xcudafe --c++11 -Xcompiler -std=c++11

Thank you for your answer.

I’ve tried some compiler flags, but not resolved.

with -Xcompiler --c++11 instead of -Xcompiler -std=c++11
w/o -Xcudafe --c++11 -Xcompiler -std=c++11

I emailed this problem to the agency of the PGI compiler, received an answer.
He said that the cuda 7.5 seems not to support the latest PGI compiler.

So, I will use g++ compiler…