Skip to content
Open
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
4 changes: 2 additions & 2 deletions sycl/include/sycl/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ class buffer : public detail::buffer_plain,
dimensions, sizeof(T), detail::rangeToArray(Range).data());
}

buffer(buffer &&rhs,
const detail::code_location CodeLoc = detail::code_location::current())
buffer(buffer &&rhs, const detail::code_location CodeLoc =
detail::code_location::current()) noexcept
: buffer_plain(std::move(rhs.impl)), Range(rhs.Range),
OffsetInBytes(rhs.OffsetInBytes), IsSubBuffer(rhs.IsSubBuffer) {
buffer_plain::constructorNotification(
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/sycl/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class __SYCL_STANDALONE_DEBUG __SYCL_EXPORT device {
#endif // __INTEL_PREVIEW_BREAKING_CHANGES
device(const device &rhs);

device(device &&rhs);
device(device &&rhs) noexcept;

device &operator=(const device &rhs) = default;

Expand Down
4 changes: 4 additions & 0 deletions sycl/include/sycl/h_item.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ template <int Dimensions> class h_item {

h_item(const h_item &hi) = default;

h_item(h_item &&hi) = default;

h_item &operator=(const h_item &hi) = default;

h_item &operator=(h_item &&hi) = default;

/* -- public interface members -- */
item<Dimensions, false> get_global() const { return globalItem; }

Expand Down
2 changes: 1 addition & 1 deletion sycl/source/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void force_type(info::device_type &t, const info::device_type &ft) {
device::device() : device(default_selector_v) {}

device::device(const device &rhs) = default;
device::device(device &&rhs) = default;
device::device(device &&rhs) noexcept = default;

device::device(OpenCLDeviceIdT DeviceId) {
detail::adapter_impl &Adapter =
Expand Down
107 changes: 107 additions & 0 deletions sycl/test/basic_tests/common_semantics_noexcept.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// RUN: %clangxx -fsycl -fsyntax-only %s
// RUN: %clangxx -fsycl -fsyntax-only -fpreview-breaking-changes %s

// Checks that the move constructor and the move assignment operator of every
// class with common reference semantics (SYCL 2020 section 3.5.2) and common
// by-value semantics (section 3.5.3) are declared noexcept, as required by
// tables 3 and 5.

#include <sycl/sycl.hpp>

#include <memory>
#include <type_traits>

template <typename T> constexpr bool declaresMoveAssign(T &(T::*)(T &&)) {
return true;
}

#define CHECK_MOVE_NOEXCEPT(...) \
static_assert(std::is_nothrow_move_constructible_v<__VA_ARGS__>, \
#__VA_ARGS__ " must be nothrow move constructible"); \
Comment on lines +19 to +20
static_assert(std::is_nothrow_move_assignable_v<__VA_ARGS__>, \
#__VA_ARGS__ " must be nothrow move assignable"); \
static_assert(declaresMoveAssign<__VA_ARGS__>(&__VA_ARGS__::operator=), \
#__VA_ARGS__ " must declare operator=(" #__VA_ARGS__ " &&)");

// --- Common reference semantics (SYCL 2020 section 3.5.2) -------------------

CHECK_MOVE_NOEXCEPT(sycl::platform)
CHECK_MOVE_NOEXCEPT(sycl::device)
CHECK_MOVE_NOEXCEPT(sycl::context)
CHECK_MOVE_NOEXCEPT(sycl::queue)
CHECK_MOVE_NOEXCEPT(sycl::event)
CHECK_MOVE_NOEXCEPT(sycl::kernel)
CHECK_MOVE_NOEXCEPT(sycl::kernel_id)
CHECK_MOVE_NOEXCEPT(sycl::stream)

CHECK_MOVE_NOEXCEPT(sycl::kernel_bundle<sycl::bundle_state::input>)
CHECK_MOVE_NOEXCEPT(sycl::kernel_bundle<sycl::bundle_state::object>)
CHECK_MOVE_NOEXCEPT(sycl::kernel_bundle<sycl::bundle_state::executable>)

CHECK_MOVE_NOEXCEPT(sycl::device_image<sycl::bundle_state::input>)
CHECK_MOVE_NOEXCEPT(sycl::device_image<sycl::bundle_state::object>)
CHECK_MOVE_NOEXCEPT(sycl::device_image<sycl::bundle_state::executable>)

CHECK_MOVE_NOEXCEPT(sycl::buffer<int, 1>)
CHECK_MOVE_NOEXCEPT(sycl::buffer<int, 2>)
CHECK_MOVE_NOEXCEPT(sycl::buffer<int, 3>)
CHECK_MOVE_NOEXCEPT(sycl::buffer<int, 1, std::allocator<int>>)

CHECK_MOVE_NOEXCEPT(sycl::unsampled_image<1>)
CHECK_MOVE_NOEXCEPT(sycl::unsampled_image<2>)
CHECK_MOVE_NOEXCEPT(sycl::unsampled_image<3>)
CHECK_MOVE_NOEXCEPT(sycl::sampled_image<1>)
CHECK_MOVE_NOEXCEPT(sycl::sampled_image<2>)
CHECK_MOVE_NOEXCEPT(sycl::sampled_image<3>)

CHECK_MOVE_NOEXCEPT(
sycl::accessor<int, 0, sycl::access_mode::read_write, sycl::target::device>)
CHECK_MOVE_NOEXCEPT(
sycl::accessor<int, 1, sycl::access_mode::read, sycl::target::device>)
CHECK_MOVE_NOEXCEPT(
sycl::accessor<int, 2, sycl::access_mode::write, sycl::target::device>)
CHECK_MOVE_NOEXCEPT(
sycl::accessor<int, 3, sycl::access_mode::read_write, sycl::target::device>)
CHECK_MOVE_NOEXCEPT(sycl::accessor<int, 1, sycl::access_mode::read_write,
sycl::target::host_task>)

CHECK_MOVE_NOEXCEPT(sycl::local_accessor<int, 0>)
CHECK_MOVE_NOEXCEPT(sycl::local_accessor<int, 1>)
CHECK_MOVE_NOEXCEPT(sycl::local_accessor<int, 3>)

CHECK_MOVE_NOEXCEPT(sycl::host_accessor<int, 0>)
CHECK_MOVE_NOEXCEPT(sycl::host_accessor<int, 1>)
CHECK_MOVE_NOEXCEPT(sycl::host_accessor<int, 3>)

CHECK_MOVE_NOEXCEPT(
sycl::unsampled_image_accessor<sycl::int4, 1, sycl::access_mode::read>)
CHECK_MOVE_NOEXCEPT(
sycl::unsampled_image_accessor<sycl::int4, 3, sycl::access_mode::write>)
CHECK_MOVE_NOEXCEPT(sycl::host_unsampled_image_accessor<sycl::int4, 1>)
CHECK_MOVE_NOEXCEPT(sycl::host_unsampled_image_accessor<sycl::int4, 3>)
CHECK_MOVE_NOEXCEPT(sycl::sampled_image_accessor<sycl::float4, 1>)
CHECK_MOVE_NOEXCEPT(sycl::sampled_image_accessor<sycl::float4, 3>)
CHECK_MOVE_NOEXCEPT(sycl::host_sampled_image_accessor<sycl::float4, 1>)
CHECK_MOVE_NOEXCEPT(sycl::host_sampled_image_accessor<sycl::float4, 3>)

// --- Common by-value semantics (SYCL 2020 section 3.5.3) -------------------

CHECK_MOVE_NOEXCEPT(sycl::id<1>)
CHECK_MOVE_NOEXCEPT(sycl::id<2>)
CHECK_MOVE_NOEXCEPT(sycl::id<3>)
CHECK_MOVE_NOEXCEPT(sycl::range<1>)
CHECK_MOVE_NOEXCEPT(sycl::range<2>)
CHECK_MOVE_NOEXCEPT(sycl::range<3>)
CHECK_MOVE_NOEXCEPT(sycl::item<1, true>)
CHECK_MOVE_NOEXCEPT(sycl::item<1, false>)
CHECK_MOVE_NOEXCEPT(sycl::item<3, true>)
CHECK_MOVE_NOEXCEPT(sycl::item<3, false>)
CHECK_MOVE_NOEXCEPT(sycl::nd_item<1>)
CHECK_MOVE_NOEXCEPT(sycl::nd_item<3>)
CHECK_MOVE_NOEXCEPT(sycl::h_item<1>)
CHECK_MOVE_NOEXCEPT(sycl::h_item<3>)
CHECK_MOVE_NOEXCEPT(sycl::group<1>)
CHECK_MOVE_NOEXCEPT(sycl::group<3>)
CHECK_MOVE_NOEXCEPT(sycl::sub_group)
CHECK_MOVE_NOEXCEPT(sycl::nd_range<1>)
CHECK_MOVE_NOEXCEPT(sycl::nd_range<3>)
Loading