Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
device Module Reference

Device abstraction, common interface for various accelerators.

Data Types

interface  device_associate
 Associate a Fortran array to a (allocated) device pointer. More...
 
interface  device_associated
 Check if a Fortran array is assoicated with a device pointer. More...
 
interface  device_deassociate
 Deassociate a Fortran array from a device pointer. More...
 
interface  device_get_ptr
 Return the device pointer for an associated Fortran array. More...
 
interface  device_map
 Map a Fortran array to a device (allocate and associate) More...
 
interface  device_memcpy
 Copy data between host and device (or device and device) More...
 
interface  device_sync
 Synchronize a device or stream. More...
 
interface  device_unmap
 Unmap a Fortran array from a device (deassociate and free) More...
 

Functions/Subroutines

subroutine, public device_init
 
subroutine, public device_finalize
 
subroutine, public device_name (name)
 
integer function, public device_count ()
 Return the number of available devices.
 
integer function, public device_mp_count ()
 Return the number of multiprocessors (SMs on NVIDIA, CUs on AMD, compute units on OpenCL, GPU cores on Apple Silicon) of the current device, or 0 if the backend cannot tell.
 
integer(kind=i8) function, public device_total_mem ()
 Return the total memory of the current device in bytes, or 0 if the backend cannot tell.
 
subroutine, public device_alloc (x_d, s)
 Allocate memory on the device.
 
subroutine, public device_free (x_d)
 Deallocate memory on the device.
 
subroutine, public device_memset (x_d, v, s, sync, strm)
 Set memory on the device to a value.
 
subroutine device_memcpy_r1 (x, x_d, n, dir, sync, strm)
 Copy data between host and device (rank 1 arrays)
 
subroutine device_memcpy_r2 (x, x_d, n, dir, sync, strm)
 Copy data between host and device (rank 2 arrays)
 
subroutine device_memcpy_r3 (x, x_d, n, dir, sync, strm)
 Copy data between host and device (rank 3 arrays)
 
subroutine device_memcpy_r4 (x, x_d, n, dir, sync, strm)
 Copy data between host and device (rank 4 arrays)
 
subroutine device_memcpy_cptr (dst, src, s, dir, sync, strm)
 Copy data between host and device (or device and device) (c-pointers)
 
subroutine device_memcpy_common (ptr_h, x_d, s, dir, sync_device, stream)
 Copy data between host and device.
 
subroutine device_associate_r1 (x, x_d, n)
 Associate a Fortran rank 1 array to a (allocated) device pointer.
 
subroutine device_associate_r2 (x, x_d, n)
 Associate a Fortran rank 2 array to a (allocated) device pointer.
 
subroutine device_associate_r3 (x, x_d, n)
 Associate a Fortran rank 3 array to a (allocated) device pointer.
 
subroutine device_associate_r4 (x, x_d, n)
 Associate a Fortran rank 4 array to a (allocated) device pointer.
 
subroutine device_deassociate_r1 (x)
 Deassociate a Fortran rank 1 array from a device pointer.
 
subroutine device_deassociate_r2 (x)
 Deassociate a Fortran rank 2 array from a device pointer.
 
subroutine device_deassociate_r3 (x)
 Deassociate a Fortran rank 3 array from a device pointer.
 
subroutine device_deassociate_r4 (x)
 Deassociate a Fortran rank 4 array from a device pointer.
 
subroutine device_map_common (ptr_h, x_d, s)
 Allocate device memory backing a mapped host array.
 
subroutine device_map_r1 (x, x_d, n)
 Map a Fortran rank 1 array to a device (allocate and associate)
 
subroutine device_map_r2 (x, x_d, n)
 Map a Fortran rank 2 array to a device (allocate and associate)
 
subroutine device_map_r3 (x, x_d, n)
 Map a Fortran rank 3 array to a device (allocate and associate)
 
subroutine device_map_r4 (x, x_d, n)
 Map a Fortran rank 4 array to a device (allocate and associate)
 
subroutine device_unmap_r1 (x, x_d)
 Unmap a Fortran rank 1 array from a device (deassociate and free)
 
