Skip to content

Commit 547ac1e

Browse files
[NFCI][SYCL] Auto-deduce sycl::is_property via std::is_base_of (#7165)
1 parent f1bfbc3 commit 547ac1e

File tree

8 files changed

+9
-50
lines changed

8 files changed

+9
-50
lines changed

sycl/include/sycl/properties/accessor_properties.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ template <typename DataT, int Dimensions, access::mode AccessMode>
125125
class host_accessor;
126126

127127
// Accessor property trait specializations
128-
template <> struct is_property<property::noinit> : std::true_type {};
129-
template <> struct is_property<property::no_init> : std::true_type {};
130128
template <>
131129
struct is_property<ext::oneapi::property::no_offset> : std::true_type {};
132130
template <>

sycl/include/sycl/properties/buffer_properties.hpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,6 @@ template <typename T, int Dimensions, typename AllocatorT, typename Enable>
8383
class buffer;
8484

8585
// Buffer property trait specializations
86-
template <>
87-
struct is_property<property::buffer::use_host_ptr> : std::true_type {};
88-
template <> struct is_property<property::buffer::use_mutex> : std::true_type {};
89-
template <>
90-
struct is_property<property::buffer::detail::buffer_location> : std::true_type {
91-
};
92-
template <>
93-
struct is_property<property::buffer::context_bound> : std::true_type {};
94-
template <>
95-
struct is_property<property::buffer::mem_channel> : std::true_type {};
96-
template <>
97-
struct is_property<ext::oneapi::property::buffer::use_pinned_host_memory>
98-
: std::true_type {};
99-
10086
template <typename T, int Dimensions, typename AllocatorT>
10187
struct is_property_of<property::buffer::use_host_ptr,
10288
buffer<T, Dimensions, AllocatorT, void>>

sycl/include/sycl/properties/context_properties.hpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,10 @@ class use_primary_context
4444
class context;
4545

4646
// Context property trait specializations
47-
template <>
48-
struct is_property<property::context::cuda::use_primary_context>
49-
: std::true_type {};
50-
5147
template <>
5248
struct is_property_of<property::context::cuda::use_primary_context, context>
5349
: std::true_type {};
5450

55-
template <>
56-
struct is_property<ext::oneapi::cuda::property::context::use_primary_context>
57-
: std::true_type {};
58-
5951
template <>
6052
struct is_property_of<ext::oneapi::cuda::property::context::use_primary_context,
6153
context> : std::true_type {};

sycl/include/sycl/properties/image_properties.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ class context_bound
4646
template <int Dimensions, typename AllocatorT> class image;
4747

4848
// Image property trait specializations
49-
template <>
50-
struct is_property<property::image::use_host_ptr> : std::true_type {};
51-
template <> struct is_property<property::image::use_mutex> : std::true_type {};
52-
template <>
53-
struct is_property<property::image::context_bound> : std::true_type {};
54-
5549
template <int Dimensions, typename AllocatorT>
5650
struct is_property_of<property::image::use_host_ptr,
5751
image<Dimensions, AllocatorT>> : std::true_type {};

sycl/include/sycl/properties/property_traits.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@
88

99
#pragma once
1010

11+
#include <sycl/detail/property_helper.hpp>
12+
1113
namespace sycl {
1214
__SYCL_INLINE_VER_NAMESPACE(_V1) {
1315

1416
// Property traits
15-
template <typename propertyT> struct is_property : public std::false_type {};
17+
template <typename propertyT>
18+
struct is_property
19+
: public std::bool_constant<
20+
std::is_base_of_v<detail::DataLessPropertyBase, propertyT> ||
21+
std::is_base_of_v<detail::PropertyWithDataBase, propertyT>> {};
1622

1723
template <typename propertyT, typename syclObjectT>
1824
struct is_property_of : public std::false_type {};

sycl/include/sycl/properties/queue_properties.hpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,6 @@ class use_default_stream
5858
class queue;
5959

6060
// Queue property trait specializations
61-
template <> struct is_property<property::queue::in_order> : std::true_type {};
62-
template <>
63-
struct is_property<property::queue::enable_profiling> : std::true_type {};
64-
template <>
65-
struct is_property<ext::oneapi::property::queue::discard_events>
66-
: std::true_type {};
67-
template <>
68-
struct is_property<property::queue::cuda::use_default_stream> : std::true_type {
69-
};
70-
template <>
71-
struct is_property<ext::oneapi::cuda::property::queue::use_default_stream>
72-
: std::true_type {};
73-
7461
template <>
7562
struct is_property_of<property::queue::in_order, queue> : std::true_type {};
7663
template <>

sycl/include/sycl/properties/reduction_properties.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,5 @@ class initialize_to_identity
2222
} // namespace property
2323

2424
// Reduction property trait specializations
25-
template <>
26-
struct is_property<property::reduction::initialize_to_identity>
27-
: std::true_type {};
28-
2925
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
3026
} // namespace sycl

sycl/test/basic_tests/stdcpp_compat.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clangxx -std=c++14 -fsycl -Wall -pedantic -Wno-c99-extensions -Wno-deprecated -fsyntax-only -Xclang -verify=expected,cxx14 %s -c -o %t.out
2-
// RUN: %clangxx -std=c++14 -fsycl -Wall -pedantic -Wno-c99-extensions -Wno-deprecated -fsyntax-only -Xclang -verify=cxx14,warning_extension,expected %s -c -o %t.out
1+
// RUN: %clangxx -std=c++14 -fsycl -Wall -pedantic -Wno-c99-extensions -Wno-deprecated -fsyntax-only -Xclang -verify-ignore-unexpected=error,note,warning -Xclang -verify=expected,cxx14 %s -c -o %t.out
2+
// RUN: %clangxx -std=c++14 -fsycl -Wall -pedantic -Wno-c99-extensions -Wno-deprecated -fsyntax-only -Xclang -verify-ignore-unexpected=error,note,warning -Xclang -verify=cxx14,warning_extension,expected %s -c -o %t.out
33
// RUN: %clangxx -std=c++17 -fsycl -Wall -pedantic -Wno-c99-extensions -Wno-deprecated -fsyntax-only -Xclang -verify %s -c -o %t.out
44
// RUN: %clangxx -std=c++20 -fsycl -Wall -pedantic -Wno-c99-extensions -Wno-deprecated -fsyntax-only -Xclang -verify %s -c -o %t.out
55
// RUN: %clangxx -fsycl -Wall -pedantic -Wno-c99-extensions -Wno-deprecated -fsyntax-only -Xclang -verify %s -c -o %t.out

0 commit comments

Comments
 (0)