error LNK2019: unresolved external symbol __pgi_cu_init

I hve been trying to compile simple do loops using accelerator directive "!$acc region’. but I am getting the following error. I have enabled the target accelerator in properties (-ta=nvidia)

!$acc region
do i= 1,400
do k= 1,5000
do j= 1,1000
j=j+1
end do
end do
end do
!$acc end region

ConsoleApp.obj : error LNK2019: unresolved external symbol _pgi_cu_init referenced in function MAIN
ConsoleApp.obj : error LNK2019: unresolved external symbol _pgi_cuda_allock referenced in function MAIN
ConsoleApp.obj : error LNK2019: unresolved external symbol _pgi_cuda_uploadk referenced in function MAIN
ConsoleApp.obj : error LNK2019: unresolved external symbol _pgi_cuda_paramsetk referenced in function MAIN
ConsoleApp.obj : error LNK2019: unresolved external symbol _pgi_cuda_launchk referenced in function MAIN
ConsoleApp.obj : error LNK2019: unresolved external symbol _pgi_cuda_downloadk referenced in function MAIN
ConsoleApp.obj : error LNK2019: unresolved external symbol _pgi_cuda_freek referenced in function MAIN
ConsoleApp.obj : error LNK2019: unresolved external symbol _pgi_cu_close referenced in function MAIN
ConsoleApp.obj : error LNK2019: unresolved external symbol _cudaRegisterFatBinary referenced in function MAIN
ConsoleApp.obj : error LNK2019: unresolved external symbol _cudaRegisterFunction referenced in function MAIN
ConsoleApp.obj : error LNK2019: unresolved external symbol _cudaRegisterVar referenced in function MAIN
ConsoleApp.obj : error LNK2019: unresolved external symbol _cudaUnregisterFatBinary referenced in function MAIN
C:\Users\INTEL\Documents\Visual Studio 2010\Projects\PVFProject4\PVFProject4\x64\Debug\PVFProject4.exe : fatal error LNK1120: 12 unresolved externals
PVFProject4 build failed.****

Can you tell the reason behind this error.

Hi Kerry,

Whenever I see these undefined references errors, it’s usually because the user forgot to add “-ta=nvidia” to the link. However, by setting target accelerator property in PVF, the -ta=nvidia flag is added to both the compile and link so I’m not sure why you’re getting this.

Can you please double check the build log (the link given in the command window after the build) to see if -ta=nvidia is being added? Post the build log or sending it to PGI Customer Sever (support@pgroup.com) might be helpful as well.

  • Mat

Mat
I am posting the build log for the project here. the -ta= nvidia flag is present in the compiling but it is not in the linking.

PVF Build Log

Compiling Project …

ConsoleApp.f90

c:\program files\pgi\win64\11.6\bin\pgfortran.exe -Hx,123,8 -Hx,123,0x40000 -Hx,0,0x40000000 -Mx,0,0x40000000 -Hx,0,0x20000000 -V -Mpreprocess -g -Bstatic -Mbackslash -Mextend -mp -Mcuda=fastmath -Mfree -Mbounds -Mchkptr -Mchkstk -Mimsl -Mmkl -I"C:\Program Files\PGI\win64\11.6\include" -I"C:\Program Files\PGI\win64\11.6\lib" -I"C:\Program Files\PGI\win64\11.6\include_acc\OT_10" -I"C:\Program Files\PGI\win64\11.6\include_acc" -I"C:\Program Files\PGI\win64\2011\cuda\3.2\lib64" -I"C:\Program Files\PGI\win64\2011\cuda\3.2\include" -I"C:\Program Files\PGI\win64\2011\cuda\4.0\lib64" -I"C:\Program Files\PGI\win64\2011\cuda\4.0\include" -I"c:\program files\pgi\win64\11.6\include" -I"C:\Program Files\PGI\Microsoft Open Tools 10\include" -I"C:\Program Files\PGI\Microsoft Open Tools 10\PlatformSDK\include" -tp=core2-64 -ta=nvidia,fastmath,mul24,wait -Minform=warn -module “x64\Debug” -Mkeepasm -Manno -Minfo=accel,ccff,ftn,inline,ipa,intensity,loop,lre,mp,opt,par,unified,vect -o “x64\Debug\ConsoleApp.obj” -c “C:\Users\INTEL\Documents\Visual Studio 2010\Projects\test_for_acceleration\PVFProject4\ConsoleApp.f90”

Command exit code: 0