subroutine device_unmap_r2 (x, x_d)
 Unmap a Fortran rank 2 array from a device (deassociate and free)
 
subroutine device_unmap_r3 (x, x_d)
 Unmap a Fortran rank 3 array from a device (deassociate and free)
 
subroutine device_unmap_r4 (x, x_d)
 Unmap a Fortran rank 4 array from a device (deassociate and free)
 
logical function device_associated_r1 (x)
 Check if a Fortran rank 1 array is assoicated with a device pointer.
 
logical function device_associated_r2 (x)
 Check if a Fortran rank 2 array is assoicated with a device pointer.
 
logical function device_associated_r3 (x)
 Check if a Fortran rank 3 array is assoicated with a device pointer.
 
logical function device_associated_r4 (x)
 Check if a Fortran rank 4 array is assoicated with a device pointer.
 
type(c_ptr) function device_get_ptr_r1 (x)
 Return the device pointer for an associated Fortran rank 1 array.
 
type(c_ptr) function device_get_ptr_r2 (x)
 Return the device pointer for an associated Fortran rank 2 array.
 
type(c_ptr) function device_get_ptr_r3 (x)
 Return the device pointer for an associated Fortran rank 3 array.
 
type(c_ptr) function device_get_ptr_r4 (x)
 Return the device pointer for an associated Fortran rank 4 array.
 
subroutine device_sync_device ()
 Synchronize the device.
 
subroutine, public device_sync_stream (stream)
 Synchronize a device stream.
 
subroutine, public device_stream_create (stream, flags)
 Create a device stream/command queue.
 
subroutine, public device_stream_create_with_priority (stream, flags, prio)
 Create a device stream/command queue with priority.
 
subroutine, public device_stream_destroy (stream)
 Destroy a device stream/command queue.
 
subroutine, public device_stream_wait_event (stream, event, flags)
 Synchronize a device stream with an event.
 
subroutine, public device_profiler_start ()
 Start device profiling.
 
subroutine, public device_profiler_stop ()
 Stop device profiling.
 
subroutine, public device_event_create (event, flags)
 Create a device event queue.
 
subroutine, public device_event_destroy (event)
 Destroy a device event.
 
subroutine, public device_event_record (event, stream)
 Record a device event.
 
subroutine, public device_event_sync (event)
 Synchronize an event.
 

Variables

integer, parameter, public host_to_device = 1
 
integer, parameter, public device_to_host = 2
 
integer, parameter, public device_to_device = 3
 
type(c_ptr), bind(C), public glb_cmd_queue = C_NULL_PTR
 Global command queue.
 
type(c_ptr), bind(C), public aux_cmd_queue = C_NULL_PTR
 Aux command queue.
 
type(c_ptr), bind(C), public prf_cmd_queue = C_NULL_PTR
 Profiling command queue.
 
type(c_ptr), bind(C), public glb_cmd_event
 Event for the global command queue.
 
integer, public strm_high_prio
 High priority stream setting.
 
integer, public strm_low_prio
 Low priority stream setting.
 
type(htable_cptr_t) device_addrtbl
 Table of host to device address mappings.
 

Function/Subroutine Documentation

◆ device_alloc()

subroutine, public device::device_alloc ( type(c_ptr), intent(inout)  x_d,
integer(c_size_t)  s 
)

Definition at line 249 of file device.F90.

Here is the caller graph for this function:

◆ device_associate_r1()

subroutine device::device_associate_r1 ( class(*), dimension(:), intent(inout), target  x,
type(c_ptr), intent(inout)  x_d,
integer, intent(in), optional  n 
)
private

Definition at line 675 of file device.F90.

◆ device_associate_r2()

subroutine device::device_associate_r2 ( class(*), dimension(:,:), intent(inout), target  x,
type(c_ptr), intent(inout)  x_d,
integer, intent(in), optional  n 
)
private

Definition at line 712 of file device.F90.

◆ device_associate_r3()

subroutine device::device_associate_r3 ( class(*), dimension(:,:,:), intent(inout), target  x,
type(c_ptr), intent(inout)  x_d,
integer, intent(in), optional  n 
)
private

