acc_devmem_setzero_bytes Subroutine

public subroutine acc_devmem_setzero_bytes(this, first_byte, last_byte, stream)

Sets entries in given devmem to zero, asynchronously.

Arguments

Type IntentOptional Attributes Name
type(acc_devmem_type), intent(inout) :: this
integer, intent(in), optional :: first_byte

begin of region to zero, defaults to 1 if not given. end of region to zero, defaults to size if not given.

integer, intent(in), optional :: last_byte

begin of region to zero, defaults to 1 if not given. end of region to zero, defaults to size if not given.

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

stream on which zeroing is performed.


Source Code

   SUBROUTINE acc_devmem_setzero_bytes(this, first_byte, last_byte, stream)
      !! Sets entries in given devmem to zero, asynchronously.

      TYPE(acc_devmem_type), INTENT(INOUT) :: this
      INTEGER, INTENT(IN), OPTIONAL        :: first_byte, last_byte
         !! begin of region to zero, defaults to 1 if not given.
         !! end of region to zero, defaults to size if not given.
      TYPE(acc_stream_type), INTENT(IN)    :: stream
         !! stream on which zeroing is performed.

#if ! defined (__DBCSR_ACC)
      MARK_USED(this)
      MARK_USED(first_byte)
      MARK_USED(last_byte)
      MARK_USED(stream)
      DBCSR_ABORT("__DBCSR_ACC not compiled in.")
#else
      INTEGER                                  :: istat
      INTEGER(KIND=C_SIZE_T)                   :: length, offset
      TYPE(C_PTR)                              :: stream_cptr

      offset = 0
      length = this%size_in_bytes
      IF (PRESENT(first_byte)) THEN
         offset = first_byte - 1
         length = length - offset
      END IF
      IF (PRESENT(last_byte)) THEN
         length = last_byte
         IF (PRESENT(first_byte)) length = length - first_byte
      END IF

      stream_cptr = acc_stream_cptr(stream)

      IF (length > 0) THEN
         CALL dbcsr_acc_set_active_device(get_accdrv_active_device_id())
         istat = acc_interface_memzero(this%cptr, offset, length, stream_cptr)
         IF (istat /= 0) &
            DBCSR_ABORT("acc_devmem_setzero: failed")
      END IF
#endif
   END SUBROUTINE acc_devmem_setzero_bytes