Command output: [PGF90/x86-64 Windows 11.6-0 Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved. Copyright 2000-2011, STMicroelectronics, Inc. All Rights Reserved. C:\Users\INTEL\Documents\Visual Studio 2010\Projects\test_for_acceleration\PVFProject4\ConsoleApp.f90(16) : warning W0115 : Assignment to DO variable j in loop 0 inform, 1 warnings, 0 severes, 0 fatal for etimetest PGF90/x86-64 Windows 11.6-0 Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved. Copyright 2000-2011, STMicroelectronics, Inc. All Rights Reserved. etimetest: 13, Intensity = 2002000400.00 Loop is parallelizable Accelerator kernel generated 13, !$acc do parallel, vector(256) ! blockidx%x threadidx%x 19, Sum reduction generated for i 14, Intensity = 5005000.00 Loop is parallelizable 15, Intensity = 1.00 Loop carried scalar dependence for ‘j’ at line 16 Inner sequential loop scheduled on accelerator pgfortran 11.6-0 64-bit target on x86-64 Windows -tp core2-64 Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved. Copyright 2000-2011, STMicroelectronics, Inc. All Rights Reserved. ]

Linking…

c:\program files\pgi\win64\11.6\bin\pgfortran.exe -Wl,/libpath:“c:\program files\pgi\win64\11.6\lib” -Wl,/libpath:“C:\Program Files\PGI\Microsoft Open Tools 10\lib\amd64” -Wl,/libpath:“C:\Program Files\PGI\Microsoft Open Tools 10\PlatformSDK\lib\AMD64” -Yl,“C:\Program Files\PGI\Microsoft Open Tools 10\bin\amd64” -g -Bstatic -o “C:\Users\INTEL\Documents\Visual Studio 2010\Projects\test_for_acceleration\PVFProject4\x64\Debug\PVFProject4.exe” “x64\Debug\ConsoleApp.obj”

Command exit code: 2

Command output: [ConsoleApp.obj : error LNK2019: unresolved external symbol _pgi_cu_init referenced in function MAIN ConsoleApp.obj : error LNK2019: unresolved external symbol _pgi_cuda_allock referenced in function MAIN ConsoleApp.obj : error LNK2019: unresolved external symbol _pgi_cuda_uploadk referenced in function MAIN ConsoleApp.obj : error LNK2019: unresolved external symbol _pgi_cuda_paramsetk referenced in function MAIN ConsoleApp.obj : error LNK2019: unresolved external symbol _pgi_cuda_launchk referenced in function MAIN ConsoleApp.obj : error LNK2019: unresolved external symbol _pgi_cuda_downloadk referenced in function MAIN ConsoleApp.obj : error LNK2019: unresolved external symbol _pgi_cuda_freek referenced in function MAIN ConsoleApp.obj : error LNK2019: unresolved external symbol _pgi_cu_close referenced in function MAIN ConsoleApp.obj : error LNK2019: unresolved external symbol _cudaRegisterFatBinary referenced in function MAIN ConsoleApp.obj : error LNK2019: unresolved external symbol _cudaRegisterFunction referenced in function MAIN ConsoleApp.obj : error LNK2019: unresolved external symbol _cudaRegisterVar referenced in function MAIN ConsoleApp.obj : error LNK2019: unresolved external symbol _cudaUnregisterFatBinary referenced in function MAIN C:\Users\INTEL\Documents\Visual Studio 2010\Projects\test_for_acceleration\PVFProject4\x64\Debug\PVFProject4.exe : fatal error LNK1120: 12 unresolved externals ]

PVFProject4 build failed.

Hi Kerry,

Yes, it appears that the “-ta” flag is not being used in the link. It may be that you set the Target NVIDIA Accelerator (-ta=nvidia) and the Enable CUDA Fortran (-Mcuda) properties for the file instead of for the project. Doing so creates a situation where the flags are used for compilation but not linking. If this is the case, you will need to set these properties at the project level.

A note about project vs. file properties. In PVF, project properties are used for all files until a particular file’s property or properties are set individually. Once that’s been done, the property overridden at the file level must continue to be adjusted at the file level for that property for that file. So if Kerry manually changes the file’s property to ‘No’ and the project’s property to ‘Yes’, the project property will not override the file’s property and the file will be compiled without the flag. This issue is a known limitation in PVF.

Hope this helps,
Mat

Mat
Thanks a lot for your help. You are right, I was using target accelerator just for the source file. Now when I set it ON for whole project, the code is running great.