Using PGI Visual Fortran 2008 v10.9 on Win7
I made a mistake by forgetting to declare an input variable in global device subroutine. The compiler would successfully compile if that input variable is of REAL type (by default). After calling the subroutine with a device array as input, copying out would result in error and program exit. This wouldn’t happen if I had put “IMPLICIT NONE” in the device subroutine.
This is the code that could produce the error. It doesn’t really do anything as I’m just trying to find out what’s wrong.
MODULE CUDADEV USE CUDAFOR PARAMETER (ISIZE=4,JSIZE=10) CONTAINS ATTRIBUTES(GLOBAL) SUBROUTINE ABCD(M,THREAL,THINT) REAL,DEVICE :: M(ISIZE,JSIZE) INTEGER :: I,J ! NO DECLARATION OF INPUT VARIABLES : THREAL, THINT I = (blockidx%x-1) * 16 + threadidx%x J = (blockidx%y-1) * 16 + threadidx%y IF (I <= ISIZE .AND. J <= JSIZE) THEN IF (M(I,J) > THREAL) THEN M(I,J) = -1 END IF IF (J == THINT) THEN M(I,J) = 1 END IF END IF RETURN END SUBROUTINE END MODULE PROGRAM MAIN USE CUDAFOR USE CUDADEV REAL,DEVICE :: Mdev(ISIZE,JSIZE) REAL :: M(ISIZE,JSIZE) DO I=1,MIN(ISIZE,JSIZE) M(I,I) = 5 END DO Mdev = M CALL ABCD<<<dim3(ISIZE/16+1,JSIZE/16+1,1),dim3(16,16,1)>>>(Mdev,2.0,3.0) WRITE (*,*) cudaGetErrorString(cudaGetLastError()) M = Mdev WRITE(*,*) M STOP END PROGRAM
And here’s the output
0: copyout Memcpy (host=0x4aaa48, dev=0x5100000, size=160) FAILED: 30(unknown error)
In my opinion, this error message just doesn’t help much.