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
17
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;
33
34inline constexpr error_t kBackendSuccess = hipSuccess;
35
37inline constexpr bool kBackendSupportsGraphCapture = true;
38
40inline const char* getBackendErrorString(error_t err) {
41 return hipGetErrorString(err);
42}
43
45inline size_t getPoolUsedMemCurrent(mempool_t pool) {
46 if (!pool) return 0;
47 uint64_t used = 0;
48 hipMemPoolGetAttribute(pool, hipMemPoolAttrUsedMemCurrent, &used);
49 return static_cast<size_t>(used);
50}
51
53inline size_t getPoolUsedMemHigh(mempool_t pool) {
54 if (!pool) return 0;
55 uint64_t high = 0;
56 hipMemPoolGetAttribute(pool, hipMemPoolAttrUsedMemHigh, &high);
57 return static_cast<size_t>(high);
58}
59
60} // namespace fz
61
62#elif defined(FZGMOD_BACKEND_SYCL)
63
64#error "FZGMOD_BACKEND=SYCL is not implemented yet"
65
66#else // FZGMOD_BACKEND_CUDA (default)
67
68#include <cstddef>
69#include <cstdint>
70
71namespace fz {
72
73using stream_t = cudaStream_t;
74using event_t = cudaEvent_t;
75using mempool_t = cudaMemPool_t;
76using error_t = cudaError_t;
77
78inline constexpr error_t kBackendSuccess = cudaSuccess;
79
81inline constexpr bool kBackendSupportsGraphCapture = true;
82
84inline const char* getBackendErrorString(error_t err) {
85 return cudaGetErrorString(err);
86}
87
89inline size_t getPoolUsedMemCurrent(mempool_t pool) {
90 if (!pool) return 0;
91 uint64_t used = 0;
92 cudaMemPoolGetAttribute(pool, cudaMemPoolAttrUsedMemCurrent, &used);
93 return static_cast<size_t>(used);
94}
95
97inline size_t getPoolUsedMemHigh(mempool_t pool) {
98 if (!pool) return 0;
99 uint64_t high = 0;
100 cudaMemPoolGetAttribute(pool, cudaMemPoolAttrUsedMemHigh, &high);
101 return static_cast<size_t>(high);
102}
103
104} // namespace fz
105
106#endif
Backend-neutral spelling of the host-side GPU runtime API.
Definition dag.h:24
size_t getPoolUsedMemCurrent(mempool_t pool)
Definition types.h:89
const char * getBackendErrorString(error_t err)
Definition types.h:84
constexpr bool kBackendSupportsGraphCapture
Definition types.h:81
size_t getPoolUsedMemHigh(mempool_t pool)
Definition types.h:97