Compilling with nvc++

i wrote a CFD code which uses nvcc for compilation .
But now for some reson i had to use nvc++ to compile the code .
I use various options like -rdc=true etc flags in nvcc . But nvc++ doesnt support that . Thats why when i’m compilling with nvc++ using -c flag and in end when i’m compilling all object files its giving nv;link error like ::
“nvlink error : Undefined reference to ‘Z7dealiasId7double2EvRT_RT0_S4_S4’ in ‘time_advance1.o’
nvlink error : Undefined reference to ‘Z7dealiasId7double2EvRT_RT0_S4’ in ‘time_advance1.o’
nvlink error : Undefined reference to ‘Z7dealiasIf6float2EvRT_RT0_S4_S4’ in ‘time_advance1.o’
nvlink error : Undefined reference to ‘Z7dealiasIf6float2EvRT_RT0_S4’ in ‘time_advance1.o’
nvlink error : Undefined reference to ‘_Z16compute_P_deviceId7double2EvRxP12Vector_fieldIT_T0_EP8PressureIS3_S4_EP7fft_varIS3_S4_E’ in ‘time_advance1.o’
nvlink error : Undefined reference to ‘_Z17cal_forcing_hydroId7double2EvP12Vector_fieldIT_T0_EP7fft_varIS2_S3_ERx’ in ‘time_advance1.o’
nvlink error : Undefined reference to ‘_Z16compute_P_deviceIf6float2EvRxP12Vector_fieldIT_T0_EP8PressureIS3_S4_EP7fft_varIS3_S4_E’ in ‘time_advance1.o’
nvlink error : Undefined reference to ‘_Z17cal_forcing_hydroIf6float2EvP12Vector_fieldIT_T0_EP7fft_varIS2_S3_ERx’ in ‘time_advance1.o’
nvlink error : Undefined reference to ‘Z7dealiasId7double2EvRT_RT0_S4_S4_S4’ in ‘time_advance3.o’
nvlink error : Undefined reference to ‘Z7dealiasIf6float2EvRT_RT0_S4_S4_S4’ in ‘time_advance3.o’
nvlink error : Undefined reference to ‘_Z18cal_forcing_scalarId7double2EvP12Vector_fieldIT_T0_EP12Scalar_feildIS2_S3_ERx’ in ‘time_advance3.o’
nvlink error : Undefined reference to ‘_Z15cal_forcing_RBCId7double2EvP12Vector_fieldIT_T0_EP12Scalar_feildIS2_S3_ERx’ in ‘time_advance3.o’
nvlink error : Undefined reference to ‘_Z18cal_forcing_scalarIf6float2EvP12Vector_fieldIT_T0_EP12Scalar_feildIS2_S3_ERx’ in ‘time_advance3.o’
nvlink error : Undefined reference to ‘_Z15cal_forcing_RBCIf6float2EvP12Vector_fieldIT_T0_EP12Scalar_feildIS2_S3_ERx’ in ‘time_advance3.o’
nvlink error : Undefined reference to ‘Z7dealiasId7double2EvRT_RT0_S4_S4_S4_S4_S4’ in ‘time_advance6.o’
nvlink error : Undefined reference to ‘Z7dealiasIf6float2EvRT_RT0_S4_S4_S4_S4_S4’ in ‘time_advance6.o’
nvlink error : Undefined reference to ‘_Z15cal_forcing_mhdId7double2EvP12Vector_fieldIT_T0_ES5_P7fft_varIS2_S3_ERx’ in ‘time_advance6.o’
nvlink error : Undefined reference to ‘_Z15cal_forcing_mhdIf6float2EvP12Vector_fieldIT_T0_ES5_P7fft_varIS2_S3_ERx’ in ‘time_advance6.o’
nvlink error : Undefined reference to ‘Z9normalizeI7double2EvRT_S2_S2’ in ‘nlin1.o’
nvlink error : Undefined reference to ‘Z9normalizeI7double2EvRT_S2’ in ‘nlin1.o’
nvlink error : Undefined reference to ‘Z9normalizeI6float2EvRT_S2_S2’ in ‘nlin1.o’
nvlink error : Undefined reference to ‘Z9normalizeI6float2EvRT_S2’ in ‘nlin1.o’
nvlink error : Undefined reference to ‘Z9normalizeI7double2EvRT_S2_S2_S2’ in ‘nlin2.o’
nvlink error : Undefined reference to ‘Z9normalizeI6float2EvRT_S2_S2_S2’ in ‘nlin2.o’”"

Please suggest what should i do and how to compile using nvc++

P.S — I checked the code many time its fine . Also with nvcc it compiles absolutely fine . Its just nvc++ that shows error. I also refered the site for nvc++ details. But it does not tell much about transition from nvcc to nvc++.

