acc_devmem_set_cptr Subroutine

public subroutine acc_devmem_set_cptr(this, pointee, size_in_bytes, lb_in_bytes)

Allocates a given devmem.

Arguments

Type IntentOptional Attributes Name
type(acc_devmem_type), intent(inout) :: this
type(acc_devmem_type), intent(in) :: pointee
integer, intent(in) :: size_in_bytes
integer, intent(in) :: lb_in_bytes

Source Code

   SUBROUTINE acc_devmem_set_cptr(this, pointee, size_in_bytes, lb_in_bytes)
      !! Allocates a given devmem.

      TYPE(acc_devmem_type), INTENT(INOUT)     :: this
      TYPE(acc_devmem_type), INTENT(IN)        :: pointee
      INTEGER, INTENT(IN)                      :: size_in_bytes, lb_in_bytes

#if ! defined (__DBCSR_ACC)
      MARK_USED(this)
      MARK_USED(pointee)
      MARK_USED(size_in_bytes)
      MARK_USED(lb_in_bytes)
      DBCSR_ABORT("__DBCSR_ACC not compiled in.")
#else

      INTEGER                                  :: istat

      IF (this%size_in_bytes >= 0) &
         DBCSR_ABORT("acc_devmem_set_cptr: already allocated")
      IF (pointee%size_in_bytes < 0 .AND. size_in_bytes > 0) &
         DBCSR_ABORT("acc_devmem_set_cptr: out-of-bounds")
      IF (size_in_bytes > 0) THEN
         IF ((lb_in_bytes + size_in_bytes) .GT. pointee%size_in_bytes) &
            DBCSR_ABORT("acc_devmem_set_cptr: out-of-bounds")
         this%size_in_bytes = size_in_bytes
         istat = acc_interface_dev_mem_set_ptr(this%cptr, pointee%cptr, INT(lb_in_bytes, KIND=C_SIZE_T))
      ELSE
         ! Empty buffers
         this%size_in_bytes = pointee%size_in_bytes
         this%cptr = pointee%cptr
      END IF
#endif
   END SUBROUTINE acc_devmem_set_cptr