Nvc++ doesn't recognise .cu file type

Hi,

I can compile a .cu file with nvcc but when I try the same with nvc++ I get …

main_thrust.cu: file not recognized: file format not recognized

Is this expected behaviour and if not how do I get this to work?

Thanks,

Leigh

Hi Leigh,

Only nvcc is capable of compiling CUDA C files. So compiling a “.cu” file with nvc++ is not expected to work.

-Mat

Hi Mat,

Thanks for that. Does NVC++ support thrust, will it work if I put my thrust in a .cpp file - currently it’s in a .cu file?

Generally should I put thrust in a .cpp file not a .cu file?

Also on what compiler is the nvc++ compiler based? I know that the nvcc compiler delegates e.g. to g++ or whatever alternative compiler is installed, and I’m seeing that in my benchmark figures.

Currently I’m getting about a 50% performance increase on nvc++ over nvcc / g++ for general C++ code. The command line options are different so I might not be optimising the g++ as well as the nvc++ where I’m using the -fast flag.

Thanks,

Leigh.

Not officially. Our C++ stdpar implementation is built on top of thrust, so nvc++ can compile the portion of thrust that we need to support stdpar. But that’s different than saying we support all of thrust, which we don’t. So you can try putting thrust code in a C++ file and have nvc++ compile it, and it may work, it’s not guaranteed nor supported.

Generally should I put thrust in a .cpp file not a .cu file?

Generally, you should use Thrust from a “.cu” file and compile using nvcc.

Also on what compiler is the nvc++ compiler based?

nvc++ is the rebranded PGI pgc++ compiler which has been available for about 10 years now. Prior to that we had “pgcpp” but when we decided to be interoperable with g++, we renamed the compiler. Though unlike nvcc which does not include a host compiler, pgc++/nvc++ is a native host compiler, and even be used as nvcc’s host compiler. Though in order to be interoperable with g++, we do need to use their C++ standard libraries so do have some dependencies on the g++ install.

Currently I’m getting about a 50% performance increase on nvc++ over nvcc / g++ for general C++ code.

That’s unfortunate, though performance differences are largely source code dependent so without analysis I can’t give firm recommendations.

“-fast” is the correct flag, but you might try increasing the number of inline levels, “-Minline=levels:10”, as inlining often helps C++ codes.

Also, be sure to look at the compiler feedback messages, “-Minfo”. This may give some clues. The caveat being that it can be quite verbose, especially when using inlining.