Skip to content

Commit 63ba1ce

Browse files
author
Alexander Batashev
authored
[SYCL] Move free function queries to experimental namespace (#4090)
1 parent 66770f0 commit 63ba1ce

File tree

9 files changed

+123
-15
lines changed

9 files changed

+123
-15
lines changed

sycl/doc/extensions/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ DPC++ extensions status:
4343
| [Uniform](Uniform/Uniform.asciidoc) | Proposal | |
4444
| [Assert](Assert/SYCL_ONEAPI_ASSERT.asciidoc) | Proposal | |
4545
| [Matrix](Matrix/dpcpp-joint-matrix.asciidoc) | Partially supported(AMX AOT) | Not supported: dynamic-extent, wg and wi scopes, layouts other than packed|
46+
| [SYCL_INTEL_free_function_queries](FreeFunctionQueries/SYCL_INTEL_free_function_queries.asciidoc) | Supported (experimental) | |
4647

4748
Legend:
4849

sycl/include/CL/sycl/group.hpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,12 +428,28 @@ template <int Dims> group<Dims> store_group(const group<Dims> *g) {
428428
}
429429
} // namespace detail
430430

431-
template <int Dims> group<Dims> this_group() {
431+
template <int Dims>
432+
__SYCL_DEPRECATED("use sycl::ext::oneapi::experimental::this_group() instead")
433+
group<Dims> this_group() {
432434
#ifdef __SYCL_DEVICE_ONLY__
433435
return detail::Builder::getElement(detail::declptr<group<Dims>>());
434436
#else
435437
return detail::store_group<Dims>(nullptr);
436438
#endif
437439
}
440+
441+
namespace ext {
442+
namespace oneapi {
443+
namespace experimental {
444+
template <int Dims> group<Dims> this_group() {
445+
#ifdef __SYCL_DEVICE_ONLY__
446+
return sycl::detail::Builder::getElement(detail::declptr<group<Dims>>());
447+
#else
448+
return sycl::detail::store_group<Dims>(nullptr);
449+
#endif
450+
}
451+
} // namespace experimental
452+
} // namespace oneapi
453+
} // namespace ext
438454
} // namespace sycl
439455
} // __SYCL_INLINE_NAMESPACE(cl)

sycl/include/CL/sycl/id.hpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,28 @@ template <int Dims> id<Dims> store_id(const id<Dims> *i) {
289289
}
290290
} // namespace detail
291291

292-
template <int Dims> id<Dims> this_id() {
292+
template <int Dims>
293+
__SYCL_DEPRECATED("use sycl::ext::oneapi::experimental::this_id() instead")
294+
id<Dims> this_id() {
293295
#ifdef __SYCL_DEVICE_ONLY__
294296
return detail::Builder::getElement(detail::declptr<id<Dims>>());
295297
#else
296298
return detail::store_id<Dims>(nullptr);
297299
#endif
298300
}
299301

302+
namespace ext {
303+
namespace oneapi {
304+
namespace experimental {
305+
template <int Dims> id<Dims> this_id() {
306+
#ifdef __SYCL_DEVICE_ONLY__
307+
return sycl::detail::Builder::getElement(detail::declptr<id<Dims>>());
308+
#else
309+
return sycl::detail::store_id<Dims>(nullptr);
310+
#endif
311+
}
312+
} // namespace experimental
313+
} // namespace oneapi
314+
} // namespace ext
300315
} // namespace sycl
301316
} // __SYCL_INLINE_NAMESPACE(cl)

sycl/include/CL/sycl/item.hpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,28 @@ template <int Dims> item<Dims> store_item(const item<Dims> *i) {
132132
}
133133
} // namespace detail
134134

135-
template <int Dims> item<Dims> this_item() {
135+
template <int Dims>
136+
__SYCL_DEPRECATED("use sycl::ext::oneapi::experimental::this_item() instead")
137+
item<Dims> this_item() {
136138
#ifdef __SYCL_DEVICE_ONLY__
137139
return detail::Builder::getElement(detail::declptr<item<Dims>>());
138140
#else
139141
return detail::store_item<Dims>(nullptr);
140142
#endif
141143
}
142144

145+
namespace ext {
146+
namespace oneapi {
147+
namespace experimental {
148+
template <int Dims> item<Dims> this_item() {
149+
#ifdef __SYCL_DEVICE_ONLY__
150+
return sycl::detail::Builder::getElement(detail::declptr<item<Dims>>());
151+
#else
152+
return sycl::detail::store_item<Dims>(nullptr);
153+
#endif
154+
}
155+
} // namespace experimental
156+
} // namespace oneapi
157+
} // namespace ext
143158
} // namespace sycl
144159
} // __SYCL_INLINE_NAMESPACE(cl)

sycl/include/CL/sycl/nd_item.hpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,28 @@ template <int Dims> nd_item<Dims> store_nd_item(const nd_item<Dims> *nd_i) {
202202
}
203203
} // namespace detail
204204

205-
template <int Dims> nd_item<Dims> this_nd_item() {
205+
template <int Dims>
206+
__SYCL_DEPRECATED("use sycl::ext::oneapi::experimental::this_nd_item() instead")
207+
nd_item<Dims> this_nd_item() {
206208
#ifdef __SYCL_DEVICE_ONLY__
207209
return detail::Builder::getElement(detail::declptr<nd_item<Dims>>());
208210
#else
209211
return detail::store_nd_item<Dims>(nullptr);
210212
#endif
211213
}
212214

215+
namespace ext {
216+
namespace oneapi {
217+
namespace experimental {
218+
template <int Dims> nd_item<Dims> this_nd_item() {
219+
#ifdef __SYCL_DEVICE_ONLY__
220+
return sycl::detail::Builder::getElement(detail::declptr<nd_item<Dims>>());
221+
#else
222+
return sycl::detail::store_nd_item<Dims>(nullptr);
223+
#endif
224+
}
225+
} // namespace experimental
226+
} // namespace oneapi
227+
} // namespace ext
213228
} // namespace sycl
214229
} // __SYCL_INLINE_NAMESPACE(cl)