Definition at line 749 of file device.F90.

◆ device_associate_r4()

subroutine device::device_associate_r4 ( class(*), dimension(:,:,:,:), intent(inout), target  x,
type(c_ptr), intent(inout)  x_d,
integer, intent(in), optional  n 
)
private

Definition at line 785 of file device.F90.

◆ device_associated_r1()

logical function device::device_associated_r1 ( class(*), dimension(:), intent(inout), target  x)
private

Definition at line 1237 of file device.F90.

◆ device_associated_r2()

logical function device::device_associated_r2 ( class(*), dimension(:,:), intent(inout), target  x)
private

Definition at line 1264 of file device.F90.

◆ device_associated_r3()

logical function device::device_associated_r3 ( class(*), dimension(:,:,:), intent(inout), target  x)
private

Definition at line 1291 of file device.F90.

◆ device_associated_r4()

logical function device::device_associated_r4 ( class(*), dimension(:,:,:,:), intent(inout), target  x)
private

Definition at line 1318 of file device.F90.

◆ device_count()

integer function, public device::device_count

Definition at line 197 of file device.F90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_deassociate_r1()

subroutine device::device_deassociate_r1 ( class(*), dimension(:), intent(inout), target  x)
private

Definition at line 822 of file device.F90.

◆ device_deassociate_r2()

subroutine device::device_deassociate_r2 ( class(*), dimension(:,:), intent(inout), target  x)
private

Definition at line 846 of file device.F90.

◆ device_deassociate_r3()

subroutine device::device_deassociate_r3 ( class(*), dimension(:,:,:), intent(inout), target  x)
private

Definition at line 870 of file device.F90.

◆ device_deassociate_r4()

subroutine device::device_deassociate_r4 ( class(*), dimension(:,:,:,:), intent(inout), target  x)
private

Definition at line 894 of file device.F90.

◆ device_event_create()

subroutine, public device::device_event_create ( type(c_ptr), intent(inout)  event,
integer, optional  flags 
)

Definition at line 1626 of file device.F90.

Here is the caller graph for this function:

◆ device_event_destroy()

subroutine, public device::device_event_destroy ( type(c_ptr), intent(inout)  event)

Definition at line 1660 of file device.F90.

Here is the caller graph for this function:

◆ device_event_record()

subroutine, public device::device_event_record ( type(c_ptr), intent(in), target  event,
type(c_ptr), intent(in)  stream 
)

Definition at line 1681 of file device.F90.

Here is the caller graph for this function:

◆ device_event_sync()

subroutine, public device::device_event_sync ( type(c_ptr), intent(in), target  event)

Definition at line 1704 of file device.F90.

Here is the caller graph for this function:

◆ device_finalize()

subroutine, public device::device_finalize

Definition at line 163 of file device.F90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_free()

subroutine, public device::device_free ( type(c_ptr), intent(inout)  x_d)

Definition at line 280 of file device.F90.

Here is the caller graph for this function:

◆ device_get_ptr_r1()

type(c_ptr) function device::device_get_ptr_r1 ( class(*), dimension(:), intent(in), target  x)
private

Definition at line 1345 of file device.F90.

Here is the caller graph for this function:

◆ device_get_ptr_r2()

type(c_ptr) function device::device_get_ptr_r2 ( class(*), dimension(:,:), intent(in), target  x)
private

Definition at line 1373 of file device.F90.

Here is the caller graph for this function:

◆ device_get_ptr_r3()

type(c_ptr) function device::device_get_ptr_r3 ( class(*), dimension(:,:,:), intent(in), target  x)
private

Definition at line 1401 of file device.F90.

Here is the caller graph for this function:

◆ device_get_ptr_r4()

type(c_ptr) function device::device_get_ptr_r4 ( class(*), dimension(:,:,:,:), intent(in), target  x)
private

Definition at line 1429 of file device.F90.

Here is the caller graph for this function:

◆ device_init()

subroutine, public device::device_init

Definition at line 138 of file device.F90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_map_common()