Are you mixing C and C++ code? If so, you need to export the C++ symbols as C ones. As you can see, the C++ name mangling is causing symbol lookup failures.

Are you linking with nvc or nvc++ ? Also: nvcc or nvc ?

Hi manver,

Is this CUDA code? What flags are using with nvc++ to compile?

Can you provide an example compilation line, such as how “time_advance.o” is build, as well as the full link command?

How are you defining the device subroutines and are these definitions included in object files on the link command?

Be sure to use the “-cuda” flag to enable compilation of CUDA code, but note that nvc++ does not support all of CUDA nor can be used as a drop in replacement for nvcc. nvc++ only supports enough CUDA to compile thrust, which is needed for our support of offloading C++ standard language parallelism. ’

nvc++ does not support “__CUDA_ARCH__” and you would need to rewrite the code to using “if target”. For details please see this talk starting around 16:20.

Note that given nvc++ supports multiple offload models, the common GPU options are located under the “-gpu” flag. While RDC is enabled by default, the flag to enable/disable it is “-gpu=[no]rdc”.

-Mat

Yes My code is "CUDA Code ".
Compile line is as follows ::
“CC -DUSE_MPI -DParallel -std=c++14 -cuda -gpu=cc80 Lib/time_advance_functions/time_advance_mhd.cu -I /opt/nvidia/hpc_sdk/Linux_x86_64/22.11/cuda/11.8//include/ -I /opt/cray/pe/hdf5-parallel/1.12.2.3/NVIDIA/20.7/include/ -I /usr/include/python3.6m/ -I /opt/cray/pe/mpich/8.1.25/ofi/nvidia/20.7//include/ -I /opt/nvidia/hpc_sdk/Linux_x86_64/22.11/math_libs/11.8//include -I /opt/nvidia/hpc_sdk/Linux_x86_64/22.11/compilers/include -w -Xptxas -O3 -c -o time_advance5.o”.
This compile is in ALCF Polaris system so they had their own compiler CC , which translated to nvc++.
like This i compile a bunch of CUDA files and when i compile all of them together to make the executable like this command ::
“CC -DUSE_MPI -DParallel -std=c++14 -cuda -gpu=cc80 show_para.o main_hydro.o main_scalar.o main_mhd.o main_emhd.o linspace.o meshgrid.o normalize.o compute_p.o pressure.o ektk.o
spectral_setup.o time_advance1.o time_advance2.o time_advance3.o time_advance4.o time_advance5.o set_anisotropy.o Destruct.o reality.o kernel_ektk.o
time_advance6.o time_advance7.o time_advance8.o glob.o helicity.o univ.o scalar_field.o comm_s.o e_div.o modes.o force1.o force2.o pre_compute_config.o FFT.o test_fft.o
force3.o force4.o nlin1.o nlin2.o nlin3.o nlin4.o print_results.o vector_field.o dealias.o io_1.o io_2.o io_3.o io_4.o io_5.o main.o -Xptxas -O3
-L /opt/nvidia/hpc_sdk/Linux_x86_64/22.11/cuda/11.8//lib64/ -L /opt/cray/pe/hdf5-parallel/1.12.2.3/NVIDIA/20.7/lib/ -L /usr/lib/python3.6m/config-3.6m-x86_64-linux-gnu/ -L /opt/cray/pe/mpich/8.1.25/ofi/nvidia/20.7//lib/ -L /opt/nvidia/hpc_sdk/Linux_x86_64/22.11/math_libs/11.8//lib64 -L /opt/nvidia/hpc_sdk/Linux_x86_64/22.11/compilers/lib/ -L /opt/cray/pe/mpich/8.1.25/gtl/lib -lcufft -lhdf5 -lpython3.6m -lmpi -lcuda -lcudart -lmpi_nvidia -lmpi_gtl_cuda -o TARANG_NVSHMEM”

Then it gives the NVLINK error that showed above .

The flags look ok. You don’t need to explicitly add the CUDA include and lib paths nor add the CUDA libraries since the compiler will do this implicitly. Same for cuFFT, if you use the “-cudalib=cufft” flag. Doesn’t hurt, but helps simplify the build and means you don’t need to update these paths if you move to a different system.

While I’m not sure which objects contain the references, I’m assuming these are in “dealias.o”, “force1.o” and “force2.o”. Nvlink can sometimes be picky about the order of objects, so you should try moving these before “time_advance1.o” on the link line so the symbols are seen before they are referenced.

did that too . But same error still

Ok, if you can post here or direct message me a pointer to the source, I can try to reproduce the error and hopefully find a solution.

direct message how?

Follow the link under my user name, then select the “message” button towards the top right.