sycl/include/CL/sycl/sub_group.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,20 @@ namespace sycl {
1616
using ext::oneapi::sub_group;
1717
// TODO move the entire sub_group class implementation to this file once
1818
// breaking changes are allowed.
19+
20+
namespace ext {
21+
namespace oneapi {
22+
namespace experimental {
23+
inline sub_group this_sub_group() {
24+
#ifdef __SYCL_DEVICE_ONLY__
25+
return sub_group();
26+
#else
27+
throw runtime_error("Sub-groups are not supported on host device.",
28+
PI_INVALID_DEVICE);
29+
#endif
30+
}
31+
} // namespace experimental
32+
} // namespace oneapi
33+
} // namespace ext
1934
} // namespace sycl
2035
} // __SYCL_INLINE_NAMESPACE(cl)

sycl/include/sycl/ext/oneapi/sub_group.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ void store(multi_ptr<T, Space> dst, const vec<T, N> &x) {
100100
namespace ext {
101101
namespace oneapi {
102102

103+
struct sub_group;
104+
namespace experimental {
105+
inline sub_group this_sub_group();
106+
}
107+
103108
struct sub_group {
104109

105110
using id_type = id<1>;
@@ -733,9 +738,12 @@ struct sub_group {
733738
protected:
734739
template <int dimensions> friend class cl::sycl::nd_item;
735740
friend sub_group this_sub_group();
741+
friend sub_group experimental::this_sub_group();
736742
sub_group() = default;
737743
};
738744

745+
__SYCL_DEPRECATED(
746+
"use sycl::ext::oneapi::experimental::this_sub_group() instead")
739747
inline sub_group this_sub_group() {
740748
#ifdef __SYCL_DEVICE_ONLY__
741749
return sub_group();

sycl/test/basic_tests/free_function_queries/free_function_queries_interface.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,30 @@
1313
#include <type_traits>
1414

1515
template <int Dims> struct this_id_caller {
16-
auto operator()() const -> decltype(sycl::this_id<Dims>()) {
17-
return sycl::this_id<Dims>();
16+
auto operator()() const
17+
-> decltype(sycl::ext::oneapi::experimental::this_id<Dims>()) {
18+
return sycl::ext::oneapi::experimental::this_id<Dims>();
1819
}
1920
};
2021

2122
template <int Dims> struct this_item_caller {
22-
auto operator()() const -> decltype(sycl::this_item<Dims>()) {
23-
return sycl::this_item<Dims>();
23+
auto operator()() const
24+
-> decltype(sycl::ext::oneapi::experimental::this_item<Dims>()) {
25+
return sycl::ext::oneapi::experimental::this_item<Dims>();
2426
}
2527
};
2628

2729
template <int Dims> struct this_nd_item_caller {
28-
auto operator()() const -> decltype(sycl::this_nd_item<Dims>()) {
29-
return sycl::this_nd_item<Dims>();
30+
auto operator()() const
31+
-> decltype(sycl::ext::oneapi::experimental::this_nd_item<Dims>()) {
32+
return sycl::ext::oneapi::experimental::this_nd_item<Dims>();
3033
}
3134
};
3235

3336
template <int Dims> struct this_group_caller {
34-
auto operator()() const -> decltype(sycl::this_group<Dims>()) {
35-
return sycl::this_group<Dims>();
37+
auto operator()() const
38+
-> decltype(sycl::ext::oneapi::experimental::this_group<Dims>()) {
39+
return sycl::ext::oneapi::experimental::this_group<Dims>();
3640
}
3741
};
3842

@@ -66,7 +70,8 @@ int main() {
6670
test<sycl::group>(this_group_caller<2>{});
6771
test<sycl::group>(this_group_caller<3>{});
6872

69-
static_assert(std::is_same<decltype(sycl::ext::oneapi::this_sub_group()),
70-
sycl::ext::oneapi::sub_group>::value,
71-
"Wrong return type of free function query for Sub Group");
73+
static_assert(
74+
std::is_same<decltype(sycl::ext::oneapi::experimental::this_sub_group()),
75+
sycl::ext::oneapi::sub_group>::value,
76+
"Wrong return type of free function query for Sub Group");
7277
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %clangxx %fsycl-host-only -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note %s -o %t.out
2+
3+
#include <CL/sycl.hpp>
4+
5+
int main() {
6+
// expected-warning@+1 {{'this_group<1>' is deprecated: use sycl::ext::oneapi::experimental::this_group() instead}}
7+
(void)sycl::this_group<1>();
8+
// expected-warning@+1 {{'this_item<1>' is deprecated: use sycl::ext::oneapi::experimental::this_item() instead}}
9+
(void)sycl::this_item<1>();
10+
// expected-warning@+1 {{'this_nd_item<1>' is deprecated: use sycl::ext::oneapi::experimental::this_nd_item() instead}}
11+
(void)sycl::this_nd_item<1>();
12+
// expected-warning@+1 {{'this_id<1>' is deprecated: use sycl::ext::oneapi::experimental::this_id() instead}}
13+
(void)sycl::this_id<1>();
14+
// expected-warning@+1 {{'this_sub_group' is deprecated: use sycl::ext::oneapi::experimental::this_sub_group() instead}}
15+
(void)sycl::ext::oneapi::this_sub_group();
16+
17+
return 0;
18+
}

0 commit comments

Comments
 (0)