subroutine device::device_map_common ( type(c_ptr), intent(in)  ptr_h,
type(c_ptr), intent(inout)  x_d,
integer(c_size_t), intent(in)  s 
)
private
Note
On unified memory architectures (Metal) the device pointer aliases the host array whenever possible, such that host and device share a single allocation instead of replicating data

Definition at line 921 of file device.F90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_map_r1()

subroutine device::device_map_r1 ( class(*), dimension(:), intent(inout), target  x,
type(c_ptr), intent(inout)  x_d,
integer, intent(in)  n 
)
private

Definition at line 953 of file device.F90.

◆ device_map_r2()

subroutine device::device_map_r2 ( class(*), dimension(:,:), intent(inout), target  x,
type(c_ptr), intent(inout)  x_d,
integer, intent(in)  n 
)
private

Definition at line 987 of file device.F90.

◆ device_map_r3()

subroutine device::device_map_r3 ( class(*), dimension(:,:,:), intent(inout), target  x,
type(c_ptr), intent(inout)  x_d,
integer, intent(in)  n 
)
private

Definition at line 1021 of file device.F90.

◆ device_map_r4()

subroutine device::device_map_r4 ( class(*), dimension(:,:,:,:), intent(inout), target  x,
type(c_ptr), intent(inout)  x_d,
integer, intent(in)  n 
)
private

Definition at line 1055 of file device.F90.

◆ device_memcpy_common()

subroutine device::device_memcpy_common ( type(c_ptr), intent(inout)  ptr_h,
type(c_ptr), intent(inout)  x_d,
integer(c_size_t), intent(in)  s,
integer, intent(in), value  dir,
logical, intent(in)  sync_device,
type(c_ptr), intent(inout)  stream 
)
private
Note
For device to device copies, ptr_h is assumed to be the dst device pointer

Definition at line 537 of file device.F90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_memcpy_cptr()

subroutine device::device_memcpy_cptr ( type(c_ptr), intent(inout)  dst,
type(c_ptr), intent(inout)  src,
integer(c_size_t), intent(in)  s,
integer, intent(in), value  dir,
logical, optional  sync,
type(c_ptr), optional  strm 
)
private
Note
For host-device copies dst is the host pointer and src is the device pointer (regardless of dir)

Definition at line 508 of file device.F90.

◆ device_memcpy_r1()

subroutine device::device_memcpy_r1 ( class(*), dimension(:), intent(inout), target  x,
type(c_ptr), intent(inout)  x_d,
integer, intent(in)  n,
integer, intent(in), value  dir,
logical  sync,
type(c_ptr), optional  strm 
)
private

Definition at line 354 of file device.F90.

◆ device_memcpy_r2()

subroutine device::device_memcpy_r2 ( class(*), dimension(:,:), intent(inout), target  x,
type(c_ptr), intent(inout)  x_d,
integer, intent(in)  n,
integer, intent(in), value  dir,
logical  sync,
type(c_ptr), optional  strm 
)
private

Definition at line 392 of file device.F90.

◆ device_memcpy_r3()

subroutine device::device_memcpy_r3 ( class(*), dimension(:,:,:), intent(inout), target  x,
type(c_ptr), intent(inout)  x_d,
integer, intent(in)  n,
integer, intent(in), value  dir,
logical  sync,
type(c_ptr), optional  strm 
)
private

Definition at line 430 of file device.F90.

◆ device_memcpy_r4()

subroutine device::device_memcpy_r4 ( class(*), dimension(:,:,:,:), intent(inout), target  x,
type(c_ptr), intent(inout)  x_d,
integer, intent(in)  n,
integer, intent(in), value  dir,
logical  sync,
type(c_ptr), optional  strm 
)
private

Definition at line 468 of file device.F90.

◆ device_memset()

subroutine, public device::device_memset ( type(c_ptr), intent(inout)  x_d,
integer(c_int), target, value  v,
integer(c_size_t), intent(in)  s,
logical, optional  sync,
type(c_ptr), optional  strm 
)

Definition at line 305 of file device.F90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_mp_count()

integer function, public device::device_mp_count
Note
Used to size work decompositions so that every launch fills the device with complete waves of blocks.

Definition at line 216 of file device.F90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_name()

