|
Neko 1.99.6
A portable framework for high-order spectral element flow simulations
|
#include <hip/hip_runtime.h>

Go to the source code of this file.
Functions | |
| int | hip_zerocopy (void) |
| hipError_t | hip_map (void **ptr_d, void *ptr_h, size_t s) |
| hipError_t | hip_map_free (void *ptr_d) |
| hipError_t | hip_map_memset (void *ptr_d, int value, size_t s, void *stream) |
| hipError_t | hip_map_memcpy (void *dst, void *src, size_t s, int kind, void *stream) |
| hipError_t hip_map | ( | void ** | ptr_d, |
| void * | ptr_h, | ||
| size_t | s | ||
| ) |
Map s bytes of host memory at ptr_h to the device.
On unified memory (see hip_zerocopy) the device pointer aliases the host allocation; otherwise a separate replicated buffer is allocated with hipMalloc. Aliased ranges are advised to coarse-grained coherence, since mapped arrays are never accessed concurrently from host and device and fine-grained system memory can be slower in kernels.
Definition at line 165 of file unified.hip.

| hipError_t hip_map_free | ( | void * | ptr_d | ) |
Free a device pointer obtained from hip_map (or hipMalloc).
Pointers aliasing host memory are left untouched; their allocation is owned by the host side. hipFree implicitly synchronizes the device, and the host typically deallocates right after an unmap, so preserve that barrier for aliased mappings such that the allocation cannot be released under in-flight device work.
Definition at line 228 of file unified.hip.

Memcpy between device pointers obtained from hip_map (or hipMalloc) and/or host pointers.
Under zero-copy either side may alias pageable host memory, which hipMemcpy treats as a staged pageable copy (slow, serializing); copy with a kernel instead, which runs at full memory bandwidth and stays stream-ordered (on a unified memory APU any pointer is dereferenceable from the device).
Definition at line 269 of file unified.hip.

| hipError_t hip_map_memset | ( | void * | ptr_d, |
| int | value, | ||
| size_t | s, | ||
| void * | stream | ||
| ) |
Memset on a device pointer obtained from hip_map (or hipMalloc).
hipMemset only accepts device allocations, so pointers aliasing host memory are set with a kernel instead, which also keeps the operation stream-ordered.
Definition at line 243 of file unified.hip.

Whether mapped arrays may alias host allocations (zero-copy).
Zero-copy is OFF by default and must be opted into with NEKO_HIP_ZEROCOPY=1: it is correct on a unified-memory APU but currently slower than replicated buffers on MI300A (the gather- scatter exchange in particular), so replication is the default until that overhead is understood. It also halves the memory footprint of mapped data, which is its reason to exist as an opt-in capacity mode.
When opted in, zero-copy is still only possible on an APU with unified physical memory and XNACK enabled, such that system allocations are directly and coherently accessible from the device:
Definition at line 122 of file unified.hip.

