Skip to content

Commit

Permalink
HIP: workaround atomicMax and atomicMin
Browse files Browse the repository at this point in the history
For architectures where __hip_atomic_compare_exchange_strong is false
HIP is emulating atomics with `atomicCAS` but with a broken
implementation.
  • Loading branch information
psychocoderHPC committed Jul 29, 2022
1 parent 05b8a60 commit eb579fd
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions include/alpaka/atomic/AtomicUniformCudaHip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,18 @@ inline namespace alpakaGlobal
struct AlpakaBuiltInAtomic<alpaka::AtomicMin, double, alpaka::hierarchy::Threads> : std::false_type
{
};

# if !__has_builtin(__hip_atomic_compare_exchange_strong)
template<typename THierarchy>
struct AlpakaBuiltInAtomic<alpaka::AtomicMin, unsigned long long, THierarchy> : std::false_type
{
};

template<>
struct AlpakaBuiltInAtomic<alpaka::AtomicMin, unsigned long long, alpaka::hierarchy::Threads> : std::false_type
{
};
# endif
# endif

// Max.
Expand Down Expand Up @@ -275,6 +287,18 @@ inline namespace alpakaGlobal
struct AlpakaBuiltInAtomic<alpaka::AtomicMax, double, alpaka::hierarchy::Threads> : std::false_type
{
};

# if !__has_builtin(__hip_atomic_compare_exchange_strong)
template<typename THierarchy>
struct AlpakaBuiltInAtomic<alpaka::AtomicMax, unsigned long long, THierarchy> : std::false_type
{
};

template<>
struct AlpakaBuiltInAtomic<alpaka::AtomicMax, unsigned long long, alpaka::hierarchy::Threads> : std::false_type
{
};
# endif
# endif


Expand Down

0 comments on commit eb579fd

Please sign in to comment.