copyout Memcpy error

Hello, I’m trying to port some combustion fluid dynamics code to the GPU. This functions which calculates the temperature of each specie gives me and error.
0: copyout Memcpy (host=0x1e1ced0, dev=0x2300200000, size=800) FAILED: 4(unspecified launch failure)


attributes(device) subroutine theta_d(F,enth_d,temp_d,rho_d)

! Calculates temperature and density
! given the species composition
! and enthalpy of the mixture

! *** Declarations ************************************************

use chem_mod_d
implicit none
! argumensts******************
double precision :: enth_d
double precision, dimension(53) :: F
double precision :: temp_d
double precision :: rho_d
! local_variables**************

integer iter,k,j,NSP,NT,i
double precision FUN,FUNP,C1,DTEMP,SUMN,T_init,caca

! *****************************************************************
N_sp=53
N_r=325
NSP =53
SUMN = sum(F)

! CALCULATE TEMPERATURE
!
TEMP_d=300.0D0
ITER=0
30 ITER=ITER+1
IF(ITER.GT.500) THEN
!! WRITE(,) ’ SUBROUTINE THETA : ITERATION COUNT EXCEEDED’
!! WRITE(,) (F(i),i=1,NSP)
!! WRITE(,)
!! iflag = 0
goto 100
!! STOP
END IF
IF(TEMP_d.GT.1000.0D0) THEN
NT=1
ELSE
NT=2
END IF
FUN=-ENTH_d/GASCON_d
FUNP=0.0D0
DO J=1,NSP
FUN=FUN+COEF(NT,6,J)F(J)
END DO
DO K=1,5
C1=0.0D0
DO J=1,NSP
C1=C1+COEF(NT,K,J)F(J)
END DO
FUN=FUN+C1/REAL(K)TEMP_d**K
FUNP=FUNP+C1
TEMP_d**(K-1)
END DO
DTEMP=-FUN/FUNP
TEMP_d=TEMP_d+DTEMP
IF(ABS(DTEMP).GT.1.0D-03.OR.ITER.EQ.1) GO TO 30
!
!! CALCULATE DENSITY
RHO_d=PRESS_d/(GASCON_d
TEMP_d
SUMN)

100 continue
!
end subroutine theta_d
But if I comment the line

IF(ABS(DTEMP).GT.1.0D-03.OR.ITER.EQ.1) GO TO 30

this error dissapears. I have no clue that what happens.

Thanks

ElMaskina,

The actual error just means that the kernel preceding the memcpy crashed for some reason. Not very helpful.

Given that it works when you remove the while loop conditional, this suggests that the kernel crashes either because of something in the loop after the first iteration or the value of TEMP_d is bad.

What I’d do is compile the code in emulation mode (-Mcuda=emu -g) and see if you can reproduce the error in the debugger.

If not, the next step is to put in “print *” statements to isolate exactly where it’s crashing.

  • Mat

Thanks, It is solved now. It was a problem with the coeff array which was no well defined