Skip to content

Commit 3906cea

Browse files
[NFC][SYCL] Prefer (void) over std::ignore (#20088)
One of my recent PRs to reduce header dependencies of `id/item/range/etc.` has caused some compile time errors downstream with `std::ignore` not being declared because we use different version of STL than the one in the upstream CI. We do want to have our device headers as lightweight as possible (especially in the context of SYCL RTC), so it makes sense to just use `(void)` uniformly instead of `std::ignore`. UR experience also found that the compile-time price of `(void)` is smaller as well.
1 parent 68f3fdf commit 3906cea

File tree

13 files changed

+208
-208
lines changed

13 files changed

+208
-208
lines changed

sycl/include/sycl/accessor_image.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ class __SYCL_EBO unsampled_image_accessor :
907907
DataT read(const CoordT &Coords) const noexcept {
908908
#ifdef __SYCL_DEVICE_ONLY__
909909
// Currently not reachable on device.
910-
std::ignore = Coords;
910+
(void)Coords;
911911
return {0, 0, 0, 0};
912912
#else
913913
return host_base_class::read<DataT>(Coords);
@@ -925,8 +925,8 @@ class __SYCL_EBO unsampled_image_accessor :
925925
void write(const CoordT &Coords, const DataT &Color) const {
926926
#ifdef __SYCL_DEVICE_ONLY__
927927
// Currently not reachable on device.
928-
std::ignore = Coords;
929-
std::ignore = Color;
928+
(void)Coords;
929+
(void)Color;
930930
#else
931931
host_base_class::write<DataT>(Coords, Color);
932932
#endif // __SYCL_DEVICE_ONLY__
@@ -938,7 +938,7 @@ class __SYCL_EBO unsampled_image_accessor :
938938
: host_base_class{Impl}
939939
#endif // __SYCL_DEVICE_ONLY__
940940
{
941-
std::ignore = Impl;
941+
(void)Impl;
942942
}
943943

944944
template <class Obj>
@@ -1216,7 +1216,7 @@ class __SYCL_EBO sampled_image_accessor :
12161216
DataT read(const CoordT &Coords) const noexcept {
12171217
#ifdef __SYCL_DEVICE_ONLY__
12181218
// Currently not reachable on device.
1219-
std::ignore = Coords;
1219+
(void)Coords;
12201220
return {0, 0, 0, 0};
12211221
#else
12221222
return host_base_class::read<DataT>(Coords);
@@ -1229,7 +1229,7 @@ class __SYCL_EBO sampled_image_accessor :
12291229
: host_base_class{Impl}
12301230
#endif // __SYCL_DEVICE_ONLY__
12311231
{
1232-
std::ignore = Impl;
1232+
(void)Impl;
12331233
}
12341234

12351235
template <class Obj>

sycl/include/sycl/detail/spirv.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ template <typename GroupT, typename T>
924924
EnableIfNativeShuffle<T> Shuffle(GroupT g, T x, id<1> local_id) {
925925
uint32_t LocalId = MapShuffleID(g, local_id);
926926
#ifndef __NVPTX__
927-
std::ignore = g;
927+
(void)g;
928928
if constexpr (ext::oneapi::experimental::is_user_constructed_group_v<
929929
GroupT> &&
930930
detail::is_vec<T>::value) {
@@ -957,7 +957,7 @@ EnableIfNativeShuffle<T> Shuffle(GroupT g, T x, id<1> local_id) {
957957
template <typename GroupT, typename T>
958958
EnableIfNativeShuffle<T> ShuffleXor(GroupT g, T x, id<1> mask) {
959959
#ifndef __NVPTX__
960-
std::ignore = g;
960+
(void)g;
961961
if constexpr (ext::oneapi::experimental::is_user_constructed_group_v<
962962
GroupT> &&
963963
detail::is_vec<T>::value) {

sycl/include/sycl/ext/intel/esimd/memory.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2155,7 +2155,7 @@ __ESIMD_API simd<Tx, N> block_load(AccessorTy acc,
21552155
return block_load<Tx, N>(__ESIMD_DNS::accessorToPointer<Tx>(acc, byte_offset),
21562156
flags);
21572157
#else
2158-
std::ignore = flags;
2158+
(void)flags;
21592159
constexpr unsigned Sz = sizeof(T) * N;
21602160
static_assert(Sz >= detail::OperandSize::OWORD,
21612161
"block size must be at least 1 oword");

sycl/include/sycl/ext/intel/experimental/pipes.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class pipe : public pipe_base {
110110
static _dataT read(queue &Q, bool &Success,
111111
memory_order Order = memory_order::seq_cst) {
112112
// Order is currently unused.
113-
std::ignore = Order;
113+
(void)Order;
114114

115115
const device Dev = Q.get_device();
116116
bool IsPipeSupported =
@@ -139,7 +139,7 @@ class pipe : public pipe_base {
139139
static void write(queue &Q, const _dataT &Data, bool &Success,
140140
memory_order Order = memory_order::seq_cst) {
141141
// Order is currently unused.
142-
std::ignore = Order;
142+
(void)Order;
143143

144144
const device Dev = Q.get_device();
145145
bool IsPipeSupported =
@@ -267,7 +267,7 @@ class pipe : public pipe_base {
267267
// Host API
268268
static _dataT read(queue &Q, memory_order Order = memory_order::seq_cst) {
269269
// Order is currently unused.
270-
std::ignore = Order;
270+
(void)Order;
271271

272272
const device Dev = Q.get_device();
273273
bool IsPipeSupported =
@@ -290,7 +290,7 @@ class pipe : public pipe_base {
290290
static void write(queue &Q, const _dataT &Data,
291291
memory_order Order = memory_order::seq_cst) {
292292
// Order is currently unused.
293-
std::ignore = Order;
293+
(void)Order;
294294

295295
const device Dev = Q.get_device();
296296
bool IsPipeSupported =

sycl/include/sycl/ext/oneapi/experimental/prefetch.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ void prefetch_impl(T *ptr, size_t bytes, Properties properties) {
9090
}
9191
__spirv_ocl_prefetch(ptrAnnotated, bytes);
9292
#else
93-
std::ignore = ptr;
94-
std::ignore = bytes;
95-
std::ignore = properties;
93+
(void)ptr;
94+
(void)bytes;
95+
(void)properties;
9696
#endif
9797
}
9898

@@ -101,7 +101,7 @@ void joint_prefetch_impl(Group g, T *ptr, size_t bytes, Properties properties) {
101101
// Although calling joint_prefetch is functionally equivalent to calling
102102
// prefetch from every work-item in a group, native suppurt may be added to to
103103
// issue cooperative prefetches more efficiently on some hardware.
104-
std::ignore = g;
104+
(void)g;
105105
prefetch_impl(ptr, bytes, properties);
106106
}
107107
} // namespace detail

sycl/include/sycl/ext/oneapi/experimental/user_defined_reductions.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ T reduce_over_group_impl(GroupHelper group_helper, T x, size_t num_elements,
3333
group_barrier(g);
3434
return group_broadcast(g, result);
3535
#else
36-
std::ignore = group_helper;
37-
std::ignore = x;
38-
std::ignore = num_elements;
39-
std::ignore = binary_op;
36+
(void)group_helper;
37+
(void)x;
38+
(void)num_elements;
39+
(void)binary_op;
4040
throw exception(make_error_code(errc::runtime),
4141
"Group algorithms are not supported on host.");
4242
#endif
@@ -73,7 +73,7 @@ reduce_over_group(GroupHelper group_helper, V x, T init,
7373
#ifdef __SYCL_DEVICE_ONLY__
7474
return binary_op(init, reduce_over_group(group_helper, x, binary_op));
7575
#else
76-
std::ignore = group_helper;
76+
(void)group_helper;
7777
throw exception(make_error_code(errc::runtime),
7878
"Group algorithms are not supported on host.");
7979
#endif
@@ -107,10 +107,10 @@ joint_reduce(GroupHelper group_helper, Ptr first, Ptr last,
107107
return detail::reduce_over_group_impl(group_helper, partial, num_elements,
108108
binary_op);
109109
#else
110-
std::ignore = group_helper;
111-
std::ignore = first;
112-
std::ignore = last;
113-
std::ignore = binary_op;
110+
(void)group_helper;
111+
(void)first;
112+
(void)last;
113+
(void)binary_op;
114114
throw exception(make_error_code(errc::runtime),
115115
"Group algorithms are not supported on host.");
116116
#endif
@@ -129,8 +129,8 @@ joint_reduce(GroupHelper group_helper, Ptr first, Ptr last, T init,
129129
#ifdef __SYCL_DEVICE_ONLY__
130130
return binary_op(init, joint_reduce(group_helper, first, last, binary_op));
131131
#else
132-
std::ignore = group_helper;
133-
std::ignore = last;
132+
(void)group_helper;
133+
(void)last;
134134
throw exception(make_error_code(errc::runtime),
135135
"Group algorithms are not supported on host.");
136136
#endif

0 commit comments

Comments
 (0)