30 #ifndef HIPCUB_CONFIG_HPP_
31 #define HIPCUB_CONFIG_HPP_
33 #include <hip/hip_runtime.h>
36 #include "hipcub_version.hpp"
38 #define HIPCUB_NAMESPACE hipcub
47 #if defined(DOXYGEN_SHOULD_SKIP_THIS) || defined(HIPCUB_DISABLE_INLINE_NAMESPACE)
48 #define HIPCUB_INLINE_NAMESPACE
49 #define BEGIN_HIPCUB_INLINE_NAMESPACE
50 #define END_HIPCUB_INLINE_NAMESPACE
52 #define HIPCUB_CONCAT_(SEP, A, B) A##SEP##B
53 #define HIPCUB_CONCAT(SEP, A, B) HIPCUB_CONCAT_(SEP, A, B)
55 #ifndef HIPCUB_INLINE_NAMESPACE
56 #define HIPCUB_INLINE_NAMESPACE \
57 HIPCUB_CONCAT(_, HIPCUB, HIPCUB_CONCAT(_, HIPCUB_VERSION, NS))
59 #define BEGIN_HIPCUB_INLINE_NAMESPACE \
60 inline namespace HIPCUB_INLINE_NAMESPACE \
62 #define END_HIPCUB_INLINE_NAMESPACE }
65 #define BEGIN_HIPCUB_NAMESPACE \
66 namespace HIPCUB_NAMESPACE \
68 BEGIN_HIPCUB_INLINE_NAMESPACE
70 #define END_HIPCUB_NAMESPACE \
71 END_HIPCUB_INLINE_NAMESPACE \
74 #ifdef __HIP_PLATFORM_AMD__
75 #define HIPCUB_ROCPRIM_API 1
76 #define HIPCUB_RUNTIME_FUNCTION __host__
78 #include <rocprim/device/config_types.hpp>
79 #include <rocprim/intrinsics/arch.hpp>
80 #include <rocprim/intrinsics/thread.hpp>
82 BEGIN_HIPCUB_NAMESPACE
85 inline unsigned int host_warp_size_wrapper()
88 unsigned int host_warp_size = 0;
89 hipError_t error = hipGetDevice(&device_id);
90 if(error != hipSuccess)
92 fprintf(stderr,
"HIP error: %d line: %d: %s\n", error, __LINE__, hipGetErrorString(error));
95 if(::rocprim::host_warp_size(device_id, host_warp_size) != hipSuccess)
99 return host_warp_size;
103 #include <rocprim/intrinsics/arch.hpp>
105 #define HIPCUB_WARP_THREADS ::rocprim::warp_size()
107 #define HIPCUB_DEVICE_WARP_THREADS ::rocprim::arch::wavefront::max_size()
108 #define HIPCUB_HOST_WARP_THREADS ::hipcub::detail::host_warp_size_wrapper()
109 #define HIPCUB_ARCH 1
110 #elif defined(__HIP_PLATFORM_NVIDIA__)
111 #define HIPCUB_CUB_API 1
112 #define HIPCUB_RUNTIME_FUNCTION CUB_RUNTIME_FUNCTION
114 #include <cub/util_arch.cuh>
115 #define HIPCUB_WARP_THREADS CUB_PTX_WARP_THREADS
116 #define HIPCUB_DEVICE_WARP_THREADS CUB_PTX_WARP_THREADS
117 #define HIPCUB_HOST_WARP_THREADS CUB_PTX_WARP_THREADS
118 #define HIPCUB_ARCH CUB_PTX_ARCH
119 BEGIN_HIPCUB_NAMESPACE
125 #define HIPCUB_WARP_SIZE_32 32u
126 #define HIPCUB_WARP_SIZE_64 64u
127 #define HIPCUB_MAX_WARP_SIZE HIPCUB_WARP_SIZE_64
129 #define HIPCUB_HOST __host__
130 #define HIPCUB_DEVICE __device__
131 #define HIPCUB_HOST_DEVICE __host__ __device__
132 #define HIPCUB_FORCEINLINE __forceinline__
133 #define HIPCUB_SHARED_MEMORY __shared__
137 #define HIPCUB_PRAGMA_TO_STR(x) _Pragma(#x)
138 #define HIPCUB_CLANG_SUPPRESS_WARNING_PUSH _Pragma("clang diagnostic push")
139 #define HIPCUB_CLANG_SUPPRESS_WARNING(w) HIPCUB_PRAGMA_TO_STR(clang diagnostic ignored w)
140 #define HIPCUB_CLANG_SUPPRESS_WARNING_POP _Pragma("clang diagnostic pop")
141 #define HIPCUB_CLANG_SUPPRESS_WARNING_WITH_PUSH(w) \
142 HIPCUB_CLANG_SUPPRESS_WARNING_PUSH HIPCUB_CLANG_SUPPRESS_WARNING(w)
144 #define HIPCUB_CLANG_SUPPRESS_WARNING_PUSH
145 #define HIPCUB_CLANG_SUPPRESS_WARNING(w)
146 #define HIPCUB_CLANG_SUPPRESS_WARNING_POP
147 #define HIPCUB_CLANG_SUPPRESS_WARNING_WITH_PUSH(w)
150 #define HIPCUB_CLANG_SUPPRESS_DEPRECATED_PUSH \
151 HIPCUB_CLANG_SUPPRESS_WARNING_PUSH \
152 HIPCUB_CLANG_SUPPRESS_WARNING("-Wdeprecated") \
153 HIPCUB_CLANG_SUPPRESS_WARNING("-Wdeprecated-declarations")
154 #define HIPCUB_CLANG_SUPPRESS_DEPRECATED_POP HIPCUB_CLANG_SUPPRESS_WARNING_POP
157 #if (defined(DEBUG) || defined(_DEBUG)) && !defined(HIPCUB_STDERR)
158 #define HIPCUB_STDERR
161 BEGIN_HIPCUB_NAMESPACE
170 const char* filename,
178 fprintf(stderr,
"HIP error %d [%s, %d]: %s\n", error, filename, line, hipGetErrorString(error));
188 inline void Log(
const char* message,
const char* filename,
int line)
190 printf(
"hipcub: %s [%s:%d]\n", message, filename, line);
196 #define HipcubDebug(e) ::hipcub::Debug((hipError_t)(e), __FILE__, __LINE__)
200 #define HipcubLog(msg) ::hipcub::Log(msg, __FILE__, __LINE__)
203 #if __cpp_if_constexpr
204 #define HIPCUB_IF_CONSTEXPR constexpr
206 #if defined(_MSC_VER) && !defined(__clang__)
210 #define HIPCUB_IF_CONSTEXPR constexpr
212 #define HIPCUB_IF_CONSTEXPR
216 #ifdef DOXYGEN_SHOULD_SKIP_THIS
222 #define HIPCUB_DEBUG_SYNC
226 #if defined(HIPCUB_CUB_API) && defined(HIPCUB_DEBUG_SYNC) && !defined(CUB_DEBUG_SYNC)
227 #define CUB_DEBUG_SYNC
230 #if !defined(HIPCUB_DEBUG_SYNC) \
231 && (defined(CUB_DEBUG_SYNC) || defined(CUB_DEBUG_HOST_ASSERTIONS) \
232 || defined(CUB_DEBUG_DEVICE_ASSERTIONS) || defined(CUB_DEBUG_ALL))
233 #define HIPCUB_DEBUG_SYNC
236 #ifdef HIPCUB_ROCPRIM_API
238 #ifdef HIPCUB_DEBUG_SYNC
239 #define HIPCUB_DETAIL_DEBUG_SYNC_VALUE true
241 #define HIPCUB_DETAIL_DEBUG_SYNC_VALUE false
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:168
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:188