dbcsr_data_host2dev Subroutine

public subroutine dbcsr_data_host2dev(area)

Transfers data from host- to device-buffer, asynchronously.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_data_obj), intent(inout) :: area

Source Code

   SUBROUTINE dbcsr_data_host2dev(area)
      !! Transfers data from host- to device-buffer, asynchronously.
      TYPE(dbcsr_data_obj), INTENT(INOUT)                :: area

      COMPLEX(KIND=real_4), DIMENSION(:), POINTER        :: c_sp
      COMPLEX(KIND=real_8), DIMENSION(:), POINTER        :: c_dp
      INTEGER(KIND=int_4), DIMENSION(:), POINTER         :: i4
      INTEGER(KIND=int_8), DIMENSION(:), POINTER         :: i8
      REAL(KIND=real_4), DIMENSION(:), POINTER           :: r_sp
      REAL(KIND=real_8), DIMENSION(:), POINTER           :: r_dp

      IF (.NOT. acc_devmem_allocated(area%d%acc_devmem)) RETURN !nothing to do
      IF (area%d%ref_size == 0) RETURN !nothing to do

      SELECT CASE (area%d%data_type)
      CASE (dbcsr_type_int_4)
         i4 => area%d%i4(:area%d%ref_size)
         CALL acc_devmem_host2dev(area%d%acc_devmem, hostmem=i4, stream=area%d%memory_type%acc_stream)
      CASE (dbcsr_type_int_8)
         i8 => area%d%i8(:area%d%ref_size)
         CALL acc_devmem_host2dev(area%d%acc_devmem, hostmem=i8, stream=area%d%memory_type%acc_stream)
      CASE (dbcsr_type_real_4)
         r_sp => area%d%r_sp(:area%d%ref_size)
         CALL acc_devmem_host2dev(area%d%acc_devmem, hostmem=r_sp, stream=area%d%memory_type%acc_stream)
      CASE (dbcsr_type_real_8)
         r_dp => area%d%r_dp(:area%d%ref_size)
         CALL acc_devmem_host2dev(area%d%acc_devmem, hostmem=r_dp, stream=area%d%memory_type%acc_stream)
      CASE (dbcsr_type_complex_4)
         c_sp => area%d%c_sp(:area%d%ref_size)
         CALL acc_devmem_host2dev(area%d%acc_devmem, hostmem=c_sp, stream=area%d%memory_type%acc_stream)
      CASE (dbcsr_type_complex_8)
         c_dp => area%d%c_dp(:area%d%ref_size)
         CALL acc_devmem_host2dev(area%d%acc_devmem, hostmem=c_dp, stream=area%d%memory_type%acc_stream)
      CASE default
         DBCSR_ABORT("Invalid data type.")
      END SELECT

      CALL acc_event_record(area%d%acc_ready, area%d%memory_type%acc_stream)
   END SUBROUTINE dbcsr_data_host2dev