FZGPUModules 2.0
GPU-accelerated modular compression pipelines
Loading...
Searching...
No Matches
api.h
Go to the documentation of this file.
1#pragma once
2
33
34#if defined(FZGMOD_BACKEND_HIP)
35
36// The real HIP declarations must be visible *before* the macros below are
37// defined, so that the macro bodies name already-declared entities.
38#include <hip/hip_runtime.h>
39#include <hip/hip_runtime_api.h>
40
41// ── Hand-mapped: the five identifiers where HIP did not keep CUDA's spelling.
42// Four are naming-convention drift (`DevAttr` → `DeviceAttribute`), one is a
43// `_t` suffix CUDA omits.
44#define cudaDeviceProp hipDeviceProp_t
45#define cudaPointerAttributes hipPointerAttribute_t
46#define cudaDevAttrMaxSharedMemoryPerBlock hipDeviceAttributeMaxSharedMemoryPerBlock
47#define cudaDevAttrMaxSharedMemoryPerBlockOptin hipDeviceAttributeSharedMemPerBlockOptin
48#define cudaDevAttrMultiProcessorCount hipDeviceAttributeMultiprocessorCount
49
50// ── Handle types
51#define cudaError_t hipError_t
52#define cudaStream_t hipStream_t
53#define cudaEvent_t hipEvent_t
54#define cudaMemPool_t hipMemPool_t
55#define cudaMemPoolProps hipMemPoolProps
56#define cudaFuncAttribute hipFuncAttribute
57#define cudaStreamCaptureStatus hipStreamCaptureStatus
58
59// ── Error codes and error reporting
60#define cudaSuccess hipSuccess
61#define cudaErrorInvalidValue hipErrorInvalidValue
62#define cudaErrorNoDevice hipErrorNoDevice
63#define cudaErrorStreamCaptureUnsupported hipErrorStreamCaptureUnsupported
64#define cudaGetErrorString hipGetErrorString
65#define cudaGetErrorName hipGetErrorName
66#define cudaGetLastError hipGetLastError
67
68// ── Device management
69#define cudaSetDevice hipSetDevice
70#define cudaGetDevice hipGetDevice
71#define cudaGetDeviceCount hipGetDeviceCount
72#define cudaGetDeviceProperties hipGetDeviceProperties
73#define cudaDeviceGetAttribute hipDeviceGetAttribute
74#define cudaDeviceSynchronize hipDeviceSynchronize
75#define cudaFuncSetAttribute hipFuncSetAttribute
76#define cudaFuncAttributeMaxDynamicSharedMemorySize hipFuncAttributeMaxDynamicSharedMemorySize
77#define cudaOccupancyMaxActiveBlocksPerMultiprocessor hipOccupancyMaxActiveBlocksPerMultiprocessor
78#define cudaProfilerStart hipProfilerStart
79
80// ── Plain allocation / transfer
81#define cudaMalloc hipMalloc
82#define cudaFree hipFree
83#define cudaMallocHost hipHostMalloc
84#define cudaHostAlloc hipHostAlloc
85#define cudaHostAllocDefault hipHostAllocDefault
86#define cudaFreeHost hipHostFree
87#define cudaMemcpy hipMemcpy
88#define cudaMemcpyAsync hipMemcpyAsync
89#define cudaMemcpyHostToDevice hipMemcpyHostToDevice
90#define cudaMemcpyDeviceToHost hipMemcpyDeviceToHost
91#define cudaMemcpyDeviceToDevice hipMemcpyDeviceToDevice
92#define cudaMemset hipMemset
93#define cudaMemsetAsync hipMemsetAsync
94#define cudaMemGetInfo hipMemGetInfo
95#define cudaPointerGetAttributes hipPointerGetAttributes
96#define cudaMemoryTypeDevice hipMemoryTypeDevice
97#define cudaMemoryTypeHost hipMemoryTypeHost
98
99// ── Stream-ordered allocation and memory pools
100#define cudaMallocAsync hipMallocAsync
101#define cudaFreeAsync hipFreeAsync
102#define cudaMallocFromPoolAsync hipMallocFromPoolAsync
103#define cudaMemPoolCreate hipMemPoolCreate
104#define cudaMemPoolDestroy hipMemPoolDestroy
105#define cudaMemPoolGetAttribute hipMemPoolGetAttribute
106#define cudaMemPoolSetAttribute hipMemPoolSetAttribute
107#define cudaMemPoolTrimTo hipMemPoolTrimTo
108#define cudaMemPoolAttrReleaseThreshold hipMemPoolAttrReleaseThreshold
109#define cudaMemPoolAttrReservedMemCurrent hipMemPoolAttrReservedMemCurrent
110#define cudaMemPoolAttrReservedMemHigh hipMemPoolAttrReservedMemHigh
111#define cudaMemPoolAttrUsedMemCurrent hipMemPoolAttrUsedMemCurrent
112#define cudaMemPoolAttrUsedMemHigh hipMemPoolAttrUsedMemHigh
113#define cudaMemPoolReuseAllowOpportunistic hipMemPoolReuseAllowOpportunistic
114#define cudaMemPoolReuseAllowInternalDependencies hipMemPoolReuseAllowInternalDependencies
115#define cudaMemPoolReuseFollowEventDependencies hipMemPoolReuseFollowEventDependencies
116#define cudaMemAllocationTypePinned hipMemAllocationTypePinned
117#define cudaMemLocationTypeDevice hipMemLocationTypeDevice
118#define cudaMemHandleTypeNone hipMemHandleTypeNone
119
120// ── Streams
121#define cudaStreamCreate hipStreamCreate
122#define cudaStreamCreateWithFlags hipStreamCreateWithFlags
123#define cudaStreamDestroy hipStreamDestroy
124#define cudaStreamSynchronize hipStreamSynchronize
125#define cudaStreamWaitEvent hipStreamWaitEvent
126#define cudaStreamDefault hipStreamDefault
127#define cudaStreamNonBlocking hipStreamNonBlocking
128#define cudaStreamLegacy hipStreamLegacy
129
130// ── Events
131#define cudaEventCreate hipEventCreate
132#define cudaEventCreateWithFlags hipEventCreateWithFlags
133#define cudaEventDestroy hipEventDestroy
134#define cudaEventRecord hipEventRecord
135#define cudaEventSynchronize hipEventSynchronize
136#define cudaEventElapsedTime hipEventElapsedTime
137#define cudaEventDefault hipEventDefault
138#define cudaEventDisableTiming hipEventDisableTiming
139
140// Device-side unconditional abort. CUDA exposes this as the named intrinsic
141// __trap(); HIP's clang only provides the compiler builtin __builtin_trap().
142#define __trap() __builtin_trap()
143
144#elif defined(FZGMOD_BACKEND_SYCL)
145
146#error "FZGMOD_BACKEND=SYCL is not implemented yet"
147
148#elif defined(__CUDACC_RTC__)
149
150// NVRTC compiles device code only and already provides the device-side
151// intrinsics (atomics, shuffles, __trap, math). Pulling in the host runtime
152// header <cuda_runtime.h> here would fail — NVRTC does not ship it. The fused
153// kernels generated by the NVRTC codegen path (src/pipeline/nvrtc_fusion.*)
154// include this header transitively via the vendored LC device codecs, so this
155// branch lets those device-only translation units compile with no host runtime.
156
157#else // FZGMOD_BACKEND_CUDA (default)
158
159#include <cuda_runtime.h>
160
161#endif