Device or host arguments to magmablas_zgemm_batched

26 views
Skip to first unread message

Wileam Phan

unread,
Aug 3, 2020, 3:04:39 PM8/3/20
to MAGMA User
Hi everyone,

I'm using MAGMA with Fortran code and OpenACC (with PGI compiler). So far I have only the array of matrices on device. I have the following wrapper to the MAGMA v2 interface (adapted from the example one in fortran subdirectory in the source code):

INTERFACE
  SUBROUTINE magmablas_zgemm_batched( opA, opB, m, n, k, alpha, dptr_A, ldda, dptr_B, lddb, beta, dptr_C, lddc, batchCount, queue) BIND(C, NAME='magmablas_zgemm_batched')
    USE ISO_C_BINDING
    INTEGER(C_INT), VALUE :: opA, opB, m, n, k, ldda, lddb, lddc
    COMPLEX(C_DOUBLE_COMPLEX), VALUE :: alpha, beta
    TYPE(C_PTR), DIMENSION(batchCount) :: dptr_A, dptr_B, dptr_C
    TYPE(C_PTR), VALUE :: queue
  END SUBROUTINE
END INTERFACE

opA = magma_trans_const( 'N' )
opB = magma_trans_const( 'N' )

!$ACC DATA PRESENT(matA, matB, matC)
!$ACC HOST_DATA USE_DEVICE(matA, matB, matC)

DO ibatch = 1, batchCount
  dptr_A(ibatch) = C_LOC( matA(1,1,ibatch) )
  dptr_B(ibatch) = C_LOC( matB(1,1,ibatch) )
  dptr_C(ibatch) = C_LOC( matC(1,1,ibatch) )
END DO

CALL magmablas_zgemm_batched( opA, opB, m, n, k, alpha, dptr_A, ldda, dptr_B, lddb, beta, dptr_C, lddc, batchCount, queue )

!$ACC END HOST_DATA
!$ACC END DATA

If I use managed memory (-ta=tesla:managed) the code executes successfully.
If I don't use managed memory and run it through cuda-gdb, I get CUDA_EXCEPTION_14, Warp illegal address, which suggests that one of the arguments need to be on device, instead of on host?

Thanks,
Wileam Y. Phan

Ahmad Abdelfattah

unread,
Aug 3, 2020, 4:17:26 PM8/3/20
to Wileam Phan, MAGMA User
The pointer arrays of all the magma batch routines must be on device memory.

Ahmad


--
You received this message because you are subscribed to the Google Groups "MAGMA User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to magma-user+...@icl.utk.edu.
To view this discussion on the web visit https://groups.google.com/a/icl.utk.edu/d/msgid/magma-user/f3d14c86-152e-4eaa-98c2-1fd12b709d53n%40icl.utk.edu.

Wileam Phan

unread,
Aug 4, 2020, 9:50:04 AM8/4/20
to MAGMA User, ah...@icl.utk.edu, MAGMA User, Wileam Phan
Hi Ahmad,

Thanks, I've now exposed their device pointer addresses using !$ACC HOST_DATA USE_DATA(matA, matB, matC, dptr_A, dptr_B, dptr_C) after filling in the pointer arrays.
What about alpha and beta? Should they reside on host, or on device?

Thanks,
Wileam Y. Phan

Ahmad Abdelfattah

unread,
Aug 4, 2020, 10:27:14 AM8/4/20
to Wileam Phan, MAGMA User
alpha and beta are scalars, not arrays. They should be on host memory. 

Ahmad

Wileam Phan

unread,
Aug 4, 2020, 10:32:27 AM8/4/20
to MAGMA User, ah...@icl.utk.edu, MAGMA User, Wileam Phan
Hi Ahmad,

Ah, I see. I guess this is where MAGMA differs from cuBLAS, where alpha and beta can be either on host or device. I wish this would be made clearer in the documentation.

Thanks a lot,
Wileam Y. Phan

Reply all
Reply to author
Forward
0 new messages