link error:redefinition of ‘__cudaRegisterLinkedBinary_8data_x_F’

Because of the “data is partically exists in device”, I changed to solve the problem with cuda. However, when I link the program, it occurred the following problem.

mpif90 -DDIST_MPI -DDBLE_PRECSN -DP3D_SINGLE -DPG -DDBLE_PRECSN   -acc -ta=tesla -Mfixed -Minfo=accel -Mcuda=rdc -o cfl3d_mpi development.o data_x.o main.o \
libdist.a libcommon.a -L/home/xiell/pgi/linux86-64/2018/mpi/openmpi-2.1.2/lib 
/home/xll/pgi/linux86-64/18.4/include_acc/linkstub.c:16:36: error: redefinition of ‘__cudaRegisterLinkedBinary_8data_x_F’
 #define __REGISTERFUNCNAME_CORE(X) __cudaRegisterLinkedBinary##X
                                    ^
/home/xll/pgi/linux86-64/18.4/include_acc/linkstub.c:17:31: note: in expansion of macro ‘__REGISTERFUNCNAME_CORE’
 #define __REGISTERFUNCNAME(X) __REGISTERFUNCNAME_CORE(X)
                               ^
/home/xll/pgi/linux86-64/18.4/include_acc/linkstub.c:22:8: note: in expansion of macro ‘__REGISTERFUNCNAME’
   void __REGISTERFUNCNAME(id)(void (*callback_fp)(void **),       \
        ^
/tmp/pgcudaayCibaqy1hWiG.reg.c:36:1: note: in expansion of macro ‘DEFINE_REGISTER_FUNC’
 DEFINE_REGISTER_FUNC(_8data_x_F)
 ^
/home/xll/pgi/linux86-64/18.4/include_acc/linkstub.c:16:36: note: previous definition of ‘__cudaRegisterLinkedBinary_8data_x_F’ was here
 #define __REGISTERFUNCNAME_CORE(X) __cudaRegisterLinkedBinary##X
                                    ^
/home/xll/pgi/linux86-64/18.4/include_acc/linkstub.c:17:31: note: in expansion of macro ‘__REGISTERFUNCNAME_CORE’
 #define __REGISTERFUNCNAME(X) __REGISTERFUNCNAME_CORE(X)
                               ^
/home/xll/pgi/linux86-64/18.4/include_acc/linkstub.c:22:8: note: in expansion of macro ‘__REGISTERFUNCNAME’
   void __REGISTERFUNCNAME(id)(void (*callback_fp)(void **),       \
        ^
/tmp/pgcudaayCibaqy1hWiG.reg.c:2:1: note: in expansion of macro ‘DEFINE_REGISTER_FUNC’
 DEFINE_REGISTER_FUNC(_8data_x_F)
 ^
pgacclnk: child process exit status 2: /home/xll/pgi/linux86-64/18.4/bin/pgnvd

the structure of the program is as follows:

PROGRAM
  MAIN.F 
  DATA.F
  A.F
  B.F
  C.F
END PROGRAM

the compile order is DATA.F C.F B.F A.F MAIN.F. All the code are compiled with"mpif90 -DDIST_MPI -DDBLE_PRECSN -DP3D_SINGLE -DPG -DDBLE_PRECSN -fast -r8 -acc -ta=tesla -Mfixed -Minfo=accel -Mcuda=rdc -c *.F"
DATA.F defines some common variable, and it also includes some “!$acc decleare create”.
C.F defines a device function.
B.F defines a kernel function that invoke C.
A.F is a function that invoke B.
MAIN.F invokes A.
Where maight be wrong?

Hi xll_bit,

As part of the link step, PGI will implicitly create the CUDA code to register kernels, global data, etc. Here it appears that the symbol “data_x_F” has multiple definitions so is getting registered multiple times.

What is the symbol "data_x_F? My guess is that it’s a variable in the “data” module.

Are you using CUDA C or CUDA Fortran?

If you’re using CUDA C, do you have this symbol also declared in the CUDA code?

If using CUDA Fortran, is “x_F” a “device” variable?

-Mat

I am using cuda fortran. And data_x.F is a module that contains some common variable. And it includes some “!$acc decleare create” which used in acc. There is no variable “x_F” or “data_x_F”.

Ok, then “data_x” must be the module name where it’s trying to register the module variables in data_x. Somehow the module is being defined twice.

Is “data_x.o” also included in one the of libraries?

If not, can you provide a reproducing example? I’d need to investigate what going on.

Yes, the data_x.o also included in another library, and the library is also used to generate the object file. However, it can generate the object file only using OpenACC without CUDA.

I have copied the *.mod file that generated by compiling the data_x.F to the place where the main.F located and deleted the compile of data_x.F in the place where the main.F located. Now it can generate the target file. Thank you!