I have written a very simple program to isolate a problem I’m seeing. Basically, “-fast” causes my device functions to stop working. I’ve pasted the code below:
module gpufunc
use cudafor
implicit none
contains
c === ==================================================================
attributes(device) REAL FUNCTION myarg(argin)
IMPLICIT NONE
REAL,DEVICE :: argin
myarg = argin * -1.0
END FUNCTION myarg
c === ==================================================================
attributes(global) SUBROUTINE myarg_helper(argin,argout)
IMPLICIT NONE
REAL,VALUE :: argin
REAL,DEVICE :: temp
REAL,DEVICE :: argout(1)
temp = argin
argout(1) = myarg(temp)
END SUBROUTINE myarg_helper
c === ==================================================================
end module gpufunc
c === ==================================================================
c === ==================================================================
program fcuda
use gpufunc
implicit none
real :: argin
real,device :: argout(1)
real :: temp
argin = 1.0
call myarg_helper<<<1,1>>>(argin,argout)
temp = argout(1)
print *,argin
print *,temp
end program fcuda
Without “-fast”, I get 1.0 and -1.0, as expected. With “-fast”, I get 1.0 and 0.0 ! I appreciate any help!
Thanks,
Todd