Skip to content

Commit 3fd70ff

Browse files
authored
fix(rocprim): backport atomic ordered block id toggle via env variable (#763)
* fix(rocprim): backport atomic ordered block id toggle via env variable * fix(rocprim): fix device_run_length_encode failure * style(rocprim): update style
1 parent fe7b409 commit 3fd70ff

27 files changed

+1681
-1413
lines changed

benchmark/benchmark_block_run_length_decode.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <rocprim/block/block_run_length_decode.hpp>
3030
#include <rocprim/block/block_store_func.hpp>
3131

32+
#include <chrono>
3233
#include <random>
3334
#include <vector>
3435

common/utils.hpp

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,33 @@
2525

2626
#include <rocprim/intrinsics/thread.hpp>
2727

28-
#ifdef USE_GTEST
29-
// GoogleTest-compatible HIP_CHECK macro. FAIL is called to log the Google Test trace.
30-
// The lambda is invoked immediately as assertions that generate a fatal failure can
31-
// only be used in void-returning functions.
32-
#define HIP_CHECK(condition) \
33-
{ \
34-
hipError_t error = condition; \
35-
if(error != hipSuccess) \
36-
{ \
37-
[error]() \
38-
{ FAIL() << "HIP error " << error << ": " << hipGetErrorString(error); }(); \
39-
exit(error); \
40-
} \
41-
}
42-
#else
43-
#define HIP_CHECK(condition) \
44-
{ \
45-
hipError_t error = condition; \
46-
if(error != hipSuccess) \
28+
#ifndef HIP_CHECK
29+
#ifdef USE_GTEST
30+
// GoogleTest-compatible HIP_CHECK macro. FAIL is called to log the Google Test trace.
31+
// The lambda is invoked immediately as assertions that generate a fatal failure can
32+
// only be used in void-returning functions.
33+
#define HIP_CHECK(condition) \
4734
{ \
48-
std::cout << "HIP error: " << hipGetErrorString(error) << " file: " << __FILE__ \
49-
<< " line: " << __LINE__ << std::endl; \
50-
exit(error); \
51-
} \
52-
}
35+
hipError_t error = condition; \
36+
if(error != hipSuccess) \
37+
{ \
38+
[error]() \
39+
{ FAIL() << "HIP error " << error << ": " << hipGetErrorString(error); }(); \
40+
exit(error); \
41+
} \
42+
}
43+
#else
44+
#define HIP_CHECK(condition) \
45+
{ \
46+
hipError_t error = condition; \
47+
if(error != hipSuccess) \
48+
{ \
49+
std::cout << "HIP error: " << hipGetErrorString(error) \
50+
<< " file: " << __FILE__ << " line: " << __LINE__ << std::endl; \
51+
exit(error); \
52+
} \
53+
}
54+
#endif
5355
#endif
5456

5557
namespace common

rocprim/include/rocprim/detail/various.hpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,36 @@ struct select_max_by_value<T, U, Vs...>
439439
template<typename... Ts>
440440
using select_max_by_value_t = typename select_max_by_value<Ts...>::type;
441441

442+
struct lookback_variant_util
443+
{
444+
bool use_sleep;
445+
bool use_atomic;
446+
447+
lookback_variant_util(bool use_sleep, bool use_atomic)
448+
: use_sleep(use_sleep), use_atomic(use_atomic)
449+
{}
450+
451+
template<typename Func>
452+
auto operator()(Func f /* [](auto use_sleep, auto use_atomic){ ... } */)
453+
{
454+
using T = std::integral_constant<bool, true>;
455+
using F = std::integral_constant<bool, false>;
456+
if(use_sleep)
457+
{
458+
if(use_atomic)
459+
{
460+
return f(T{}, T{});
461+
}
462+
return f(T{}, F{});
463+
}
464+
if(use_atomic)
465+
{
466+
return f(F{}, T{});
467+
}
468+
return f(F{}, F{});
469+
}
470+
};
471+
442472
} // end namespace detail
443473
END_ROCPRIM_NAMESPACE
444474

0 commit comments

Comments
 (0)