module ab
contains
subroutine ab(a, b)
real :: a, b
end subroutine
attributes(device) subroutine ac(a, b)
real :: a, b
end subroutine
end module
This is created as a Static library
then :…like this :
MODULE aabb
use ab
use cudafor
CONTAINS
attributes(global) subroutine abab( a, b, m )
integer, value :: m
real, device :: a(m), b(m)
!!! call ac(a(1), b(1))
end subroutine
subroutine ccc( a, b, m )
integer, value :: m
real :: a(m), b(m)
call ab(a(1), b(1))
end subroutine
end module
program foo
use aabb
use cudafor
integer m
real, device, allocatable :: a(:), b(:)
m = 1024
allocate(a(m),b(m))
call abab<<<1,128>>>(a,b,m)
deallocate(a,b)
end program foo
------ Build started: Project: PVFProject2, Configuration: Debug x64 ------
Compiling Project …
SourceFile1.cuf
Linking…
PVFProject2 build succeeded.
Build log was saved at “file://c:\Users\nhri-gpu\documents\visual studio 2015\Projects\PVFProject2\PVFProject2\x64\Debug\BuildLog.htm”
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
but …like this:
MODULE aabb
use ab
use cudafor
CONTAINS
attributes(global) subroutine abab( a, b, m )
integer, value :: m
real, device :: a(m), b(m)
call ac(a(1), b(1))
end subroutine
subroutine ccc( a, b, m )
integer, value :: m
real :: a(m), b(m)
call ab(a(1), b(1))
end subroutine
end module
program foo
use aabb
use cudafor
integer m
real, device, allocatable :: a(:), b(:)
m = 1024
allocate(a(m),b(m))
call abab<<<1,128>>>(a,b,m)
deallocate(a,b)
end program foo
Compiling Project …
SourceFile1.cuf
Linking…
nvlink error : Undefined reference to ‘ab_ac_’ in ‘x64\Debug\SourceFile1.obj’
pgnvd-Fatal-Could not spawn c:\program files\pgi\win64/2017/cuda/7.5/bin\nvlink.exe
child process exit with signal 127: c:\program files\pgi\win64\17.10\bin\pgnvd.exe
PVFProject2 build failed.
Build log was saved at “file://c:\Users\nhri-gpu\documents\visual studio 2015\Projects\PVFProject2\PVFProject2\x64\Debug\BuildLog.htm”
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The reason is that the attributes(device) subroutine can not be use in the Static library .