Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 2942225

Browse files
authored
[SYCL][ESIMD] Add atomic load/store tests (#1459)
1 parent 1897b70 commit 2942225

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

SYCL/ESIMD/lsc/atomic_smoke.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,33 @@ template <class T, int N> struct ImplDec {
344344
// processed.
345345
constexpr float FPDELTA = 0.5f;
346346

347+
template <class T, int N> struct ImplLoad {
348+
static constexpr AtomicOp atomic_op = AtomicOp::load;
349+
static constexpr int n_args = 0;
350+
351+
static T init(int i, const Config &cfg) { return (T)(i + FPDELTA); }
352+
353+
static T gold(int i, const Config &cfg) {
354+
T gold = init(i, cfg);
355+
return gold;
356+
}
357+
};
358+
359+
template <class T, int N> struct ImplStore {
360+
static constexpr AtomicOp atomic_op = AtomicOp::store;
361+
static constexpr int n_args = 1;
362+
static constexpr T base = (T)(2 + FPDELTA);
363+
364+
static T init(int i, const Config &cfg) { return 0; }
365+
366+
static T gold(int i, const Config &cfg) {
367+
T gold = is_updated(i, N, cfg) ? base : init(i, cfg);
368+
return gold;
369+
}
370+
371+
static T arg0(int i) { return base; }
372+
};
373+
347374
template <class T, int N, class C, C Op> struct ImplAdd {
348375
static constexpr C atomic_op = Op;
349376
static constexpr int n_args = 1;
@@ -576,6 +603,13 @@ int main(void) {
576603
passed &= test<float, 8, ImplLSCFcmpwr>(q, cfg);
577604
#endif // USE_DWORD_ATOMICS
578605
#endif // CMPXCHG_TEST
606+
607+
#ifndef USE_DWORD_ATOMICS
608+
// Check load/store operations
609+
passed &= test_int_types<8, ImplLoad>(q, cfg);
610+
passed &= test_int_types<8, ImplStore>(q, cfg);
611+
passed &= test<float, 8, ImplStore>(q, cfg);
612+
#endif // USE_DWORD_ATOMICS
579613
// TODO: check double other vector lengths in LSC mode.
580614

581615
std::cout << (passed ? "Passed\n" : "FAILED\n");

0 commit comments

Comments
 (0)