acc_hostmem_alloc_c4_2D Subroutine

private subroutine acc_hostmem_alloc_c4_2D(host_mem, n1, n2, stream)

Allocates 2D fortan-array as GPU host-pinned memory.

Arguments

Type IntentOptional Attributes Name
complex(kind=real_4), DIMENSION(:, :), POINTER :: host_mem

pointer to array

integer, intent(in) :: n1

sizes given in terms of item-count (not bytes!) sizes given in terms of item-count (not bytes!)

integer, intent(in) :: n2

sizes given in terms of item-count (not bytes!) sizes given in terms of item-count (not bytes!)

type(acc_stream_type), intent(in) :: stream

Source Code

      SUBROUTINE acc_hostmem_alloc_c4_2D(host_mem, n1, n2, stream)
      !! Allocates 2D fortan-array as GPU host-pinned memory.

         COMPLEX(kind=real_4), DIMENSION(:, :), POINTER        :: host_mem
         !! pointer to array
         INTEGER, INTENT(IN)                      :: n1, n2
         !! sizes given in terms of item-count (not bytes!)
         !! sizes given in terms of item-count (not bytes!)
         TYPE(acc_stream_type), INTENT(IN)        :: stream
#if defined (__DBCSR_ACC)
         TYPE(C_PTR)                              :: host_mem_c_ptr
         INTEGER(KIND=C_SIZE_T)                   :: n_bytes

         n_bytes = INT(2*real_4_size, KIND=C_SIZE_T)* &
                   INT(MAX(1, n1), KIND=C_SIZE_T)*INT(MAX(1, n2), KIND=C_SIZE_T)
         CALL acc_hostmem_alloc_raw(host_mem_c_ptr, n_bytes, stream)
         CALL C_F_POINTER(host_mem_c_ptr, host_mem, (/MAX(1, n1), MAX(1, n2)/))
#else
         MARK_USED(host_mem)
         MARK_USED(n1)
         MARK_USED(n2)
         MARK_USED(stream)
         DBCSR_ABORT("acc_hostmem_alloc_c4_2D: ACC not compiled in.")
#endif
      END SUBROUTINE acc_hostmem_alloc_c4_2D