Skip to content

Private/asachkov/for testing #19043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 10 commits into
base: sycl
Choose a base branch
from
Draft
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
16 changes: 9 additions & 7 deletions sycl/include/sycl/accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#pragma once

#include <sycl/access/access.hpp> // for target, mode
#include <sycl/atomic.hpp> // for atomic
#include <sycl/access/access.hpp> // for target, mode
#include <sycl/detail/defines.hpp>
#include <sycl/buffer.hpp> // for range
#include <sycl/detail/accessor_iterator.hpp> // for accessor_iterator
#include <sycl/detail/common.hpp> // for code_location
Expand Down Expand Up @@ -215,6 +215,8 @@
namespace sycl {
inline namespace _V1 {
class stream;
template <typename T, access::address_space addressSpace> class atomic;

namespace ext::intel::esimd::detail {
// Forward declare a "back-door" access class to support ESIMD.
class AccessorPrivateProxy;
Expand Down Expand Up @@ -1755,14 +1757,14 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
}

template <int Dims = Dimensions>
operator typename std::enable_if_t<Dims == 0 &&
AccessMode == access::mode::atomic,
operator typename std::enable_if_t<
Dims == 0 && AccessMode == access::mode::atomic,
#ifdef __ENABLE_USM_ADDR_SPACE__
atomic<DataT>
atomic<DataT, access::address_space::global_space>
#else
atomic<DataT, AS>
atomic<DataT, AS>
#endif
>() const {
>() const {
const size_t LinearIndex = getLinearIndex(id<AdjustedDim>());
return atomic<DataT, AS>(multi_ptr<DataT, AS, access::decorated::yes>(
getQualifiedPtr() + LinearIndex));
Expand Down
1 change: 1 addition & 0 deletions sycl/include/sycl/atomic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#pragma once

#include <sycl/__spirv/spirv_ops.hpp>
#include <sycl/__spirv/spirv_types.hpp> // for Scope, MemorySemanticsMask
#include <sycl/access/access.hpp> // for address_space, decorated
#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEPRECATED
Expand Down
21 changes: 21 additions & 0 deletions sycl/include/sycl/detail/assume_int.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#pragma once

#include <sycl/detail/defines_elementary.hpp> // for __SYCL_ID_QUERIES_FIT_...

#if __SYCL_ID_QUERIES_FIT_IN_INT__ && __has_builtin(__builtin_assume)
#include <climits>
#define __SYCL_ASSUME_INT(x) __builtin_assume((x) <= INT_MAX)
#else
#define __SYCL_ASSUME_INT(x)
#if __SYCL_ID_QUERIES_FIT_IN_INT__ && !__has_builtin(__builtin_assume)
#warning "No assumptions will be emitted due to no __builtin_assume available"
#endif
#endif
12 changes: 1 addition & 11 deletions sycl/include/sycl/detail/defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,7 @@

#pragma once

#include <sycl/detail/defines_elementary.hpp> // for __SYCL_ID_QUERIES_FIT_...

#if __SYCL_ID_QUERIES_FIT_IN_INT__ && __has_builtin(__builtin_assume)
#include <climits>
#define __SYCL_ASSUME_INT(x) __builtin_assume((x) <= INT_MAX)
#else
#define __SYCL_ASSUME_INT(x)
#if __SYCL_ID_QUERIES_FIT_IN_INT__ && !__has_builtin(__builtin_assume)
#warning "No assumptions will be emitted due to no __builtin_assume available"
#endif
#endif
#include <sycl/detail/defines_elementary.hpp>

// FIXME Check for __SYCL_DEVICE_ONLY__ can be removed if implementation of
// __has_attribute is fixed to consider LangOpts when generating attributes in
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/sycl/id.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <sycl/detail/array.hpp> // for array
#include <sycl/detail/common.hpp> // for InitializedVal
#include <sycl/detail/defines.hpp> // for __SYCL_ASSUME_INT
#include <sycl/detail/assume_int.hpp> // for __SYCL_ASSUME_INT
#include <sycl/detail/defines_elementary.hpp> // for __SYCL_DEPRECATED, __SYCL_A...
#include <sycl/exception.hpp> // for make_error_code, errc, exce...
#include <sycl/range.hpp> // for range
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/sycl/item.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#pragma once

#include <sycl/detail/defines.hpp> // for __SYCL_ASSUME_INT
#include <sycl/detail/assume_int.hpp> // for __SYCL_ASSUME_INT
#include <sycl/detail/defines_elementary.hpp> // for __SYCL_ALWAYS_INLINE, __SYC...
#include <sycl/detail/helpers.hpp> // for Builder
#include <sycl/detail/item_base.hpp> // for id, range, ItemBase
Expand Down
1 change: 1 addition & 0 deletions sycl/include/sycl/nd_item.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#pragma once

#include <sycl/detail/defines.hpp> // for __SYCL_ASSUME_INT
#include <sycl/__spirv/spirv_types.hpp> // for Scope
#include <sycl/__spirv/spirv_vars.hpp> // for initLocalInvocationId
#include <sycl/access/access.hpp> // for mode, fence_space
Expand Down
2 changes: 2 additions & 0 deletions sycl/test-e2e/Basic/accessor/accessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
//===----------------------------------------------------------------------===//
#include <cassert>
#include <iostream>

#include <sycl/atomic.hpp>
#include <sycl/detail/core.hpp>

struct IdxID1 {
Expand Down
1 change: 1 addition & 0 deletions sycl/test-e2e/Basic/compare_exchange_strong.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out

#include <sycl/atomic.hpp>
#include <sycl/detail/core.hpp>
using namespace sycl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
// RUN: %{build} -sycl-std=2020 -o %t2.out
// RUN: env SYCL_PARALLEL_FOR_RANGE_ROUNDING_TRACE=1 %{run} %t2.out | FileCheck %s --check-prefix CHECK-ENABLED

#include <iostream>
#include <sycl/atomic.hpp>
#include <sycl/detail/core.hpp>

#include <iostream>
using namespace sycl;

range<1> Range1 = {0};
Expand Down
4 changes: 3 additions & 1 deletion sycl/test-e2e/Basic/parallel_for_range_roundup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
// UNSUPPORTED: hip
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/17077
//
#include <iostream>
#include <sycl/atomic.hpp>
#include <sycl/detail/core.hpp>
#include <sycl/vector.hpp>

#include <iostream>

using namespace sycl;

constexpr size_t MagicY = 33, MagicZ = 64;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// This test checks edge cases handling for std::exp(std::complex<T>) used
// in SYCL kernels.

#include <cmath>

#include <sycl/detail/core.hpp>

#include <cmath>
#include <complex>
#include <type_traits>

Expand Down
2 changes: 2 additions & 0 deletions sycl/test-e2e/Regression/atomic_load.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
#include <sycl/atomic.hpp>
#include <sycl/detail/core.hpp>

using namespace sycl;

template <typename T> class foo;
Expand Down
1 change: 1 addition & 0 deletions sycl/test-e2e/Regression/implicit_atomic_conversion.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// RUN: %{build} -Wno-error=deprecated-declarations -o %t.out
// RUN: %{run} %t.out

#include <sycl/atomic.hpp>
#include <sycl/detail/core.hpp>

using namespace sycl;
Expand Down
1 change: 1 addition & 0 deletions sycl/test-e2e/XPTI/buffer/accessors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#else

#include <sycl/atomic.hpp>
#include <sycl/detail/core.hpp>

using namespace sycl::access;
Expand Down
35 changes: 17 additions & 18 deletions sycl/test/include_deps/sycl_accessor.hpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,21 @@
// CHECK-NEXT: accessor.hpp
// CHECK-NEXT: access/access.hpp
// CHECK-NEXT: detail/defines_elementary.hpp
// CHECK-NEXT: atomic.hpp
// CHECK-NEXT: __spirv/spirv_types.hpp
// CHECK-NEXT: detail/defines.hpp
// CHECK-NEXT: detail/helpers.hpp
// CHECK-NEXT: detail/export.hpp
// CHECK-NEXT: memory_enums.hpp
// CHECK-NEXT: __spirv/spirv_vars.hpp
// CHECK-NEXT: multi_ptr.hpp
// CHECK-NEXT: aliases.hpp
// CHECK-NEXT: detail/address_space_cast.hpp
// CHECK-NEXT: detail/type_traits.hpp
// CHECK-NEXT: detail/type_traits/vec_marray_traits.hpp
// CHECK-NEXT: half_type.hpp
// CHECK-NEXT: bit_cast.hpp
// CHECK-NEXT: detail/iostream_proxy.hpp
// CHECK-NEXT: aspects.hpp
// CHECK-NEXT: info/aspects.def
// CHECK-NEXT: info/aspects_deprecated.def
// CHECK-NEXT: buffer.hpp
// CHECK-NEXT: backend_types.hpp
// CHECK-NEXT: detail/array.hpp
// CHECK-NEXT: exception.hpp
// CHECK-NEXT: detail/export.hpp
// CHECK-NEXT: detail/string.hpp
// CHECK-NEXT: detail/common.hpp
// CHECK-NEXT: stl_wrappers/cassert
// CHECK-NEXT: stl_wrappers/assert.h
// CHECK-NEXT: __spirv/spirv_vars.hpp
// CHECK-NEXT: __spirv/spirv_types.hpp
// CHECK-NEXT: detail/defines.hpp
// CHECK-NEXT: detail/helpers.hpp
// CHECK-NEXT: memory_enums.hpp
// CHECK-NEXT: detail/iostream_proxy.hpp
// CHECK-NEXT: detail/is_device_copyable.hpp
// CHECK-NEXT: detail/owner_less_base.hpp
// CHECK-NEXT: detail/impl_utils.hpp
Expand All @@ -51,6 +40,16 @@
// CHECK-NEXT: ur_api.h
// CHECK-NEXT: detail/accessor_iterator.hpp
// CHECK-NEXT: detail/generic_type_traits.hpp
// CHECK-NEXT: aliases.hpp
// CHECK-NEXT: detail/type_traits.hpp
// CHECK-NEXT: detail/type_traits/vec_marray_traits.hpp
// CHECK-NEXT: half_type.hpp
// CHECK-NEXT: bit_cast.hpp
// CHECK-NEXT: aspects.hpp
// CHECK-NEXT: info/aspects.def
// CHECK-NEXT: info/aspects_deprecated.def
// CHECK-NEXT: multi_ptr.hpp
// CHECK-NEXT: detail/address_space_cast.hpp
// CHECK-NEXT: ext/oneapi/bfloat16.hpp
// CHECK-NEXT: detail/handler_proxy.hpp
// CHECK-NEXT: pointers.hpp
Expand Down
35 changes: 17 additions & 18 deletions sycl/test/include_deps/sycl_detail_core.hpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,21 @@
// CHECK-NEXT: accessor.hpp
// CHECK-NEXT: access/access.hpp
// CHECK-NEXT: detail/defines_elementary.hpp
// CHECK-NEXT: atomic.hpp
// CHECK-NEXT: __spirv/spirv_types.hpp
// CHECK-NEXT: detail/defines.hpp
// CHECK-NEXT: detail/helpers.hpp
// CHECK-NEXT: detail/export.hpp
// CHECK-NEXT: memory_enums.hpp
// CHECK-NEXT: __spirv/spirv_vars.hpp
// CHECK-NEXT: multi_ptr.hpp
// CHECK-NEXT: aliases.hpp
// CHECK-NEXT: detail/address_space_cast.hpp
// CHECK-NEXT: detail/type_traits.hpp
// CHECK-NEXT: detail/type_traits/vec_marray_traits.hpp
// CHECK-NEXT: half_type.hpp
// CHECK-NEXT: bit_cast.hpp
// CHECK-NEXT: detail/iostream_proxy.hpp
// CHECK-NEXT: aspects.hpp
// CHECK-NEXT: info/aspects.def
// CHECK-NEXT: info/aspects_deprecated.def
// CHECK-NEXT: buffer.hpp
// CHECK-NEXT: backend_types.hpp
// CHECK-NEXT: detail/array.hpp
// CHECK-NEXT: exception.hpp
// CHECK-NEXT: detail/export.hpp
// CHECK-NEXT: detail/string.hpp
// CHECK-NEXT: detail/common.hpp
// CHECK-NEXT: stl_wrappers/cassert
// CHECK-NEXT: stl_wrappers/assert.h
// CHECK-NEXT: __spirv/spirv_vars.hpp
// CHECK-NEXT: __spirv/spirv_types.hpp
// CHECK-NEXT: detail/defines.hpp
// CHECK-NEXT: detail/helpers.hpp
// CHECK-NEXT: memory_enums.hpp
// CHECK-NEXT: detail/iostream_proxy.hpp
// CHECK-NEXT: detail/is_device_copyable.hpp
// CHECK-NEXT: detail/owner_less_base.hpp
// CHECK-NEXT: detail/impl_utils.hpp
Expand All @@ -52,6 +41,16 @@
// CHECK-NEXT: ur_api.h
// CHECK-NEXT: detail/accessor_iterator.hpp
// CHECK-NEXT: detail/generic_type_traits.hpp
// CHECK-NEXT: aliases.hpp
// CHECK-NEXT: detail/type_traits.hpp
// CHECK-NEXT: detail/type_traits/vec_marray_traits.hpp
// CHECK-NEXT: half_type.hpp
// CHECK-NEXT: bit_cast.hpp
// CHECK-NEXT: aspects.hpp
// CHECK-NEXT: info/aspects.def
// CHECK-NEXT: info/aspects_deprecated.def
// CHECK-NEXT: multi_ptr.hpp
// CHECK-NEXT: detail/address_space_cast.hpp
// CHECK-NEXT: ext/oneapi/bfloat16.hpp
// CHECK-NEXT: detail/handler_proxy.hpp
// CHECK-NEXT: pointers.hpp
Expand Down
74 changes: 74 additions & 0 deletions sycl/test/regression/atomic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// RUN: %clangxx -fsycl -fsyntax-only -Wno-deprecated-declarations -Xclang -verify %s
// expected-no-diagnostics

#include <sycl/atomic.hpp>
#include <sycl/multi_ptr.hpp>

SYCL_EXTERNAL void
store(sycl::multi_ptr<int, sycl::access::address_space::global_space> mptr,
int value) {
sycl::atomic<int> a(mptr);
a.store(value);
}

SYCL_EXTERNAL int
load(sycl::multi_ptr<int, sycl::access::address_space::global_space> mptr) {
sycl::atomic<int> a(mptr);
return a.load();
}

SYCL_EXTERNAL int
exchange(sycl::multi_ptr<int, sycl::access::address_space::global_space> mptr,
int value) {
sycl::atomic<int> a(mptr);
return a.exchange(value);
}

SYCL_EXTERNAL int
fetch_add(sycl::multi_ptr<int, sycl::access::address_space::global_space> mptr,
int value) {
sycl::atomic<int> a(mptr);
return a.fetch_add(value);
}

SYCL_EXTERNAL int
fetch_sub(sycl::multi_ptr<int, sycl::access::address_space::global_space> mptr,
int value) {
sycl::atomic<int> a(mptr);
return a.fetch_sub(value);
}

SYCL_EXTERNAL int
fetch_and(sycl::multi_ptr<int, sycl::access::address_space::global_space> mptr,
int value) {
sycl::atomic<int> a(mptr);
return a.fetch_and(value);
}

SYCL_EXTERNAL int
fetch_or(sycl::multi_ptr<int, sycl::access::address_space::global_space> mptr,
int value) {
sycl::atomic<int> a(mptr);
return a.fetch_or(value);
}

SYCL_EXTERNAL int
fetch_xor(sycl::multi_ptr<int, sycl::access::address_space::global_space> mptr,
int value) {
sycl::atomic<int> a(mptr);
return a.fetch_xor(value);
}

SYCL_EXTERNAL int
fetch_min(sycl::multi_ptr<int, sycl::access::address_space::global_space> mptr,
int value) {
sycl::atomic<int> a(mptr);
return a.fetch_min(value);
}

SYCL_EXTERNAL int
fetch_max(sycl::multi_ptr<int, sycl::access::address_space::global_space> mptr,
int value) {
sycl::atomic<int> a(mptr);
return a.fetch_max(value);
}
Loading