Skip to content

Commit 2864eac

Browse files
[SYCL] Refactor include/sycl/properties/queue_properties.hpp (#8048)
Make sure the required amount of boilerplate code is minimal. Fixes an issue with missing explicit instantiations - see new symbols in the ABI test(s).
1 parent ab0c46b commit 2864eac

File tree

5 files changed

+89
-75
lines changed

5 files changed

+89
-75
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// --*- c++ -*---
2+
#ifndef __SYCL_DATA_LESS_PROP
3+
#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL)
4+
#endif
5+
#ifndef __SYCL_MANUALLY_DEFINED_PROP
6+
#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME)
7+
#endif
8+
9+
__SYCL_DATA_LESS_PROP(property::queue, in_order, InOrder)
10+
__SYCL_DATA_LESS_PROP(property::queue, enable_profiling, QueueEnableProfiling)
11+
12+
__SYCL_DATA_LESS_PROP(ext::oneapi::property::queue, discard_events,
13+
DiscardEvents)
14+
__SYCL_DATA_LESS_PROP(ext::oneapi::property::queue, priority_normal,
15+
QueuePriorityNormal)
16+
__SYCL_DATA_LESS_PROP(ext::oneapi::property::queue, priority_low,
17+
QueuePriorityLow)
18+
__SYCL_DATA_LESS_PROP(ext::oneapi::property::queue, priority_high,
19+
QueuePriorityHigh)
20+
21+
__SYCL_DATA_LESS_PROP(ext::oneapi::cuda::property::queue, use_default_stream,
22+
UseDefaultStream)
23+
24+
// Deprecated alias for ext::oneapi::cuda::property::queue.
25+
__SYCL_MANUALLY_DEFINED_PROP(property::queue::cuda, use_default_stream)
26+
27+
// Contains data field, defined explicitly.
28+
__SYCL_MANUALLY_DEFINED_PROP(ext::intel::property::queue, compute_index)
29+
30+
#undef __SYCL_DATA_LESS_PROP
31+
#undef __SYCL_MANUALLY_DEFINED_PROP

sycl/include/sycl/properties/queue_properties.hpp

Lines changed: 16 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,13 @@
1313

1414
namespace sycl {
1515
__SYCL_INLINE_VER_NAMESPACE(_V1) {
16-
namespace property::queue {
17-
class in_order : public detail::DataLessProperty<detail::InOrder> {};
18-
class enable_profiling
19-
: public detail::DataLessProperty<detail::QueueEnableProfiling> {};
20-
} // namespace property::queue
21-
22-
namespace ext::oneapi {
23-
24-
namespace property::queue {
25-
class discard_events
26-
: public ::sycl::detail::DataLessProperty<::sycl::detail::DiscardEvents> {};
27-
28-
class priority_normal
29-
: public sycl::detail::DataLessProperty<sycl::detail::QueuePriorityNormal> {
30-
};
31-
class priority_low
32-
: public sycl::detail::DataLessProperty<sycl::detail::QueuePriorityLow> {};
33-
class priority_high
34-
: public sycl::detail::DataLessProperty<sycl::detail::QueuePriorityHigh> {};
35-
36-
} // namespace property::queue
16+
#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \
17+
namespace NS_QUALIFIER { \
18+
class PROP_NAME \
19+
: public sycl::detail::DataLessProperty<sycl::detail::ENUM_VAL> {}; \
20+
}
3721

38-
namespace cuda::property::queue {
39-
class use_default_stream : public ::sycl::detail::DataLessProperty<
40-
::sycl::detail::UseDefaultStream> {};
41-
} // namespace cuda::property::queue
42-
} // namespace ext::oneapi
22+
#include <sycl/properties/queue_properties.def>
4323

4424
namespace property ::queue {
4525
namespace __SYCL2020_DEPRECATED(
@@ -51,10 +31,7 @@ class use_default_stream
5131
// clang-format on
5232
} // namespace property::queue
5333

54-
namespace ext {
55-
namespace intel {
56-
namespace property {
57-
namespace queue {
34+
namespace ext::intel::property::queue {
5835
class compute_index : public sycl::detail::PropertyWithData<
5936
sycl::detail::PropWithDataKind::QueueComputeIndex> {
6037
public:
@@ -64,41 +41,18 @@ class compute_index : public sycl::detail::PropertyWithData<
6441
private:
6542
int idx;
6643
};
67-
} // namespace queue
68-
} // namespace property
69-
} // namespace intel
70-
} // namespace ext
44+
} // namespace ext::intel::property::queue
7145

72-
// Forward declaration
46+
// Queue property trait specializations.
7347
class queue;
7448

75-
// Queue property trait specializations
76-
template <>
77-
struct is_property_of<property::queue::in_order, queue> : std::true_type {};
78-
template <>
79-
struct is_property_of<property::queue::enable_profiling, queue>
80-
: std::true_type {};
81-
template <>
82-
struct is_property_of<ext::oneapi::property::queue::discard_events, queue>
83-
: std::true_type {};
84-
template <>
85-
struct is_property_of<ext::oneapi::property::queue::priority_normal, queue>
86-
: std::true_type {};
87-
template <>
88-
struct is_property_of<ext::oneapi::property::queue::priority_low, queue>
89-
: std::true_type {};
90-
template <>
91-
struct is_property_of<ext::oneapi::property::queue::priority_high, queue>
92-
: std::true_type {};
93-
template <>
94-
struct is_property_of<property::queue::cuda::use_default_stream, queue>
95-
: std::true_type {};
96-
template <>
97-
struct is_property_of<ext::oneapi::cuda::property::queue::use_default_stream,
98-
queue> : std::true_type {};
99-
template <>
100-
struct is_property_of<ext::intel::property::queue::compute_index, queue>
101-
: std::true_type {};
49+
#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \
50+
template <> \
51+
struct is_property_of<NS_QUALIFIER::PROP_NAME, queue> : std::true_type {};
52+
#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \
53+
__SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME)
54+
55+
#include <sycl/properties/queue_properties.def>
10256

10357
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
10458
} // namespace sycl

sycl/source/queue.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,16 @@ template <typename PropertyT> PropertyT queue::get_property() const {
188188
return impl->get_property<PropertyT>();
189189
}
190190

191-
template __SYCL_EXPORT bool
192-
queue::has_property<property::queue::enable_profiling>() const noexcept;
193-
template __SYCL_EXPORT property::queue::enable_profiling
194-
queue::get_property<property::queue::enable_profiling>() const;
195-
196-
template __SYCL_EXPORT bool
197-
queue::has_property<property::queue::in_order>() const;
198-
template __SYCL_EXPORT property::queue::in_order
199-
queue::get_property<property::queue::in_order>() const;
191+
#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \
192+
template __SYCL_EXPORT bool queue::has_property<NS_QUALIFIER::PROP_NAME>() \
193+
const noexcept; \
194+
template __SYCL_EXPORT NS_QUALIFIER::PROP_NAME \
195+
queue::get_property<NS_QUALIFIER::PROP_NAME>() const;
196+
197+
#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \
198+
__SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME)
199+
200+
#include <sycl/properties/queue_properties.def>
200201

201202
bool queue::is_in_order() const {
202203
return impl->has_property<property::queue::in_order>();

sycl/test/abi/sycl_symbols_linux.dump

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# DO NOT EDIT IT MANUALLY. Refer to sycl/doc/developer/ABIPolicyGuide.md for more info.
44
################################################################################
55

6-
# RUN: env LLVM_BIN_PATH=%llvm_build_bin_dir %python %sycl_tools_src_dir/abi_check.py --mode check_symbols --reference %s %sycl_libs_dir/libsycl.so
6+
# RUN: env LLVM_BIN_PATH=%llvm_build_bin_dir python %sycl_tools_src_dir/abi_check.py --mode check_symbols --reference %s %sycl_libs_dir/libsycl.so
77
# REQUIRES: linux
88
# UNSUPPORTED: libcxx
99

@@ -4055,9 +4055,23 @@ _ZNK4sycl3_V15queue10get_deviceEv
40554055
_ZNK4sycl3_V15queue11get_backendEv
40564056
_ZNK4sycl3_V15queue11get_contextEv
40574057
_ZNK4sycl3_V15queue11is_in_orderEv
4058+
_ZNK4sycl3_V15queue12get_propertyINS0_3ext5intel8property5queue13compute_indexEEET_v
4059+
_ZNK4sycl3_V15queue12get_propertyINS0_3ext6oneapi4cuda8property5queue18use_default_streamEEET_v
4060+
_ZNK4sycl3_V15queue12get_propertyINS0_3ext6oneapi8property5queue12priority_lowEEET_v
4061+
_ZNK4sycl3_V15queue12get_propertyINS0_3ext6oneapi8property5queue13priority_highEEET_v
4062+
_ZNK4sycl3_V15queue12get_propertyINS0_3ext6oneapi8property5queue14discard_eventsEEET_v
4063+
_ZNK4sycl3_V15queue12get_propertyINS0_3ext6oneapi8property5queue15priority_normalEEET_v
40584064
_ZNK4sycl3_V15queue12get_propertyINS0_8property5queue16enable_profilingEEET_v
4065+
_ZNK4sycl3_V15queue12get_propertyINS0_8property5queue4cuda18use_default_streamEEET_v
40594066
_ZNK4sycl3_V15queue12get_propertyINS0_8property5queue8in_orderEEET_v
4067+
_ZNK4sycl3_V15queue12has_propertyINS0_3ext5intel8property5queue13compute_indexEEEbv
4068+
_ZNK4sycl3_V15queue12has_propertyINS0_3ext6oneapi4cuda8property5queue18use_default_streamEEEbv
4069+
_ZNK4sycl3_V15queue12has_propertyINS0_3ext6oneapi8property5queue12priority_lowEEEbv
4070+
_ZNK4sycl3_V15queue12has_propertyINS0_3ext6oneapi8property5queue13priority_highEEEbv
4071+
_ZNK4sycl3_V15queue12has_propertyINS0_3ext6oneapi8property5queue14discard_eventsEEEbv
4072+
_ZNK4sycl3_V15queue12has_propertyINS0_3ext6oneapi8property5queue15priority_normalEEEbv
40604073
_ZNK4sycl3_V15queue12has_propertyINS0_8property5queue16enable_profilingEEEbv
4074+
_ZNK4sycl3_V15queue12has_propertyINS0_8property5queue4cuda18use_default_streamEEEbv
40614075
_ZNK4sycl3_V15queue12has_propertyINS0_8property5queue8in_orderEEEbv
40624076
_ZNK4sycl3_V15queue16ext_oneapi_emptyEv
40634077
_ZNK4sycl3_V15queue28ext_codeplay_supports_fusionEv
@@ -4318,12 +4332,12 @@ _ZNK4sycl3_V16device8get_infoINS0_4info6device35ext_intel_gpu_eu_count_per_subsl
43184332
_ZNK4sycl3_V16device8get_infoINS0_4info6device38sub_group_independent_forward_progressEEENS0_6detail19is_device_info_descIT_E11return_typeEv
43194333
_ZNK4sycl3_V16device8get_infoINS0_4info6device4nameEEENS0_6detail19is_device_info_descIT_E11return_typeEv
43204334
_ZNK4sycl3_V16device8get_infoINS0_4info6device6vendorEEENS0_6detail19is_device_info_descIT_E11return_typeEv
4335+
_ZNK4sycl3_V16device8get_infoINS0_4info6device7aspectsEEENS0_6detail19is_device_info_descIT_E11return_typeEv
43214336
_ZNK4sycl3_V16device8get_infoINS0_4info6device7profileEEENS0_6detail19is_device_info_descIT_E11return_typeEv
43224337
_ZNK4sycl3_V16device8get_infoINS0_4info6device7versionEEENS0_6detail19is_device_info_descIT_E11return_typeEv
43234338
_ZNK4sycl3_V16device8get_infoINS0_4info6device8atomic64EEENS0_6detail19is_device_info_descIT_E11return_typeEv
43244339
_ZNK4sycl3_V16device8get_infoINS0_4info6device8platformEEENS0_6detail19is_device_info_descIT_E11return_typeEv
43254340
_ZNK4sycl3_V16device8get_infoINS0_4info6device9vendor_idEEENS0_6detail19is_device_info_descIT_E11return_typeEv
4326-
_ZNK4sycl3_V16device8get_infoINS0_4info6device7aspectsEEENS0_6detail19is_device_info_descIT_E11return_typeEv
43274341
_ZNK4sycl3_V16device9getNativeEv
43284342
_ZNK4sycl3_V16kernel11get_backendEv
43294343
_ZNK4sycl3_V16kernel11get_contextEv

0 commit comments

Comments
 (0)