30 #ifndef HIPCUB_CONFIG_HPP_
31 #define HIPCUB_CONFIG_HPP_
33 #include <hip/hip_runtime.h>
36 #include "hipcub_version.hpp"
42 #if _HIPCUB_HAS_DEVICE_SYSTEM_STD
43 #include _HIPCUB_LIBCXX_INCLUDE(__cccl_config)
46 #define HIPCUB_NAMESPACE hipcub
55 #if defined(DOXYGEN_SHOULD_SKIP_THIS) || defined(HIPCUB_DISABLE_INLINE_NAMESPACE)
56 #define HIPCUB_INLINE_NAMESPACE
57 #define BEGIN_HIPCUB_INLINE_NAMESPACE
58 #define END_HIPCUB_INLINE_NAMESPACE
60 #define HIPCUB_CONCAT_(SEP, A, B) A##SEP##B
61 #define HIPCUB_CONCAT(SEP, A, B) HIPCUB_CONCAT_(SEP, A, B)
63 #ifndef HIPCUB_INLINE_NAMESPACE
64 #define HIPCUB_INLINE_NAMESPACE \
65 HIPCUB_CONCAT(_, HIPCUB, HIPCUB_CONCAT(_, HIPCUB_VERSION, NS))
67 #define BEGIN_HIPCUB_INLINE_NAMESPACE \
68 inline namespace HIPCUB_INLINE_NAMESPACE \
70 #define END_HIPCUB_INLINE_NAMESPACE }
73 #define BEGIN_HIPCUB_NAMESPACE \
74 namespace HIPCUB_NAMESPACE \
76 BEGIN_HIPCUB_INLINE_NAMESPACE
78 #define END_HIPCUB_NAMESPACE \
79 END_HIPCUB_INLINE_NAMESPACE \
82 #ifdef __HIP_PLATFORM_AMD__
83 #define HIPCUB_ROCPRIM_API 1
84 #define HIPCUB_RUNTIME_FUNCTION __host__
86 #include <rocprim/device/config_types.hpp>
87 #include <rocprim/intrinsics/arch.hpp>
88 #include <rocprim/intrinsics/thread.hpp>
90 BEGIN_HIPCUB_NAMESPACE
93 inline unsigned int host_warp_size_wrapper()
96 unsigned int host_warp_size = 0;
97 hipError_t error = hipGetDevice(&device_id);
98 if(error != hipSuccess)
100 fprintf(stderr,
"HIP error: %d line: %d: %s\n", error, __LINE__, hipGetErrorString(error));
103 if(::rocprim::host_warp_size(device_id, host_warp_size) != hipSuccess)
107 return host_warp_size;
111 #include <rocprim/intrinsics/arch.hpp>
113 #define HIPCUB_WARP_THREADS ::rocprim::warp_size()
115 #define HIPCUB_DEVICE_WARP_THREADS ::rocprim::arch::wavefront::max_size()
116 #define HIPCUB_HOST_WARP_THREADS ::hipcub::detail::host_warp_size_wrapper()
117 #define HIPCUB_ARCH 1
118 #elif defined(__HIP_PLATFORM_NVIDIA__)
119 #define HIPCUB_CUB_API 1
120 #define HIPCUB_RUNTIME_FUNCTION CUB_RUNTIME_FUNCTION
122 #include <cub/util_arch.cuh>
123 #include <cuda/std/limits>
124 #include <cuda/std/type_traits>
125 #define HIPCUB_WARP_THREADS CUB_PTX_WARP_THREADS
126 #define HIPCUB_DEVICE_WARP_THREADS CUB_PTX_WARP_THREADS
127 #define HIPCUB_HOST_WARP_THREADS CUB_PTX_WARP_THREADS
128 #define HIPCUB_ARCH CUB_PTX_ARCH
129 BEGIN_HIPCUB_NAMESPACE
135 #define HIPCUB_WARP_SIZE_32 32u
136 #define HIPCUB_WARP_SIZE_64 64u
137 #define HIPCUB_MAX_WARP_SIZE HIPCUB_WARP_SIZE_64
139 #define HIPCUB_HOST __host__
140 #define HIPCUB_DEVICE __device__
141 #define HIPCUB_HOST_DEVICE __host__ __device__
142 #define HIPCUB_FORCEINLINE __forceinline__
143 #define HIPCUB_SHARED_MEMORY __shared__
147 #define HIPCUB_PRAGMA_TO_STR(x) _Pragma(#x)
148 #define HIPCUB_CLANG_SUPPRESS_WARNING_PUSH _Pragma("clang diagnostic push")
149 #define HIPCUB_CLANG_SUPPRESS_WARNING(w) HIPCUB_PRAGMA_TO_STR(clang diagnostic ignored w)
150 #define HIPCUB_CLANG_SUPPRESS_WARNING_POP _Pragma("clang diagnostic pop")
151 #define HIPCUB_CLANG_SUPPRESS_WARNING_WITH_PUSH(w) \
152 HIPCUB_CLANG_SUPPRESS_WARNING_PUSH HIPCUB_CLANG_SUPPRESS_WARNING(w)
154 #define HIPCUB_CLANG_SUPPRESS_WARNING_PUSH
155 #define HIPCUB_CLANG_SUPPRESS_WARNING(w)
156 #define HIPCUB_CLANG_SUPPRESS_WARNING_POP
157 #define HIPCUB_CLANG_SUPPRESS_WARNING_WITH_PUSH(w)
160 #define HIPCUB_CLANG_SUPPRESS_DEPRECATED_PUSH \
161 HIPCUB_CLANG_SUPPRESS_WARNING_PUSH \
162 HIPCUB_CLANG_SUPPRESS_WARNING("-Wdeprecated") \
163 HIPCUB_CLANG_SUPPRESS_WARNING("-Wdeprecated-declarations")
164 #define HIPCUB_CLANG_SUPPRESS_DEPRECATED_POP HIPCUB_CLANG_SUPPRESS_WARNING_POP
167 #if (defined(DEBUG) || defined(_DEBUG)) && !defined(HIPCUB_STDERR)
168 #define HIPCUB_STDERR
171 BEGIN_HIPCUB_NAMESPACE
180 const char* filename,
188 fprintf(stderr,
"HIP error %d [%s, %d]: %s\n", error, filename, line, hipGetErrorString(error));
198 inline void Log(
const char* message,
const char* filename,
int line)
200 printf(
"hipcub: %s [%s:%d]\n", message, filename, line);
206 #define HipcubDebug(e) ::hipcub::Debug((hipError_t)(e), __FILE__, __LINE__)
210 #define HipcubLog(msg) ::hipcub::Log(msg, __FILE__, __LINE__)
213 #ifdef DOXYGEN_SHOULD_SKIP_THIS
219 #define HIPCUB_DEBUG_SYNC
223 #if defined(HIPCUB_CUB_API) && defined(HIPCUB_DEBUG_SYNC) && !defined(CUB_DEBUG_SYNC)
224 #define CUB_DEBUG_SYNC
227 #if !defined(HIPCUB_DEBUG_SYNC) \
228 && (defined(CUB_DEBUG_SYNC) || defined(CUB_DEBUG_HOST_ASSERTIONS) \
229 || defined(CUB_DEBUG_DEVICE_ASSERTIONS) || defined(CUB_DEBUG_ALL))
230 #define HIPCUB_DEBUG_SYNC
233 #ifdef HIPCUB_ROCPRIM_API
235 #ifdef HIPCUB_DEBUG_SYNC
236 #define HIPCUB_DETAIL_DEBUG_SYNC_VALUE true
238 #define HIPCUB_DETAIL_DEBUG_SYNC_VALUE false
243 #if !defined(_CCCL_PRAGMA_UNROLL_FULL)
244 #define _CCCL_PRAGMA_UNROLL_FULL() _Pragma("unroll")
247 #if !defined(_CCCL_PRAGMA_NOUNROLL)
248 #define _CCCL_PRAGMA_NOUNROLL() _Pragma("nounroll")
hipError_t Debug(hipError_t error, const char *filename, int line)
Don't use this function directly, but via the HipcubDebug macro instead. If error is not hipSuccess,...
Definition: config.hpp:178
void Log(const char *message, const char *filename, int line)
Don't use this function directly, but via the HipcubLog macro instead. Prints the provided message co...
Definition: config.hpp:198