30 #ifndef HIPCUB_CONFIG_HPP_
31 #define HIPCUB_CONFIG_HPP_
33 #include <hip/hip_runtime.h>
35 #define HIPCUB_NAMESPACE hipcub
37 #define BEGIN_HIPCUB_NAMESPACE \
40 #define END_HIPCUB_NAMESPACE \
43 #ifdef __HIP_PLATFORM_AMD__
44 #define HIPCUB_ROCPRIM_API 1
45 #define HIPCUB_RUNTIME_FUNCTION __host__
47 #include <rocprim/device/config_types.hpp>
49 BEGIN_HIPCUB_NAMESPACE
52 inline unsigned int host_warp_size_wrapper()
55 unsigned int host_warp_size = 0;
56 hipError_t error = hipGetDevice(&device_id);
57 if(error != hipSuccess)
59 fprintf(stderr,
"HIP error: %d line: %d: %s\n", error, __LINE__, hipGetErrorString(error));
62 if(::rocprim::host_warp_size(device_id, host_warp_size) != hipSuccess)
66 return host_warp_size;
71 #define HIPCUB_WARP_THREADS ::rocprim::warp_size()
72 #define HIPCUB_DEVICE_WARP_THREADS ::rocprim::device_warp_size()
73 #define HIPCUB_HOST_WARP_THREADS ::hipcub::detail::host_warp_size_wrapper()
75 #elif defined(__HIP_PLATFORM_NVIDIA__)
76 #define HIPCUB_CUB_API 1
77 #define HIPCUB_RUNTIME_FUNCTION CUB_RUNTIME_FUNCTION
79 #include <cub/util_arch.cuh>
80 #define HIPCUB_WARP_THREADS CUB_PTX_WARP_THREADS
81 #define HIPCUB_DEVICE_WARP_THREADS CUB_PTX_WARP_THREADS
82 #define HIPCUB_HOST_WARP_THREADS CUB_PTX_WARP_THREADS
83 #define HIPCUB_ARCH CUB_PTX_ARCH
84 BEGIN_HIPCUB_NAMESPACE
90 #define HIPCUB_WARP_SIZE_32 32u
91 #define HIPCUB_WARP_SIZE_64 64u
92 #define HIPCUB_MAX_WARP_SIZE HIPCUB_WARP_SIZE_64
94 #define HIPCUB_HOST __host__
95 #define HIPCUB_DEVICE __device__
96 #define HIPCUB_HOST_DEVICE __host__ __device__
97 #define HIPCUB_SHARED_MEMORY __shared__
101 #define HIPCUB_PRAGMA_TO_STR(x) _Pragma(#x)
102 #define HIPCUB_CLANG_SUPPRESS_WARNING_PUSH _Pragma("clang diagnostic push")
103 #define HIPCUB_CLANG_SUPPRESS_WARNING(w) HIPCUB_PRAGMA_TO_STR(clang diagnostic ignored w)
104 #define HIPCUB_CLANG_SUPPRESS_WARNING_POP _Pragma("clang diagnostic pop")
105 #define HIPCUB_CLANG_SUPPRESS_WARNING_WITH_PUSH(w) \
106 HIPCUB_CLANG_SUPPRESS_WARNING_PUSH HIPCUB_CLANG_SUPPRESS_WARNING(w)
108 #define HIPCUB_CLANG_SUPPRESS_WARNING_PUSH
109 #define HIPCUB_CLANG_SUPPRESS_WARNING(w)
110 #define HIPCUB_CLANG_SUPPRESS_WARNING_POP
111 #define HIPCUB_CLANG_SUPPRESS_WARNING_WITH_PUSH(w)
114 #define HIPCUB_CLANG_SUPPRESS_DEPRECATED_PUSH \
115 HIPCUB_CLANG_SUPPRESS_WARNING_PUSH \
116 HIPCUB_CLANG_SUPPRESS_WARNING("-Wdeprecated") \
117 HIPCUB_CLANG_SUPPRESS_WARNING("-Wdeprecated-declarations")
118 #define HIPCUB_CLANG_SUPPRESS_DEPRECATED_POP HIPCUB_CLANG_SUPPRESS_WARNING_POP
121 #if (defined(DEBUG) || defined(_DEBUG)) && !defined(HIPCUB_STDERR)
122 #define HIPCUB_STDERR
125 BEGIN_HIPCUB_NAMESPACE
134 const char* filename,
142 fprintf(stderr,
"HIP error %d [%s, %d]: %s\n", error, filename, line, hipGetErrorString(error));
152 inline void Log(
const char* message,
const char* filename,
int line)
154 printf(
"hipcub: %s [%s:%d]\n", message, filename, line);
160 #define HipcubDebug(e) ::hipcub::Debug((hipError_t)(e), __FILE__, __LINE__)
164 #define HipcubLog(msg) ::hipcub::Log(msg, __FILE__, __LINE__)
167 #if __cpp_if_constexpr
168 #define HIPCUB_IF_CONSTEXPR constexpr
170 #if defined(_MSC_VER) && !defined(__clang__)
174 #define HIPCUB_IF_CONSTEXPR constexpr
176 #define HIPCUB_IF_CONSTEXPR
180 #ifdef DOXYGEN_SHOULD_SKIP_THIS
186 #define HIPCUB_DEBUG_SYNC
190 #if defined(HIPCUB_CUB_API) && defined(HIPCUB_DEBUG_SYNC) && !defined(CUB_DEBUG_SYNC)
191 #define CUB_DEBUG_SYNC
194 #if !defined(HIPCUB_DEBUG_SYNC) \
195 && (defined(CUB_DEBUG_SYNC) || defined(CUB_DEBUG_HOST_ASSERTIONS) \
196 || defined(CUB_DEBUG_DEVICE_ASSERTIONS) || defined(CUB_DEBUG_ALL))
197 #define HIPCUB_DEBUG_SYNC
200 #ifdef HIPCUB_ROCPRIM_API
202 #ifdef HIPCUB_DEBUG_SYNC
203 #define HIPCUB_DETAIL_DEBUG_SYNC_VALUE true
205 #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:132
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:152