forked from alpaka-group/alpaka3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatomicHelpers.hpp
More file actions
47 lines (41 loc) · 2.83 KB
/
atomicHelpers.hpp
File metadata and controls
47 lines (41 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* Copyright 2025 René Widera
* SPDX-License-Identifier: MPL-2.0
*/
/* @file This file provides functors where the atomic function call and the corresponding operation available within
* one object. This allows testing of the atomic function and atomicOp<Op>() without the usage of function pointers
* which is not supported by all backends.
*/
#include <alpaka/onAcc/atomic.hpp>
#include <utility>
#define ALPAKA_CHECK(success, expression) \
do \
{ \
if(!(expression)) \
{ \
success = false; \
} \
} while(0)
#define ALPAKA_MAKE_ATOMIC_TEST_FUNCTOR(OpName) \
struct OpName \
{ \
using Op = alpaka::onAcc::Atomic##OpName; \
\
static constexpr auto atomic(auto&&... args) \
{ \
return alpaka::onAcc::atomic##OpName(ALPAKA_FORWARD(args)...); \
} \
};
namespace alpaka::test::unit::atomic
{
ALPAKA_MAKE_ATOMIC_TEST_FUNCTOR(Add);
ALPAKA_MAKE_ATOMIC_TEST_FUNCTOR(Sub);
ALPAKA_MAKE_ATOMIC_TEST_FUNCTOR(Min);
ALPAKA_MAKE_ATOMIC_TEST_FUNCTOR(Max);
ALPAKA_MAKE_ATOMIC_TEST_FUNCTOR(Exch);
ALPAKA_MAKE_ATOMIC_TEST_FUNCTOR(Dec);
ALPAKA_MAKE_ATOMIC_TEST_FUNCTOR(Inc);
ALPAKA_MAKE_ATOMIC_TEST_FUNCTOR(Cas);
ALPAKA_MAKE_ATOMIC_TEST_FUNCTOR(Or);
ALPAKA_MAKE_ATOMIC_TEST_FUNCTOR(Xor);
ALPAKA_MAKE_ATOMIC_TEST_FUNCTOR(And);
} // namespace alpaka::test::unit::atomic