undefined reference to `__pgi_cu_init'... linking error

I tried to build a big fortran program with PGI accelerator. Looks like all .o files can be built. But the binary file can not be produced from the .o files. I specified the pgi library directory in the make file, and tried almost everything. Following errors just dont go away.

pgfortran -O0 -o ./rundir/dualacm main.o read_data.o write_data.o connect.o calcjacob.o compflux.o setup.o mapder.o compresid.o initsetup.o boundcond.o preprocess.o checkdebug.o iterations.o calctimestep.o wallforce.o curvefit.o tecplotter.o
iterations.o: In function iterations_': /root/Desktop/ForTest/./iterations.f90:86: undefined reference to __pgi_cu_init’
/root/Desktop/ForTest/./iterations.f90:86: undefined reference to __pgi_cu_module3' /root/Desktop/ForTest/./iterations.f90:86: undefined reference to __pgi_cu_module_function2’
/root/Desktop/ForTest/./iterations.f90:86: undefined reference to __pgi_cu_alloc' /root/Desktop/ForTest/./iterations.f90:86: undefined reference to __pgi_cu_alloc’
/root/Desktop/ForTest/./iterations.f90:86: undefined reference to __pgi_cu_alloc' /root/Desktop/ForTest/./iterations.f90:86: undefined reference to __pgi_cu_uploadx’
/root/Desktop/ForTest/./iterations.f90:86: undefined reference to __pgi_cu_uploadx' /root/Desktop/ForTest/./iterations.f90:86: undefined reference to __pgi_cu_datadone’
/root/Desktop/ForTest/./iterations.f90:86: undefined reference to __pgi_cu_uploadc' /root/Desktop/ForTest/./iterations.f90:91: undefined reference to __pgi_cu_paramset’
/root/Desktop/ForTest/./iterations.f90:91: undefined reference to __pgi_cu_launch2' /root/Desktop/ForTest/./iterations.f90:98: undefined reference to __pgi_cu_downloadx’
/root/Desktop/ForTest/./iterations.f90:98: undefined reference to __pgi_cu_downloadx' /root/Desktop/ForTest/./iterations.f90:98: undefined reference to __pgi_cu_datadone’
/root/Desktop/ForTest/./iterations.f90:98: undefined reference to __pgi_cu_free' /root/Desktop/ForTest/./iterations.f90:98: undefined reference to __pgi_cu_free’
/root/Desktop/ForTest/./iterations.f90:98: undefined reference to __pgi_cu_free' /root/Desktop/ForTest/./iterations.f90:98: undefined reference to __pgi_cu_close’


My make file is here:


FCOMP = pgfortran
OPTS = -L/opt/pgi/linux86-64/10.9/lib -L/opt/pgi/linux86-64/10.9/libso -c -ta=nvidia,cc20,cuda3.1,time -Minfo
LINK2OPTS = -O0 -o
OBJS = main.o read_data.o write_data.o connect.o calcjacob.o
compflux.o setup.o mapder.o compresid.o
initsetup.o boundcond.o preprocess.o checkdebug.o iterations.o calctimestep.o
wallforce.o curvefit.o tecplotter.o

dualacm:$(OBJS)
$(FCOMP) $(LINK2OPTS) ./rundir/dualacm $(OBJS)

boundcond.o:setup.o boundcond.f90
$(FCOMP) $(OPTS) boundcond.f90

calcjacob.o:setup.o calcjacob.f90 curvefit.o
$(FCOMP) $(OPTS) calcjacob.f90

calctimestep.o:setup.o calctimestep.f90
$(FCOMP) $(OPTS) calctimestep.f90

checkdebug.o:setup.o checkdebug.f90
$(FCOMP) $(OPTS) checkdebug.f90

compflux.o:setup.o compflux.f90
$(FCOMP) $(OPTS) compflux.f90

compresid.o:setup.o compresid.f90
$(FCOMP) $(OPTS) compresid.f90

connect.o:connect.f90
$(FCOMP) $(OPTS) connect.f90

initsetup.o:setup.o initsetup.f90
$(FCOMP) $(OPTS) initsetup.f90

iterations.o:setup.o iterations.f90
$(FCOMP) $(OPTS) iterations.f90

write_data.o:write_data.f90
$(FCOMP) $(OPTS) write_data.f90

main.o:setup.o main.f90 write_data.o
$(FCOMP) $(OPTS) main.f90

mapder.o:setup.o mapder.f90
$(FCOMP) $(OPTS) mapder.f90

preprocess.o:preprocess.f90
$(FCOMP) $(OPTS) preprocess.f90

read_data.o:read_data.f90
$(FCOMP) $(OPTS) read_data.f90

tecplotter.o:setup.o mapder.o tecplotter.f90
$(FCOMP) $(OPTS) tecplotter.f90

wallforce.o:setup.o wallforce.f90
$(FCOMP) $(OPTS) wallforce.f90

curvefit.o:curvefit.f90
$(FCOMP) $(OPTS) curvefit.f90

setup.o:setup.f90
$(FCOMP) $(OPTS) setup.f90
clean:
rm *.o *.mod



The complete building info is:

pgfortran -L/opt/pgi/linux86-64/10.9/lib -L/opt/pgi/linux86-64/10.9/libso -c -ta=nvidia,cc20,cuda3.1,time -Minfo setup.f90
pgfortran -L/opt/pgi/linux86-64/10.9/lib -L/opt/pgi/linux86-64/10.9/libso -c -ta=nvidia,cc20,cuda3.1,time -Minfo write_data.f90
pgfortran -L/opt/pgi/linux86-64/10.9/lib -L/opt/pgi/linux86-64/10.9/libso -c -ta=nvidia,cc20,cuda3.1,time -Minfo main.f90
pgfortran -L/opt/pgi/linux86-64/10.9/lib -L/opt/pgi/linux86-64/10.9/libso -c -ta=nvidia,cc20,cuda3.1,time -Minfo read_data.f90
pgfortran -L/opt/pgi/linux86-64/10.9/lib -L/opt/pgi/linux86-64/10.9/libso -c -ta=nvidia,cc20,cuda3.1,time -Minfo connect.f90
connectivity:
30, Memory zero idiom, loop replaced by call to __c_mzero4
pgfortran -L/opt/pgi/linux86-64/10.9/lib -L/opt/pgi/linux86-64/10.9/libso -c -ta=nvidia,cc20,cuda3.1,time -Minfo curvefit.f90
pgfortran -L/opt/pgi/linux86-64/10.9/lib -L/opt/pgi/linux86-64/10.9/libso -c -ta=nvidia,cc20,cuda3.1,time -Minfo calcjacob.f90
curved_jacobi_cubic:
852, Invariant assignments hoisted out of loop
909, Invariant assignments hoisted out of loop
1135, Invariant assignments hoisted out of loop
xycoor_atgps:
1188, Possible copy in and copy out of func in call to mapbasefunc
1189, Possible copy in and copy out of func in call to mapbasefunc8
1190, Possible copy in and copy out of func in call to mapbasefunc12
pgfortran -L/opt/pgi/linux86-64/10.9/lib -L/opt/pgi/linux86-64/10.9/libso -c -ta=nvidia,cc20,cuda3.1,time -Minfo compflux.f90
interfacevisflux:
304, Invariant if transformation
pgfortran -L/opt/pgi/linux86-64/10.9/lib -L/opt/pgi/linux86-64/10.9/libso -c -ta=nvidia,cc20,cuda3.1,time -Minfo mapder.f90
mapder:
15, Invariant if transformation
16, Invariant assignments hoisted out of loop
36, Invariant if transformation
37, Invariant assignments hoisted out of loop
59, Invariant if transformation
60, Invariant assignments hoisted out of loop
mapder_8_node:
177, Invariant if transformation
178, Invariant assignments hoisted out of loop
224, Invariant if transformation
225, Invariant assignments hoisted out of loop
269, Invariant if transformation
270, Invariant assignments hoisted out of loop
mapder_12_node:
329, Invariant if transformation
330, Invariant assignments hoisted out of loop
378, Invariant if transformation
379, Invariant assignments hoisted out of loop
427, Invariant if transformation
428, Invariant assignments hoisted out of loop
pgfortran -L/opt/pgi/linux86-64/10.9/lib -L/opt/pgi/linux86-64/10.9/libso -c -ta=nvidia,cc20,cuda3.1,time -Minfo compresid.f90
pgfortran -L/opt/pgi/linux86-64/10.9/lib -L/opt/pgi/linux86-64/10.9/libso -c -ta=nvidia,cc20,cuda3.1,time -Minfo initsetup.f90
computelandm:
549, Invariant communication calls hoisted out of loop
Invariant assignments hoisted out of loop
554, Invariant communication calls hoisted out of loop
Invariant assignments hoisted out of loop
pgfortran -L/opt/pgi/linux86-64/10.9/lib -L/opt/pgi/linux86-64/10.9/libso -c -ta=nvidia,cc20,cuda3.1,time -Minfo boundcond.f90
bcflux:
30, Invariant assignments hoisted out of loop
89, Invariant assignments hoisted out of loop
150, Invariant assignments hoisted out of loop
212, Invariant assignments hoisted out of loop
274, Invariant assignments hoisted out of loop
332, Invariant assignments hoisted out of loop
390, Invariant assignments hoisted out of loop
bcvisflux:
467, Invariant assignments hoisted out of loop
Invariant if transformation
510, Invariant assignments hoisted out of loop
Invariant if transformation
553, Invariant assignments hoisted out of loop
Invariant if transformation
596, Invariant assignments hoisted out of loop
Invariant if transformation
640, Invariant assignments hoisted out of loop
Invariant if transformation
687, Invariant assignments hoisted out of loop
Invariant if transformation
732, Invariant assignments hoisted out of loop
Invariant if transformation
pgfortran -L/opt/pgi/linux86-64/10.9/lib -L/opt/pgi/linux86-64/10.9/libso -c -ta=nvidia,cc20,cuda3.1,time -Minfo preprocess.f90
pgfortran -L/opt/pgi/linux86-64/10.9/lib -L/opt/pgi/linux86-64/10.9/libso -c -ta=nvidia,cc20,cuda3.1,time -Minfo checkdebug.f90
checkcell:
82, Invariant if transformation
83, Invariant assignments hoisted out of loop
pgfortran -L/opt/pgi/linux86-64/10.9/lib -L/opt/pgi/linux86-64/10.9/libso -c -ta=nvidia,cc20,cuda3.1,time -Minfo iterations.f90
iterations:
90, Generating copyin(q(1:3,1:n,1:n,1:ncell))
Generating copyout(qoo(1:3,1:n,1:n,1:ncell))
Generating copy(qo(1:3,1:n,1:n,1:ncell))
Generating compute capability 2.0 binary
91, Loop is parallelizable
92, Loop is parallelizable
93, Loop is parallelizable
94, Loop is parallelizable
Accelerator kernel generated
91, !$acc do parallel
92, !$acc do parallel, vector(2)
93, !$acc do vector(8)
94, !$acc do vector(3)
CC 2.0 : 0 registers; 0 shared, 0 constant, 0 local memory bytes; 33 occupancy
threestagerk:
150, Memory copy idiom, loop replaced by call to __c_mcopy4
fivestagerk:
181, Memory copy idiom, loop replaced by call to __c_mcopy4
196, Memory copy idiom, loop replaced by call to __c_mcopy4
206, Memory copy idiom, loop replaced by call to __c_mcopy4
215, Memory copy idiom, loop replaced by call to __c_mcopy4
pgfortran -L/opt/pgi/linux86-64/10.9/lib -L/opt/pgi/linux86-64/10.9/libso -c -ta=nvidia,cc20,cuda3.1,time -Minfo calctimestep.f90
calctimestep:
18, Memory zero idiom, loop replaced by call to __c_mzero4
50, Memory set idiom, loop replaced by call to __c_mset4
calc_vol_av:
69, Memory zero idiom, loop replaced by call to __c_mzero4
83, Invariant assignments hoisted out of loop
pgfortran -L/opt/pgi/linux86-64/10.9/lib -L/opt/pgi/linux86-64/10.9/libso -c -ta=nvidia,cc20,cuda3.1,time -Minfo wallforce.f90
tauandp:
45, Invariant if transformation
118, Invariant if transformation
calc_face_normal:
235, Invariant assignments hoisted out of loop
skinfricsetup:
680, Invariant assignments hoisted out of loop
770, Invariant assignments hoisted out of loop
pgfortran -L/opt/pgi/linux86-64/10.9/lib -L/opt/pgi/linux86-64/10.9/libso -c -ta=nvidia,cc20,cuda3.1,time -Minfo tecplotter.f90
tecplotter:
310, Invariant assignments hoisted out of loop
314, Invariant assignments hoisted out of loop
pgfortran -O0 -o ./rundir/dualacm main.o read_data.o write_data.o connect.o calcjacob.o compflux.o setup.o mapder.o compresid.o initsetup.o boundcond.o preprocess.o checkdebug.o iterations.o calctimestep.o wallforce.o curvefit.o tecplotter.o
iterations.o: In function iterations_': /root/Desktop/ForTest/./iterations.f90:86: undefined reference to __pgi_cu_init’
/root/Desktop/ForTest/./iterations.f90:86: undefined reference to __pgi_cu_module3' /root/Desktop/ForTest/./iterations.f90:86: undefined reference to __pgi_cu_module_function2’
/root/Desktop/ForTest/./iterations.f90:86: undefined reference to __pgi_cu_alloc' /root/Desktop/ForTest/./iterations.f90:86: undefined reference to __pgi_cu_alloc’
/root/Desktop/ForTest/./iterations.f90:86: undefined reference to __pgi_cu_alloc' /root/Desktop/ForTest/./iterations.f90:86: undefined reference to __pgi_cu_uploadx’
/root/Desktop/ForTest/./iterations.f90:86: undefined reference to __pgi_cu_uploadx' /root/Desktop/ForTest/./iterations.f90:86: undefined reference to __pgi_cu_datadone’
/root/Desktop/ForTest/./iterations.f90:86: undefined reference to __pgi_cu_uploadc' /root/Desktop/ForTest/./iterations.f90:91: undefined reference to __pgi_cu_paramset’
/root/Desktop/ForTest/./iterations.f90:91: undefined reference to __pgi_cu_launch2' /root/Desktop/ForTest/./iterations.f90:98: undefined reference to __pgi_cu_downloadx’
/root/Desktop/ForTest/./iterations.f90:98: undefined reference to __pgi_cu_downloadx' /root/Desktop/ForTest/./iterations.f90:98: undefined reference to __pgi_cu_datadone’
/root/Desktop/ForTest/./iterations.f90:98: undefined reference to __pgi_cu_free' /root/Desktop/ForTest/./iterations.f90:98: undefined reference to __pgi_cu_free’
/root/Desktop/ForTest/./iterations.f90:98: undefined reference to __pgi_cu_free' /root/Desktop/ForTest/./iterations.f90:98: undefined reference to __pgi_cu_close’
make: *** [dualacm] Error 2


Please help me with this issue. It’s kinda urgent. I appreciate if any one can shed some light on it!

Thanks.


Shawn

It looks like you aren’t linking with a CUDA option, just building. Try adding the -ta= line to the LINK2OPTS. I believe the linker needs this option, not just the build, so that it can link the correct CUDA objects/libraries from PGI.

Hope this helps,
Matt