Unified GPU portability layer between CUDA and HIP with host fallback stubs.
More...
#include "core/CompilerPortability.hpp"
#include <cstddef>
#include <utility>
Go to the source code of this file.
|
| struct | MemcpyParams |
| | Memory copy parameter struct for host fallback. More...
|
| struct | dim3 |
| | 3D vector dimension descriptor for CUDA/HIP emulation. More...
|
|
| using | hipError_t = int |
| | Return error type for host fallback emulation.
|
|
| hipError_t | hipGetDeviceCount (int *count) noexcept |
| | Returns the number of compute-capable GPU devices.
|
| template<typename T> |
| hipError_t | hipMalloc (T **ptr, std::size_t size) noexcept |
| | Host fallback allocation stub returning failure when GPU support is disabled.
|
| hipError_t | hipFree (void *ptr) noexcept |
| | Host fallback deallocation stub.
|
| hipError_t | hipMemcpy (MemcpyParams params) noexcept |
| | Host fallback memory copy stub.
|
| hipError_t | hipMemcpy (void *dst, const void *src, std::size_t count, int kind) noexcept |
| | Host fallback memory copy overload.
|
| hipError_t | hipDeviceSynchronize () noexcept |
| | Host fallback device synchronization stub.
|
| const char * | hipGetErrorString (hipError_t err) noexcept |
| | Translates an error code to a human-readable description.
|
| template<typename T, typename U> |
| T | atomicAdd (T *addr, U val) noexcept |
| | Host fallback atomic addition.
|
| template<typename K, typename Grid, typename Block, typename Shared, typename Stream, typename... Args> |
| constexpr void | hipLaunchKernelGGL (K &&kernel, Grid &&grid, Block &&block, Shared &&shared, Stream &&stream, Args &&...args) noexcept |
| | Host fallback stub for kernel launch when GPU acceleration is disabled.
|
Unified GPU portability layer between CUDA and HIP with host fallback stubs.
- Copyright
- Copyright © 2013-2026 Isaías Rodríguez (isurw.nosp@m.ars@.nosp@m.gmail.nosp@m..com)
- License
- SPDX-License-Identifier: AGPL-3.0-only
◆ hipError_t
Return error type for host fallback emulation.
◆ atomicAdd()
template<typename T, typename U>
| T atomicAdd |
( |
T * | addr, |
|
|
U | val ) |
|
inlinenoexcept |
Host fallback atomic addition.
- Template Parameters
-
| T | Address data type. |
| U | Increment value type. |
- Parameters
-
| [in,out] | addr | Target memory location. |
| [in] | val | Value to add. |
- Returns
- Old value before addition.
◆ hipDeviceSynchronize()
Host fallback device synchronization stub.
- Returns
- hipErrorNoDevice.
◆ hipFree()
Host fallback deallocation stub.
- Parameters
-
| [in] | ptr | Pointer to free (ignored in fallback mode). |
- Returns
- hipSuccess.
◆ hipGetDeviceCount()
Returns the number of compute-capable GPU devices.
- Parameters
-
| [out] | count | Pointer to integer receiving device count (always 0 in host fallback). |
- Returns
- hipSuccess.
◆ hipGetErrorString()
Translates an error code to a human-readable description.
- Parameters
-
- Returns
- Static string description of the error code.
◆ hipLaunchKernelGGL()
template<typename K, typename Grid, typename Block, typename Shared, typename Stream, typename... Args>
| void hipLaunchKernelGGL |
( |
K && | kernel, |
|
|
Grid && | grid, |
|
|
Block && | block, |
|
|
Shared && | shared, |
|
|
Stream && | stream, |
|
|
Args &&... | args ) |
|
constexprnoexcept |
Host fallback stub for kernel launch when GPU acceleration is disabled.
- Template Parameters
-
| K | Kernel function type. |
| Grid | Grid dimension type. |
| Block | Block dimension type. |
| Shared | Shared memory size type. |
| Stream | Stream type. |
| Args | Kernel argument types. |
- Parameters
-
| [in] | kernel | Kernel function pointer or callable. |
| [in] | grid | Grid dimensions. |
| [in] | block | Block dimensions. |
| [in] | shared | Shared memory allocation size in bytes. |
| [in] | stream | Execution stream. |
| [in] | args | Kernel launch arguments. |
◆ hipMalloc()
template<typename T>
| hipError_t hipMalloc |
( |
T ** | ptr, |
|
|
std::size_t | size ) |
|
inlinenoexcept |
Host fallback allocation stub returning failure when GPU support is disabled.
- Template Parameters
-
- Parameters
-
| [out] | ptr | Output pointer set to nullptr. |
| [in] | size | Requested byte size. |
- Returns
- hipErrorNoDevice indicating no GPU acceleration is compiled in.
◆ hipMemcpy() [1/2]
Host fallback memory copy stub.
- Parameters
-
| [in] | params | Memory copy parameters. |
- Returns
- hipErrorNoDevice.
◆ hipMemcpy() [2/2]
| hipError_t hipMemcpy |
( |
void * | dst, |
|
|
const void * | src, |
|
|
std::size_t | count, |
|
|
int | kind ) |
|
inlinenoexcept |
Host fallback memory copy overload.
- Parameters
-
| [out] | dst | Destination buffer pointer. |
| [in] | src | Source buffer pointer. |
| [in] | count | Byte count. |
| [in] | kind | Transfer direction. |
- Returns
- hipErrorNoDevice.
◆ blockDim
Initial value:{
.x = 1,
.y = 1,
.z = 1,
}
Emulated block dimension.
◆ blockIdx
Initial value:{
.x = 0,
.y = 0,
.z = 0,
}
Emulated block index inside grid.
◆ hipErrorNoDevice
| int hipErrorNoDevice = 100 |
|
constexpr |
Device unavailable error code.
◆ hipErrorNotSupported
| int hipErrorNotSupported = 801 |
|
constexpr |
Operation not supported in host fallback mode.
◆ hipMemcpyDeviceToHost
| int hipMemcpyDeviceToHost = 0 |
|
constexpr |
Device-to-host memory copy transfer direction flag.
◆ hipMemcpyHostToDevice
| int hipMemcpyHostToDevice = 0 |
|
constexpr |
Host-to-device memory copy transfer direction flag.
◆ hipSuccess
Successful execution code.
◆ threadIdx
Initial value:{
.x = 0,
.y = 0,
.z = 0,
}
Emulated thread index inside thread block.