subroutine, public device::device_name ( character(len=*), intent(inout)  name)

Definition at line 182 of file device.F90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_profiler_start()

subroutine, public device::device_profiler_start

Definition at line 1608 of file device.F90.

Here is the caller graph for this function:

◆ device_profiler_stop()

subroutine, public device::device_profiler_stop

Definition at line 1617 of file device.F90.

Here is the caller graph for this function:

◆ device_stream_create()

subroutine, public device::device_stream_create ( type(c_ptr), intent(inout)  stream,
integer, optional  flags 
)

Definition at line 1500 of file device.F90.

◆ device_stream_create_with_priority()

subroutine, public device::device_stream_create_with_priority ( type(c_ptr), intent(inout)  stream,
integer, intent(in)  flags,
integer, intent(in)  prio 
)

Definition at line 1537 of file device.F90.

Here is the caller graph for this function:

◆ device_stream_destroy()

subroutine, public device::device_stream_destroy ( type(c_ptr), intent(inout)  stream)

Definition at line 1559 of file device.F90.

Here is the caller graph for this function:

◆ device_stream_wait_event()

subroutine, public device::device_stream_wait_event ( type(c_ptr), intent(in)  stream,
type(c_ptr), intent(in), target  event,
integer  flags 
)

Definition at line 1581 of file device.F90.

Here is the caller graph for this function:

◆ device_sync_device()

subroutine device::device_sync_device
private

Definition at line 1457 of file device.F90.

◆ device_sync_stream()

subroutine, public device::device_sync_stream ( type(c_ptr), intent(in)  stream)

Definition at line 1478 of file device.F90.

Here is the caller graph for this function:

◆ device_total_mem()

integer(kind=i8) function, public device::device_total_mem
Note
On Metal (unified memory) this is the recommended maximum working set rather than physical memory.

Definition at line 234 of file device.F90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ device_unmap_r1()

subroutine device::device_unmap_r1 ( class(*), dimension(:), intent(inout), target  x,
type(c_ptr), intent(inout)  x_d 
)
private

Definition at line 1089 of file device.F90.

◆ device_unmap_r2()

subroutine device::device_unmap_r2 ( class(*), dimension(:,:), intent(inout), target  x,
type(c_ptr), intent(inout)  x_d 
)
private

Definition at line 1126 of file device.F90.

◆ device_unmap_r3()

subroutine device::device_unmap_r3 ( class(*), dimension(:,:,:), intent(inout), target  x,
type(c_ptr), intent(inout)  x_d 
)
private

Definition at line 1163 of file device.F90.

◆ device_unmap_r4()

subroutine device::device_unmap_r4 ( class(*), dimension(:,:,:,:), intent(inout), target  x,
type(c_ptr), intent(inout)  x_d 
)
private

Definition at line 1200 of file device.F90.

Variable Documentation

◆ aux_cmd_queue

type(c_ptr), bind(C), public device::aux_cmd_queue = C_NULL_PTR

Definition at line 55 of file device.F90.

◆ device_addrtbl

type(htable_cptr_t) device::device_addrtbl
private

Definition at line 124 of file device.F90.

◆ device_to_device

integer, parameter, public device::device_to_device = 3

Definition at line 48 of file device.F90.

◆ device_to_host

integer, parameter, public device::device_to_host = 2

Definition at line 48 of file device.F90.

◆ glb_cmd_event

type(c_ptr), bind(C), public device::glb_cmd_event

Definition at line 63 of file device.F90.

◆ glb_cmd_queue

type(c_ptr), bind(C), public device::glb_cmd_queue = C_NULL_PTR

Definition at line 52 of file device.F90.

◆ host_to_device

integer, parameter, public device::host_to_device = 1

Definition at line 48 of file device.F90.

◆ prf_cmd_queue

type(c_ptr), bind(C), public device::prf_cmd_queue = C_NULL_PTR

Definition at line 59 of file device.F90.

◆ strm_high_prio

integer, public device::strm_high_prio

Definition at line 66 of file device.F90.

◆ strm_low_prio

integer, public device::strm_low_prio

Definition at line 69 of file device.F90.