Today I installed PGI CUDA Fortran v. 10.4.
The following code (working with v. 10.3) cannot be compiled anymore with the new version.
module mod_test
use cudafor
implicit none
type comp
integer :: n
real*8 :: r
end type
type(comp), device :: struct_dev
contains
attributes(device) real*8 function calc2(i)
implicit none
integer, value :: i
integer :: j
calc2 = 0.d0
do j=1,struct_dev%n
calc2 = calc2 + log(real(i)) * struct_dev%r
end do
end function
attributes(device) subroutine calc(counter,idx,Vettore)
implicit none
integer, value :: counter, idx
real*8, dimension(counter),device :: Vettore
!real*8, dimension(32), shared :: vettore_shared
real*8 :: var
integer :: i, tid
tid = threadidx%x
!var = 0.
do i=1,20
var = calc2(i)
enddo
Vettore(idx) = Vettore(idx)+var
!vettore_shared(tid) =vettore_shared(tid)+ var
end subroutine
attributes(global) subroutine kernel_test(counter,Vettore)
implicit none
integer, value :: counter
real*8, dimension(counter),device :: Vettore
integer :: idx
idx = (blockidx%x-1)*blockdim%x + threadidx%x
call calc(counter,idx,Vettore)
end subroutine
end module
program test
use cudafor
use mod_test
implicit none
integer :: nblocks, nthreads, counter
integer :: c1, c2
real*8, dimension(:), allocatable :: Vettore_host
real*8, dimension(:), allocatable, device :: Vettore_dev
counter = 9216
nthreads = 32
nblocks = counter/nthreads
call system_clock(count=c1)
allocate(Vettore_host(counter),Vettore_dev(counter))
Vettore_dev = 0.d0
Vettore_host = 0.d0
struct_dev%n = 10
struct_dev%r = 0.1d0
call kernel_test<<<nblocks,nthreads>>>(counter,Vettore_dev)
Vettore_host = Vettore_dev
deallocate(Vettore_host,Vettore_dev)
call system_clock(count=c2)
write(*,*) 'time ', c2-c1
end program
This is the error message I get:
/tmp/pgcudaforp5ebTWCUwOMw.gpu(14): error: no suitable conversion function from “struct ::” to “int *” exists
/tmp/pgcudaforp5ebTWCUwOMw.gpu(18): error: no suitable conversion function from “struct ::” to “double *” exists
2 errors detected in the compilation of “/tmp/pgnvdd6ebjwUXYAt3.nv0”.
PGF90-F-0000-Internal compiler error. pgnvd job exited with nonzero status code 0 (test.cuf: 41)
PGF90/x86-64 Linux 10.4-0: compilation aborted
It seems that the problem is in the use of the derived type variable struct_dev, but I cannot understand why.
Thank you for any hint!