At present, I’m looking at converting a program that works with Accelerators to CUDA Fortran. I’m not sure it’ll be useful in the long run, but the experience will be well worth it. Unfortunately, I got caught with an ICE:
PGF90-F-0000-Internal compiler error. unexpected runtime function call
Okay, I’ll probably report that to Support if I can’t figure it out. But then I wondered about whether my PGI setup might be wonky. So I tried this simple program which has worked before:
module assign_mod
use cudafor
contains
attributes(global) subroutine assign_kernel(A, N)
implicit none
integer, value :: N
integer, device, dimension(N) :: A
integer, device :: idx
idx = (blockidx%x - 1) * blockdim%x + threadidx%x
if (idx <= N) A(idx) = blockidx%x * blockdim%x + threadidx%x
end subroutine assign_kernel
end module assign_mod
program main
use cudafor
use assign_mod
implicit none
integer, parameter :: n = 32
integer, allocatable, dimension(:) :: a_host, b_host
integer, device, allocatable, dimension(:) :: a_device
type(dim3) :: dimGrid, dimBlock
integer, parameter :: blocksize = 4
integer :: i
dimBlock = dim3(blocksize,1,1)
dimGrid = dim3(n/blocksize,1,1)
allocate(a_host(n))
allocate(b_host(n))
allocate(a_device(n))
forall (i=1:n)
a_host(i) = 99
end forall
a_device = a_host
call assign_kernel<<<dimGrid, dimBlock>>> (a_device, n)
b_host = a_device
write (*,"(I2,1X)",advance="no") b_host
write (*,*)
end program main
But, when I try to compile and run it:
> pgfortran trial.cuf
> ./a.out
0: ALLOCATE: 128 bytes requested; status = 35
Can you help me figure out what I’ve done to wreck my CUDA Fortran setup? (Another example: running the cufinfo.cuf example from 10.2 does nothing on first run and then dumps core when you run it again.)
FYI, I’m running 10.2 and my environment looks like:
> env | grep -i pgi
MANPATH=/usr/share/man:/usr/local/share/man:/usr/X11R6/man:/opt/pgi/linux86-64/2010/man
LD_LIBRARY_PATH=/home/mathomp4/lib:/opt/pgi/linux86-64/2010/mpi/mpich/lib:/opt/pgi/linux86-64/2010/cuda/lib:/opt/pgi/linux86-64/2010/cuda/open64/lib:/opt/pgi/linux86-64/2010/lib:/opt/pgi/linux86-64/2010/libso:/opt/cuda/lib64::/home/mathomp4/GMAO-Baselibs-3_1_5/Linux/lib:/opt/pgi/linux86-64/2010/mpi/mpich/lib:/opt/cuda/lib64
PGI=/opt/pgi
PATH=.:/home/mathomp4/bin:/home/mathomp4/cvstools:/home/mathomp4/opengrads:/opt/pgi/linux86-64/2010/bin:/opt/pgi/linux86-64/2010/mpi/mpich/bin:/home/dkokron/play/pdt/pdt-3.15/x86_64/bin:/home/dkokron/play/tau/tau-2.19/x86_64/bin:/home/mathomp4/Fortuna/GEOSagcm/src/GMAO_Shared/GEOS_Util/post:/home/mathomp4/Fortuna/GEOSagcm/src/GMAO_Shared/GEOS_Util/plots:/opt/cuda/bin:/home/mathomp4/bin:/opt/pgi/linux86-64/2010/bin:/opt/pgi/linux86-64/2010/mpi/mpich/bin:/opt/pgi/linux86-64/2010/cuda/bin:/opt/cuda/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/mathomp4/bin
LM_LICENSE_FILE=/opt/pgi/license.dat
PGIABBR=/opt/pgi/linux86-64/2010
Thanks,
Matt