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

Commit 70a8337

Browse files
authored
[ESIMD] Make more thorough check for atomic operations with floating point (#1458)
1 parent a2fef0c commit 70a8337

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

SYCL/ESIMD/lsc/atomic_smoke.cpp

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -340,43 +340,49 @@ template <class T, int N> struct ImplDec {
340340
}
341341
};
342342

343+
// The purpose of this is validate that floating point data is correctly
344+
// processed.
345+
constexpr float FPDELTA = 0.5f;
346+
343347
template <class T, int N, class C, C Op> struct ImplAdd {
344348
static constexpr C atomic_op = Op;
345349
static constexpr int n_args = 1;
346350

347-
static T init(int i, const Config &cfg) { return (T)0; }
351+
static T init(int i, const Config &cfg) { return 0; }
348352

349353
static T gold(int i, const Config &cfg) {
350-
T gold = is_updated(i, N, cfg)
351-
? (T)(cfg.repeat * cfg.threads_per_group * cfg.n_groups)
352-
: init(i, cfg);
354+
T gold = is_updated(i, N, cfg) ? (T)(cfg.repeat * cfg.threads_per_group *
355+
cfg.n_groups * (T)(1 + FPDELTA))
356+
: init(i, cfg);
353357
return gold;
354358
}
355359

356-
static T arg0(int i) { return 1; }
360+
static T arg0(int i) { return (T)(1 + FPDELTA); }
357361
};
358362

359363
template <class T, int N, class C, C Op> struct ImplSub {
360364
static constexpr C atomic_op = Op;
361365
static constexpr int n_args = 1;
362-
static constexpr int base = 5;
366+
static constexpr T base = (T)(5 + FPDELTA);
363367

364368
static T init(int i, const Config &cfg) {
365-
return (T)(cfg.repeat * cfg.threads_per_group * cfg.n_groups + base);
369+
return (T)(cfg.repeat * cfg.threads_per_group * cfg.n_groups *
370+
(T)(1 + FPDELTA) +
371+
base);
366372
}
367373

368374
static T gold(int i, const Config &cfg) {
369-
T gold = is_updated(i, N, cfg) ? (T)base : init(i, cfg);
375+
T gold = is_updated(i, N, cfg) ? base : init(i, cfg);
370376
return gold;
371377
}
372378

373-
static T arg0(int i) { return 1; }
379+
static T arg0(int i) { return (T)(1 + FPDELTA); }
374380
};
375381

376382
template <class T, int N, class C, C Op> struct ImplMin {
377383
static constexpr C atomic_op = Op;
378384
static constexpr int n_args = 1;
379-
static constexpr int MIN = 1;
385+
static constexpr T MIN = (T)(1 + FPDELTA);
380386

381387
static T init(int i, const Config &cfg) {
382388
return (T)(cfg.threads_per_group * cfg.n_groups + MIN + 1);
@@ -393,18 +399,18 @@ template <class T, int N, class C, C Op> struct ImplMin {
393399
template <class T, int N, class C, C Op> struct ImplMax {
394400
static constexpr C atomic_op = Op;
395401
static constexpr int n_args = 1;
396-
static constexpr int base = 5;
402+
static constexpr T base = (T)(5 + FPDELTA);
397403

398-
static T init(int i, const Config &cfg) { return 0; }
404+
static T init(int i, const Config &cfg) { return (T)FPDELTA; }
399405

400406
static T gold(int i, const Config &cfg) {
401407
T gold = is_updated(i, N, cfg)
402-
? (T)(cfg.threads_per_group * cfg.n_groups - 1)
408+
? (T)(cfg.threads_per_group * cfg.n_groups - 1 + FPDELTA)
403409
: init(i, cfg);
404410
return gold;
405411
}
406412

407-
static T arg0(int i) { return i; }
413+
static T arg0(int i) { return (T)(i + FPDELTA); }
408414
};
409415

410416
template <class T, int N>
@@ -444,7 +450,7 @@ struct ImplLSCFmax : ImplMax<T, N, LSCAtomicOp, LSCAtomicOp::fmax> {};
444450
template <class T, int N, class C, C Op> struct ImplCmpxchgBase {
445451
static constexpr C atomic_op = Op;
446452
static constexpr int n_args = 2;
447-
static constexpr int base = 2;
453+
static constexpr T base = (T)(2 + FPDELTA);
448454

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

0 commit comments

Comments
 (0)