15#ifdef CORRELATION_USE_HIP
16#include <hip/hip_runtime.h>
17#elif defined(CORRELATION_USE_CUDA)
18#include <cuda_runtime.h>
22#define hipSuccess cudaSuccess
23#define hipGetDeviceCount cudaGetDeviceCount
24#define hipMalloc cudaMalloc
25#define hipFree cudaFree
26#define hipMemcpy cudaMemcpy
27#define hipMemcpyHostToDevice cudaMemcpyHostToDevice
28#define hipMemcpyDeviceToHost cudaMemcpyDeviceToHost
29#define hipDeviceSynchronize cudaDeviceSynchronize
30#define hipGetErrorString cudaGetErrorString
44template <
typename K,
typename... Args>
46 cudaStream_t stream, Args &&...args) {
47 kernel<<<grid, block, shared, stream>>>(std::forward<Args>(args)...);
68 if (count !=
nullptr) {
153 return "No GPU device available (compiled without CUDA/HIP support)";
155 return "GPU operation not supported in host fallback mode";
157 return "Unknown GPU error";
169template <
typename T,
typename U>
inline T
atomicAdd(T *addr, U val)
noexcept {
170 if (addr ==
nullptr) {
174 *addr +=
static_cast<T
>(val);
221template <
typename K,
typename Grid,
typename Block,
typename Shared,
typename Stream,
224 [[maybe_unused]] Block &&block, [[maybe_unused]] Shared &&shared,
225 [[maybe_unused]] Stream &&stream,
226 [[maybe_unused]] Args &&...args)
noexcept {}
Unified compiler extensions, alignment, restrict, and GPU execution qualifiers.
constexpr dim3 threadIdx
Emulated thread index inside thread block.
Definition GPUPortability.hpp:188
constexpr int hipErrorNoDevice
Device unavailable error code.
Definition GPUPortability.hpp:58
constexpr dim3 blockDim
Emulated block dimension.
Definition GPUPortability.hpp:200
int hipError_t
Return error type for host fallback emulation.
Definition GPUPortability.hpp:54
constexpr int hipErrorNotSupported
Operation not supported in host fallback mode.
Definition GPUPortability.hpp:60
hipError_t hipFree(void *ptr) noexcept
Host fallback deallocation stub.
Definition GPUPortability.hpp:94
constexpr int hipMemcpyDeviceToHost
Device-to-host memory copy transfer direction flag.
Definition GPUPortability.hpp:135
hipError_t hipGetDeviceCount(int *count) noexcept
Returns the number of compute-capable GPU devices.
Definition GPUPortability.hpp:67
constexpr int hipSuccess
Successful execution code.
Definition GPUPortability.hpp:56
hipError_t hipMemcpy(MemcpyParams params) noexcept
Host fallback memory copy stub.
Definition GPUPortability.hpp:111
hipError_t hipMalloc(T **ptr, std::size_t size) noexcept
Host fallback allocation stub returning failure when GPU support is disabled.
Definition GPUPortability.hpp:82
const char * hipGetErrorString(hipError_t err) noexcept
Translates an error code to a human-readable description.
Definition GPUPortability.hpp:148
constexpr int hipMemcpyHostToDevice
Host-to-device memory copy transfer direction flag.
Definition GPUPortability.hpp:133
T atomicAdd(T *addr, U val) noexcept
Host fallback atomic addition.
Definition GPUPortability.hpp:169
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.
Definition GPUPortability.hpp:223
hipError_t hipDeviceSynchronize() noexcept
Host fallback device synchronization stub.
Definition GPUPortability.hpp:141
constexpr dim3 blockIdx
Emulated block index inside grid.
Definition GPUPortability.hpp:194
Memory copy parameter struct for host fallback.
Definition GPUPortability.hpp:99
const void * src
Definition GPUPortability.hpp:101
void * dst
Definition GPUPortability.hpp:100
int kind
Definition GPUPortability.hpp:103
std::size_t count
Definition GPUPortability.hpp:102
3D vector dimension descriptor for CUDA/HIP emulation.
Definition GPUPortability.hpp:181
unsigned int z
Definition GPUPortability.hpp:184
unsigned int x
Definition GPUPortability.hpp:182
unsigned int y
Definition GPUPortability.hpp:183