FZGPUModules 2.0
GPU-accelerated modular compression pipelines
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1#pragma once
2
18// Pulls in the active backend's runtime headers, and (under HIP) re-points the
19// CUDA-spelled host API onto its HIP equivalents.
20#include "backend/api.h"
21
22#if defined(FZGMOD_BACKEND_HIP)
23
24#include <cstddef>
25#include <cstdint>
26
27namespace fz {
28
29using stream_t = hipStream_t;
30using event_t = hipEvent_t;
31using mempool_t = hipMemPool_t;
32using error_t = hipError_t;
33using graph_t = hipGraph_t;
34using graph_exec_t = hipGraphExec_t;
35
36inline constexpr error_t kBackendSuccess = hipSuccess;
37
39inline constexpr bool kBackendSupportsGraphCapture = true;
40
42inline const char* getBackendErrorString(error_t err) {
43 return hipGetErrorString(err);
44}
45
47inline size_t getPoolUsedMemCurrent(mempool_t pool) {
48 if (!pool) return 0;
49 uint64_t used = 0;
50 hipMemPoolGetAttribute(pool, hipMemPoolAttrUsedMemCurrent, &used);
51 return static_cast<size_t>(used);
52}
53
55inline size_t getPoolUsedMemHigh(mempool_t pool) {
56 if (!pool) return 0;
57 uint64_t high = 0;
58 hipMemPoolGetAttribute(pool, hipMemPoolAttrUsedMemHigh, &high);
59 return static_cast<size_t>(high);
60}
61
62} // namespace fz
63
64#elif defined(FZGMOD_BACKEND_SYCL)
65
66#error "FZGMOD_BACKEND=SYCL is not implemented yet"
67
68#else // FZGMOD_BACKEND_CUDA (default)
69
70#include <cstddef>
71#include <cstdint>
72
73namespace fz {
74
75using stream_t = cudaStream_t;
76using event_t = cudaEvent_t;
77using mempool_t = cudaMemPool_t;
78using error_t = cudaError_t;
79using graph_t = cudaGraph_t;
80using graph_exec_t = cudaGraphExec_t;
81
82inline constexpr error_t kBackendSuccess = cudaSuccess;
83
85inline constexpr bool kBackendSupportsGraphCapture = true;
86
88inline const char* getBackendErrorString(error_t err) {
89 return cudaGetErrorString(err);
90}
91
93inline size_t getPoolUsedMemCurrent(mempool_t pool) {
94 if (!pool) return 0;
95 uint64_t used = 0;
96 cudaMemPoolGetAttribute(pool, cudaMemPoolAttrUsedMemCurrent, &used);
97 return static_cast<size_t>(used);
98}
99
101inline size_t getPoolUsedMemHigh(mempool_t pool) {
102 if (!pool) return 0;
103 uint64_t high = 0;
104 cudaMemPoolGetAttribute(pool, cudaMemPoolAttrUsedMemHigh, &high);
105 return static_cast<size_t>(high);
106}
107
108} // namespace fz
109
110#endif
Backend-neutral spelling of the host-side GPU runtime API.
Definition algorithms.h:48
size_t getPoolUsedMemCurrent(mempool_t pool)
Definition types.h:93
const char * getBackendErrorString(error_t err)
Definition types.h:88
constexpr bool kBackendSupportsGraphCapture
Definition types.h:85
size_t getPoolUsedMemHigh(mempool_t pool)
Definition types.h:101