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

[SYCL][ESIMD] Add atomic load/store tests #1459

Merged
merged 4 commits into from
Jan 6, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions SYCL/ESIMD/lsc/atomic_smoke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,33 @@ template <class T, int N> struct ImplDec {
// processed.
constexpr float FPDELTA = 0.5f;

template <class T, int N> struct ImplLoad {
static constexpr AtomicOp atomic_op = AtomicOp::load;
static constexpr int n_args = 0;

static T init(int i, const Config &cfg) { return (T)(i + FPDELTA); }

static T gold(int i, const Config &cfg) {
T gold = init(i, cfg);
return gold;
}
};

template <class T, int N> struct ImplStore {
static constexpr AtomicOp atomic_op = AtomicOp::store;
static constexpr int n_args = 1;
static constexpr T base = (T)(2 + FPDELTA);

static T init(int i, const Config &cfg) { return 0; }

static T gold(int i, const Config &cfg) {
T gold = is_updated(i, N, cfg) ? base : init(i, cfg);
return gold;
}

static T arg0(int i) { return base; }
};

template <class T, int N, class C, C Op> struct ImplAdd {
static constexpr C atomic_op = Op;
static constexpr int n_args = 1;
Expand Down Expand Up @@ -576,6 +603,12 @@ int main(void) {
passed &= test<float, 8, ImplLSCFcmpwr>(q, cfg);
#endif // USE_DWORD_ATOMICS
#endif // CMPXCHG_TEST

// Check load/store operations
passed &= test_int_types<8, ImplLoad>(q, cfg);
passed &= test_int_types<8, ImplStore>(q, cfg);
passed &= test<float, 8, ImplStore>(q, cfg);

// TODO: check double other vector lengths in LSC mode.

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