Skip to content

Commit 3de0989

Browse files
[SYCL] Fix sycl::atomic regression (#19015)
This is a follow-up for #18839 which broke host compilation of `sycl::atomic`. The actual fix is just an addition of `#include <sycl/__spirv/spirv_ops.hpp>` to `sycl/atomic.hpp`. However, I didn't want `spirv_ops.hpp` to appear again in `sycl/detail/core.hpp` and therefore I went further to make sure that `sycl/atomic.hpp` isn't used by `sycl/accessor.hpp` which prompted other changes in this PR.
1 parent adf3592 commit 3de0989

File tree

13 files changed

+133
-45
lines changed

13 files changed

+133
-45
lines changed

sycl/include/sycl/accessor.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#pragma once
1010

1111
#include <sycl/access/access.hpp> // for target, mode
12-
#include <sycl/atomic.hpp> // for atomic
1312
#include <sycl/buffer.hpp> // for range
1413
#include <sycl/detail/accessor_iterator.hpp> // for accessor_iterator
1514
#include <sycl/detail/common.hpp> // for code_location
@@ -215,6 +214,8 @@
215214
namespace sycl {
216215
inline namespace _V1 {
217216
class stream;
217+
template <typename T, access::address_space addressSpace> class atomic;
218+
218219
namespace ext::intel::esimd::detail {
219220
// Forward declare a "back-door" access class to support ESIMD.
220221
class AccessorPrivateProxy;
@@ -1755,14 +1756,14 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
17551756
}
17561757

17571758
template <int Dims = Dimensions>
1758-
operator typename std::enable_if_t<Dims == 0 &&
1759-
AccessMode == access::mode::atomic,
1759+
operator typename std::enable_if_t<
1760+
Dims == 0 && AccessMode == access::mode::atomic,
17601761
#ifdef __ENABLE_USM_ADDR_SPACE__
1761-
atomic<DataT>
1762+
atomic<DataT, access::address_space::global_space>
17621763
#else
1763-
atomic<DataT, AS>
1764+
atomic<DataT, AS>
17641765
#endif
1765-
>() const {
1766+
>() const {
17661767
const size_t LinearIndex = getLinearIndex(id<AdjustedDim>());
17671768
return atomic<DataT, AS>(multi_ptr<DataT, AS, access::decorated::yes>(
17681769
getQualifiedPtr() + LinearIndex));

sycl/include/sycl/atomic.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#pragma once
1010

11+
#include <sycl/__spirv/spirv_ops.hpp>
1112
#include <sycl/__spirv/spirv_types.hpp> // for Scope, MemorySemanticsMask
1213
#include <sycl/access/access.hpp> // for address_space, decorated
1314
#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEPRECATED

sycl/test-e2e/Basic/accessor/accessor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
//===----------------------------------------------------------------------===//
1616
#include <cassert>
1717
#include <iostream>
18+
19+
#include <sycl/atomic.hpp>
1820
#include <sycl/detail/core.hpp>
1921

2022
struct IdxID1 {

sycl/test-e2e/Basic/compare_exchange_strong.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %{build} -o %t.out
22
// RUN: %{run} %t.out
33

4+
#include <sycl/atomic.hpp>
45
#include <sycl/detail/core.hpp>
56
using namespace sycl;
67

sycl/test-e2e/Basic/parallel_for_disable_range_roundup.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
// RUN: %{build} -sycl-std=2020 -o %t2.out
77
// RUN: env SYCL_PARALLEL_FOR_RANGE_ROUNDING_TRACE=1 %{run} %t2.out | FileCheck %s --check-prefix CHECK-ENABLED
88

9-
#include <iostream>
9+
#include <sycl/atomic.hpp>
1010
#include <sycl/detail/core.hpp>
11+
12+
#include <iostream>
1113
using namespace sycl;
1214

1315
range<1> Range1 = {0};

sycl/test-e2e/Basic/parallel_for_range_roundup.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@
2525
// UNSUPPORTED: hip
2626
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/17077
2727
//
28-
#include <iostream>
28+
#include <sycl/atomic.hpp>
2929
#include <sycl/detail/core.hpp>
3030
#include <sycl/vector.hpp>
3131

32+
#include <iostream>
33+
3234
using namespace sycl;
3335

3436
constexpr size_t MagicY = 33, MagicZ = 64;

sycl/test-e2e/DeviceLib/exp/exp-std-complex-edge-cases.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
// This test checks edge cases handling for std::exp(std::complex<T>) used
22
// in SYCL kernels.
33

4+
// This include should happen before <sycl/detail/core.hpp> or otherwise NAN
5+
// may not be constexpr on some Windows configurations. See intel/llvm#19114
6+
#include <cmath>
7+
48
#include <sycl/detail/core.hpp>
59

6-
#include <cmath>
710
#include <complex>
811
#include <type_traits>
912

sycl/test-e2e/Regression/atomic_load.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// RUN: %{build} -o %t.out
22
// RUN: %{run} %t.out
3+
#include <sycl/atomic.hpp>
34
#include <sycl/detail/core.hpp>
5+
46
using namespace sycl;
57

68
template <typename T> class foo;

sycl/test-e2e/Regression/implicit_atomic_conversion.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %{build} -Wno-error=deprecated-declarations -o %t.out
22
// RUN: %{run} %t.out
33

4+
#include <sycl/atomic.hpp>
45
#include <sycl/detail/core.hpp>
56

67
using namespace sycl;

sycl/test-e2e/XPTI/buffer/accessors.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#else
1111

12+
#include <sycl/atomic.hpp>
1213
#include <sycl/detail/core.hpp>
1314

1415
using namespace sycl::access;

0 commit comments

Comments
 (0)