41 use,
intrinsic :: iso_c_binding
46 real(kind=
rp),
allocatable :: x(:,:,:,:)
47 character(len=NEKO_VARNAME_LEN) :: name =
""
48 type(c_ptr) :: x_d = c_null_ptr
49 integer,
private :: n1 = 0
50 integer,
private :: n2 = 0
51 integer,
private :: n3 = 0
52 integer,
private :: n4 = 0
53 integer,
private :: n = 0
62 generic :: init => init_dims
111 integer,
intent(in) :: n1
112 integer,
intent(in) :: n2
113 integer,
intent(in) :: n3
114 integer,
intent(in) :: n4
115 character(len=*),
intent(in),
optional :: name
122 call t%alloc(n1, n2, n3, n4)
124 if (
present(name))
then
138 integer,
intent(in) :: n1
139 integer,
intent(in) :: n2
140 integer,
intent(in) :: n3
141 integer,
intent(in) :: n4
145 allocate(t%x(n1, n2, n3, n4))
157 call cfill(t%x, 0.0_rp, t%n)
166 if (
allocated(t%x))
then
196 integer,
intent(in) :: memdir
197 logical,
intent(in) :: sync
242 dims = [t%n1, t%n2, t%n3, t%n4]
252 if (
allocated(t%x))
then
256 if (.not.
allocated(t%x))
then
263 allocate(t%x(t%n1, t%n2, t%n3, t%n4))
286 real(kind=
rp),
intent(in) :: s
288 if (.not.
allocated(t%x))
then
308 type(
tensor4_t),
target,
intent(in) :: ptr
319 if (
associated(this%ptr))
then
Map a Fortran array to a device (allocate and associate)
Copy data between host and device (or device and device)
Synchronize a device or stream.
Unmap a Fortran array from a device (deassociate and free)
subroutine, public device_copy(a_d, b_d, n, strm)
Copy a vector .
subroutine, public device_cfill(a_d, c, n, strm)
Set all elements to a constant c .
Device abstraction, common interface for various accelerators.
subroutine, public cfill(a, c, n)
Set all elements to a constant c .
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
subroutine tensor4_ptr_free(this)
Destructor. Just nullifies the pointer.
subroutine tensor4_copy_from(t, memdir, sync)
Easy way to copy between host and device.
pure integer function, dimension(4) tensor4_get_dims(t)
Returns the dimensions of the tensor.
pure integer function tensor4_size(t)
Returns the number of entries in the tensor.
subroutine tensor4_init(t, n1, n2, n3, n4, name)
Initialise a tensor of size n1*n2*n3*n4.
subroutine tensor4_allocate(t, n1, n2, n3, n4)
Allocate a tensor of size n1*n2*n3*n4.
subroutine tensor4_free(t)
Deallocate a tensor.
pure integer function tensor4_n3(t)
Returns the size of the third dimension.
subroutine tensor4_ptr_init(this, ptr)
Constructor. Just assigns the pointer.
pure integer function tensor4_n4(t)
Returns the size of the fourth dimension.
pure integer function tensor4_n2(t)
Returns the size of the second dimension.
pure integer function tensor4_n1(t)
Returns the size of the first dimension.
subroutine tensor4_assign_tensor4(t, w)
Assignment .
subroutine tensor4_assign_scalar(t, s)
Assignment .
integer, parameter, public neko_varname_len