Skip to content

Commit ed8efd7

Browse files
author
Alexander Batashev
committed
Address more comments
1 parent 2c04881 commit ed8efd7

File tree

5 files changed

+82
-19
lines changed

5 files changed

+82
-19
lines changed

sycl/include/CL/sycl/ONEAPI/accessor_property_list.hpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,8 @@ class accessor_property_list : protected sycl::detail::PropertyListBase {
6161
template <typename PropT> struct ContainsProperty<PropT> : std::false_type {};
6262
template <typename PropT, typename Head, typename... Tail>
6363
struct ContainsProperty<PropT, Head, Tail...>
64-
: std::conditional<
65-
AreSameTemplate<PropT, Head>::value ||
66-
!sycl::detail::IsCompileTimePropertyInstance<PropT>::value,
67-
std::true_type, ContainsProperty<PropT, Tail...>>::type {};
64+
: std::conditional<AreSameTemplate<PropT, Head>::value, std::true_type,
65+
ContainsProperty<PropT, Tail...>>::type {};
6866

6967
// PropertyContainer is a helper structure, that holds list of properties.
7068
// It is used to avoid multiple parameter packs in templates.
@@ -90,10 +88,8 @@ class accessor_property_list : protected sycl::detail::PropertyListBase {
9088
struct ContainsPropertyInstance
9189
: std::conditional_t<
9290
!std::is_same_v<typename ContainerT::Head, void> &&
93-
(AreSameTemplate<PropT<Args...>,
94-
typename ContainerT::Head>::value ||
95-
!sycl::detail::IsCompileTimePropertyInstance<
96-
typename ContainerT::Head>::value),
91+
AreSameTemplate<PropT<Args...>,
92+
typename ContainerT::Head>::value,
9793
std::true_type,
9894
ContainsPropertyInstance<typename ContainerT::Rest, PropT,
9995
Args...>> {};
@@ -103,11 +99,14 @@ class accessor_property_list : protected sycl::detail::PropertyListBase {
10399
#endif
104100

105101
// This template checks if two lists of properties contain the same set of
106-
// compile-time-constant properties in any order.
107-
template <typename ContainerT, typename... OtherProps>
102+
// compile-time-constant properties in any order. Run time properties are
103+
// skipped.
108104
struct ContainsSameProperties
109105
: std::conditional<
110-
ContainsProperty<typename ContainerT::Head, OtherProps...>::value,
106+
!detail::IsCompileTimePropertyInstance<
107+
typename ContainerT::Head>::value ||
108+
ContainsProperty<typename ContainerT::Head,
109+
OtherProps...>::value,
111110
ContainsSameProperties<typename ContainerT::Rest, OtherProps...>,
112111
std::false_type>::type {};
113112
template <typename... OtherProps>

sycl/include/CL/sycl/properties/accessor_properties.hpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,13 @@ namespace INTEL {
3939
namespace property {
4040
struct buffer_location {
4141
template <int A> struct instance {
42-
constexpr bool operator==(const buffer_location::instance<A> &) const {
43-
return true;
44-
}
45-
constexpr bool operator!=(const buffer_location::instance<A> &) const {
46-
return false;
47-
}
4842
template <int B>
4943
constexpr bool operator==(const buffer_location::instance<B> &) const {
50-
return false;
44+
return A == B;
5145
}
5246
template <int B>
5347
constexpr bool operator!=(const buffer_location::instance<B> &) const {
54-
return true;
48+
return A != B;
5549
}
5650
};
5751
};

sycl/test/basic_tests/accessor/accessor_property_list_rt.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ int main() {
1111
{
1212
// Single RT property
1313
accessor_property_list PL{sycl::noinit};
14+
static_assert(!PL.has_property<property::no_offset>(), "Property is found");
1415
assert(PL.has_property<sycl::property::noinit>() && "Property not found");
1516
}
1617

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %clangxx -fsycl %s -o %t.out
2+
// RUNx: %ACC_RUN_PLACEHOLDER %t.out
3+
4+
#include <CL/sycl.hpp>
5+
6+
int main() {
7+
sycl::queue Queue;
8+
sycl::buffer<int, 1> Buf{sycl::range{1}};
9+
10+
Queue.submit([&](sycl::handler &CGH) {
11+
sycl::ONEAPI::accessor_property_list PL{sycl::INTEL::buffer_location<1>};
12+
sycl::accessor Acc(Buf, CGH, sycl::write_only, PL);
13+
CGH.single_task<class Test>([=]() { Acc[0] = 42; });
14+
});
15+
16+
Queue.wait();
17+
18+
auto Acc = Buf.template get_access<sycl::access::mode::read_write>();
19+
assert(Acc[0] == 42 && "Value mismatch");
20+
21+
return 0;
22+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// RUN: %clangxx -fsycl -c -fsycl-device-only -S -emit-llvm %s -o - | FileCheck %s
2+
3+
// CHECK: define {{.*}}spir_kernel void @"_ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE15kernel_function"{{.*}} !kernel_arg_buffer_location ![[MDBL:[0-9]+]]
4+
// CHECK: ![[MDBL]] = !{i32 3, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 2, i32 -1, i32 -1, i32 -1, i32 2, i32 -1, i32 -1, i32 -1, i32 -1}
5+
6+
#include <CL/sycl.hpp>
7+
8+
struct Base {
9+
int A, B;
10+
cl::sycl::accessor<
11+
char, 1, cl::sycl::access::mode::read,
12+
cl::sycl::access::target::global_buffer,
13+
cl::sycl::access::placeholder::false_t,
14+
cl::sycl::ONEAPI::accessor_property_list<
15+
cl::sycl::INTEL::property::buffer_location::instance<2>>>
16+
AccField;
17+
};
18+
19+
struct Captured
20+
: Base,
21+
cl::sycl::accessor<
22+
char, 1, cl::sycl::access::mode::read,
23+
cl::sycl::access::target::global_buffer,
24+
cl::sycl::access::placeholder::false_t,
25+
cl::sycl::ONEAPI::accessor_property_list<
26+
cl::sycl::INTEL::property::buffer_location::instance<2>>> {
27+
int C;
28+
};
29+
30+
int main() {
31+
Captured Obj;
32+
cl::sycl::accessor<
33+
int, 1, cl::sycl::access::mode::read_write,
34+
cl::sycl::access::target::global_buffer,
35+
cl::sycl::access::placeholder::false_t,
36+
cl::sycl::ONEAPI::accessor_property_list<
37+
cl::sycl::INTEL::property::buffer_location::instance<3>>>
38+
accessorA;
39+
sycl::queue Queue;
40+
Queue.submit([&](sycl::handler &CGH) {
41+
CGH.single_task<class kernel_function>([=]() {
42+
(int)accessorA[0];
43+
(int)Obj[0];
44+
});
45+
});
46+
return 0;
47+
}

0 commit comments

Comments
 (0)