40 use,
intrinsic :: iso_c_binding, only : c_ptr, c_null_ptr, c_size_t, &
49 type(c_ptr) :: x_d = c_null_ptr
51 integer,
private :: n = 0
67 generic ::
assignment(=) => assign
77 integer,
intent(in) :: size
80 call neko_error(
'Device array cannot be initialized when ' // &
81 'NEKO_BCKND_DEVICE is not set to 1')
85 call this%allocate(size)
96 if (c_associated(this%x_d))
call device_free(this%x_d)
105 integer,
intent(in) :: size
106 integer(c_size_t) :: c_size
111 c_size =
size * int(4, c_size_t)
113 c_size =
size * int(8, c_size_t)
128 if (.not. source%is_allocated())
then
131 else if (source%size() .ne. this%size())
then
133 call this%allocate(source%size())
154 is_alloc = c_associated(this%x_d)
Module containing device only array type.
pure integer function device_array_size(this)
Return the size of the device array.
subroutine device_array_assign(this, source)
Assignment with deep-copy ownership semantics.
subroutine device_array_init(this, size)
Initialize a device array of size size.
subroutine device_array_free(this)
Free a device array.
subroutine device_array_allocate(this, size)
Allocate a device array (used by init and assignment).
pure logical function device_array_is_allocated(this)
Check whether the device array is allocated.
subroutine, public device_rzero(a_d, n, strm)
Zero a real vector.
subroutine, public device_copy(a_d, b_d, n, strm)
Copy a vector .
Device abstraction, common interface for various accelerators.
subroutine, public device_free(x_d)
Deallocate memory on the device.
subroutine, public device_alloc(x_d, s)
Allocate memory on the device.
integer, parameter neko_bcknd_device
integer, parameter, public dp
integer, parameter, public sp
integer, parameter, public rp
Global precision used in computations.
Device-only temporary array.