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

[SYCL][ESIMD] Make more thorough check for atomic operations with floating point #1458

Merged
merged 7 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion SYCL/ESIMD/lsc/atomic_cmpxchg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
// separated.
#define CMPXCHG_TEST

#include "lsc/atomic_smoke.cpp"
#include "atomic_smoke.cpp"
36 changes: 21 additions & 15 deletions SYCL/ESIMD/lsc/atomic_smoke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,43 +334,49 @@ template <class T, int N> struct ImplDec {
}
};

// The purpose of this is validate that floating point data is correctly
// processed.
constexpr float FPDELTA = 0.5f;

template <class T, int N, class C, C Op> struct ImplAdd {
static constexpr C atomic_op = Op;
static constexpr int n_args = 1;

static T init(int i, const Config &cfg) { return (T)0; }
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)
? (T)(cfg.repeat * cfg.threads_per_group * cfg.n_groups)
: init(i, cfg);
T gold = is_updated(i, N, cfg) ? (T)(cfg.repeat * cfg.threads_per_group *
cfg.n_groups * (T)(1 + FPDELTA))
: init(i, cfg);
return gold;
}

static T arg0(int i) { return 1; }
static T arg0(int i) { return (T)(1 + FPDELTA); }
};

template <class T, int N, class C, C Op> struct ImplSub {
static constexpr C atomic_op = Op;
static constexpr int n_args = 1;
static constexpr int base = 5;
static constexpr T base = (T)(5 + FPDELTA);

static T init(int i, const Config &cfg) {
return (T)(cfg.repeat * cfg.threads_per_group * cfg.n_groups + base);
return (T)(cfg.repeat * cfg.threads_per_group * cfg.n_groups *
(T)(1 + FPDELTA) +
base);
}

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

static T arg0(int i) { return 1; }
static T arg0(int i) { return (T)(1 + FPDELTA); }
};

template <class T, int N, class C, C Op> struct ImplMin {
static constexpr C atomic_op = Op;
static constexpr int n_args = 1;
static constexpr int MIN = 1;
static constexpr T MIN = (T)(1 + FPDELTA);

static T init(int i, const Config &cfg) {
return (T)(cfg.threads_per_group * cfg.n_groups + MIN + 1);
Expand All @@ -387,18 +393,18 @@ template <class T, int N, class C, C Op> struct ImplMin {
template <class T, int N, class C, C Op> struct ImplMax {
static constexpr C atomic_op = Op;
static constexpr int n_args = 1;
static constexpr int base = 5;
static constexpr T base = (T)(5 + FPDELTA);

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

static T gold(int i, const Config &cfg) {
T gold = is_updated(i, N, cfg)
? (T)(cfg.threads_per_group * cfg.n_groups - 1)
? (T)(cfg.threads_per_group * cfg.n_groups - 1 + FPDELTA)
: init(i, cfg);
return gold;
}

static T arg0(int i) { return i; }
static T arg0(int i) { return (T)(i + FPDELTA); }
};

template <class T, int N>
Expand Down Expand Up @@ -438,7 +444,7 @@ struct ImplLSCFmax : ImplMax<T, N, LSCAtomicOp, LSCAtomicOp::fmax> {};
template <class T, int N, class C, C Op> struct ImplCmpxchgBase {
static constexpr C atomic_op = Op;
static constexpr int n_args = 2;
static constexpr int base = 2;
static constexpr T base = (T)(2 + FPDELTA);

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

Expand Down