Skip to content

Commit 642a419

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents 5ac8727 + 0351926 commit 642a419

File tree

11 files changed

+297
-13
lines changed

11 files changed

+297
-13
lines changed

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,9 +780,11 @@ def SyclIvdepAttribute : DiagGroup<"ivdep-compat">;
780780
def IndependentClassAttribute : DiagGroup<"IndependentClass-attribute">;
781781
def UnknownAttributes : DiagGroup<"unknown-attributes">;
782782
def IgnoredAttributes : DiagGroup<"ignored-attributes", [SyclIvdepAttribute]>;
783+
def IncorrectSubGroupSize: DiagGroup<"incorrect-sub-group-size">;
783784
def AcceptedAttributes : DiagGroup<"accepted-attributes">;
784785
def Attributes : DiagGroup<"attributes", [UnknownAttributes,
785786
IgnoredAttributes,
787+
IncorrectSubGroupSize,
786788
AcceptedAttributes]>;
787789
def UnknownSanitizers : DiagGroup<"unknown-sanitizers">;
788790
def UnnamedTypeTemplateArgs : DiagGroup<"unnamed-type-template-args",

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3543,7 +3543,7 @@ def warn_attribute_on_direct_kernel_callee_only : Warning<"%0 attribute allowed"
35433543
def warn_reqd_sub_group_attribute_n
35443544
: Warning<"attribute argument %0 is invalid and will be ignored; %1 "
35453545
"requires sub_group size %2">,
3546-
InGroup<IgnoredAttributes>;
3546+
InGroup<IncorrectSubGroupSize>;
35473547
def warn_nothrow_attribute_ignored : Warning<"'nothrow' attribute conflicts with"
35483548
" exception specification; attribute ignored">,
35493549
InGroup<IgnoredAttributes>;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %clang_cc1 -fsycl-is-device -triple nvptx -internal-isystem %S/Inputs -std=c++2b -verify -Wno-incorrect-sub-group-size %s
2+
// RUN: %clang_cc1 -fsycl-is-device -triple nvptx -internal-isystem %S/Inputs -std=c++2b -verify -Wno-attributes %s
3+
// RUN: %clang_cc1 -fsycl-is-device -triple amdgcn-amd-amdhsa -target-cpu gfx90a -internal-isystem %S/Inputs -std=c++2b -verify -Wno-incorrect-sub-group-size %s
4+
// RUN: %clang_cc1 -fsycl-is-device -triple amdgcn-amd-amdhsa -target-cpu gfx90a -internal-isystem %S/Inputs -std=c++2b -verify -Wno-attributes %s
5+
// RUN: %clang_cc1 -fsycl-is-device -triple amdgcn-amd-amdhsa -target-cpu gfx1010 -internal-isystem %S/Inputs -std=c++2b -verify -Wno-incorrect-sub-group-size %s
6+
// RUN: %clang_cc1 -fsycl-is-device -triple amdgcn-amd-amdhsa -target-cpu gfx1010 -internal-isystem %S/Inputs -std=c++2b -verify -Wno-attributes %s
7+
//
8+
// Sub group size of 8 is incompatible with both CUDA and HIP, expect it to be
9+
// silenced. Check both the dedicated switch '-Wno-incorrect-sub-group-size' and
10+
// the catch all '-Wno-attributes'.
11+
#include "sycl.hpp"
12+
13+
14+
// expected-no-diagnostics
15+
int main() {
16+
17+
sycl::queue Q;
18+
19+
Q.submit([&](sycl::handler &h) {
20+
h.single_task<class invalid_kernel>([=] [[sycl::reqd_sub_group_size(8)]] {});
21+
});
22+
23+
return 0;
24+
}

sycl/doc/extensions/experimental/sycl_ext_oneapi_annotated_ptr.asciidoc

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,31 @@ information provided as compile-time constant properties through all uses of the
183183
pointer unless noted otherwise.
184184

185185
.Unsupported Usage Example
186+
[source,c++]
187+
----
188+
using sycl::ext::oneapi::experimental;
189+
struct MyType {
190+
MyType(const MyType& otherM) {
191+
...
192+
}
193+
};
194+
195+
struct MyKernel {
196+
annotated_ptr<MyType, properties<PropA>> a; //non-trivially-copyable type is not allowed
197+
annotated_ptr<void, properties<PropB>> b; //void is legal
198+
...
199+
void operator()() const {
200+
...
201+
*b = ...; //deference is not allowed
202+
}
203+
};
204+
----
205+
It is ill-formed to instantiate`annotated_ptr` and `annotated_ref` for a non-trivially-copyable
206+
type `T`. The only exception is that `annotated_ptr` is allowed to be instantiated with `void`.
207+
208+
In the above example, encapsulating `annotated_ptr` within `MyType` is illegal. Encapsulating
209+
`annotated_ptr` with `void` is legal, but it can not be deferenced.
210+
186211
[source,c++]
187212
----
188213
using sycl::ext::oneapi::experimental;
@@ -524,10 +549,10 @@ class annotated_ref {
524549
public:
525550
annotated_ref(const annotated_ref&) = delete;
526551
operator T() const;
527-
T operator=(const T &) const;
552+
T operator=(T) const;
528553
T operator=(const annotated_ref&) const;
529554
// OP is: +=, -=, *=, /=, %=, <<=, >>=, &=, |=, ^=
530-
T operatorOP(const T &) const;
555+
T operatorOP(T) const;
531556
T operator++() const;
532557
T operator++(int) const;
533558
T operator--() const;
@@ -556,7 +581,7 @@ annotations when the object is loaded from memory.
556581
a|
557582
[source,c++]
558583
----
559-
T operator=(const T &) const;
584+
T operator=(T) const;
560585
----
561586
|
562587
Writes an object of type `T` to the location referenced by this wrapper,
@@ -583,7 +608,7 @@ Does not rebind the reference!
583608
a|
584609
[source,c++]
585610
----
586-
T operatorOP(const T &) const;
611+
T operatorOP(T) const;
587612
----
588613
a|
589614
Where [code]#OP# is: [code]#pass:[+=]#, [code]#-=#,[code]#*=#, [code]#/=#, [code]#%=#, [code]#+<<=+#, [code]#>>=#, [code]#&=#, [code]#\|=#, [code]#^=#.

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace experimental {
3232

3333
namespace {
3434
#define PROPAGATE_OP(op) \
35-
T operator op##=(const T &rhs) const { \
35+
T operator op##=(T rhs) const { \
3636
T t = *this; \
3737
t op## = rhs; \
3838
*this = t; \
@@ -78,6 +78,10 @@ template <typename T, typename... Props>
7878
class annotated_ref<T, detail::properties_t<Props...>> {
7979
using property_list_t = detail::properties_t<Props...>;
8080

81+
static_assert(
82+
std::is_trivially_copyable_v<T>,
83+
"annotated_ref can only encapsulate a trivially-copyable type!");
84+
8185
private:
8286
T *m_Ptr;
8387
annotated_ref(T *Ptr) : m_Ptr(Ptr) {}
@@ -95,7 +99,7 @@ class annotated_ref<T, detail::properties_t<Props...>> {
9599
#endif
96100
}
97101

98-
T operator=(const T &Obj) const {
102+
T operator=(T Obj) const {
99103
#ifdef __SYCL_DEVICE_ONLY__
100104
*__builtin_intel_sycl_ptr_annotation(
101105
m_Ptr, detail::PropertyMetaInfo<Props>::name...,
@@ -178,6 +182,11 @@ class __SYCL_SPECIAL_CLASS
178182
__SYCL_TYPE(annotated_ptr) annotated_ptr<T, detail::properties_t<Props...>> {
179183
using property_list_t = detail::properties_t<Props...>;
180184

185+
static_assert(std::is_same_v<T, void> || std::is_trivially_copyable_v<T>,
186+
"annotated_ptr can only encapsulate either "
187+
"a trivially-copyable type "
188+
"or void!");
189+
181190
// buffer_location and alignment are allowed for annotated_ref
182191
// Cache controls are allowed for annotated_ptr
183192
using allowed_properties =
@@ -249,6 +258,7 @@ __SYCL_TYPE(annotated_ptr) annotated_ptr<T, detail::properties_t<Props...>> {
249258
template <typename... PropertyValueTs>
250259
explicit annotated_ptr(T *Ptr, const PropertyValueTs &...props) noexcept
251260
: m_Ptr(Ptr) {
261+
252262
static constexpr bool has_same_properties = std::is_same<
253263
property_list_t,
254264
detail::merged_properties_t<property_list_t,

sycl/include/sycl/types.hpp

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,8 +1544,37 @@ template <typename VecT, typename OperationLeftT, typename OperationRightT,
15441544
template <typename> class OperationCurrentT, int... Indexes>
15451545
class SwizzleOp {
15461546
using DataT = typename VecT::element_type;
1547-
using CommonDataT = std::common_type_t<typename OperationLeftT::DataT,
1548-
typename OperationRightT::DataT>;
1547+
// Certain operators return a vector with a different element type. Also, the
1548+
// left and right operand types may differ. CommonDataT selects a result type
1549+
// based on these types to ensure that the result value can be represented.
1550+
//
1551+
// Example 1:
1552+
// sycl::vec<unsigned char, 4> vec{...};
1553+
// auto result = 300u + vec.x();
1554+
//
1555+
// CommonDataT is std::common_type_t<OperationLeftT, OperationRightT> since
1556+
// it's larger than unsigned char.
1557+
//
1558+
// Example 2:
1559+
// sycl::vec<bool, 1> vec{...};
1560+
// auto result = vec.template swizzle<sycl::elem::s0>() && vec;
1561+
//
1562+
// CommonDataT is DataT since operator&& returns a vector with element type
1563+
// int8_t, which is larger than bool.
1564+
//
1565+
// Example 3:
1566+
// sycl::vec<std::byte, 4> vec{...}; auto swlo = vec.lo();
1567+
// auto result = swlo == swlo;
1568+
//
1569+
// CommonDataT is DataT since operator== returns a vector with element type
1570+
// int8_t, which is the same size as std::byte. std::common_type_t<DataT, ...>
1571+
// can't be used here since there's no type that int8_t and std::byte can both
1572+
// be implicitly converted to.
1573+
using OpLeftDataT = typename OperationLeftT::DataT;
1574+
using OpRightDataT = typename OperationRightT::DataT;
1575+
using CommonDataT = std::conditional_t<
1576+
sizeof(DataT) >= sizeof(std::common_type_t<OpLeftDataT, OpRightDataT>),
1577+
DataT, std::common_type_t<OpLeftDataT, OpRightDataT>>;
15491578
static constexpr int getNumElements() { return sizeof...(Indexes); }
15501579

15511580
using rel_t = detail::rel_t<DataT>;

sycl/plugins/unified_runtime/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ if(SYCL_PI_UR_USE_FETCH_CONTENT)
5757
include(FetchContent)
5858

5959
set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git")
60-
# commit 712d79120e0a9293daf5741f9c0b5269ddd862ce
60+
# commit b3de31844ca45d1815c54d85f248f13ad81b6755
6161
# Author: Kenneth Benzie (Benie) <k.benzie@codeplay.com>
62-
# Date: Fri Nov 24 12:34:51 2023 +0000
63-
# Set version to v0.8.0
64-
set(UNIFIED_RUNTIME_TAG v0.8.0)
62+
# Date: Tue Nov 28 16:21:43 2023 +0000
63+
# Set version to v0.8.1
64+
set(UNIFIED_RUNTIME_TAG v0.8.1)
6565

6666
if(SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO)
6767
set(UNIFIED_RUNTIME_REPO "${SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO}")

sycl/test-e2e/Annotated_arg_ptr/annotated_ptr.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ int main() {
2828

2929
auto *d = malloc_shared<int>(4, Q);
3030
auto d_ptr = annotated_ptr{d};
31+
32+
auto *e1 = malloc_shared<int>(1, Q);
33+
*e1 = 0;
34+
volatile int *e1_vol = e1;
35+
auto e1_ptr = annotated_ptr{e1_vol};
36+
37+
auto *e2 = malloc_shared<int>(1, Q);
38+
*e2 = 5;
39+
const volatile int *e2_vol = e2;
40+
auto e2_ptr = annotated_ptr{e2_vol};
41+
3142
for (int i = 0; i < 4; i++)
3243
d_ptr[i] = i;
3344
Q.single_task([=]() {
@@ -60,6 +71,8 @@ int main() {
6071
};
6172

6273
d_ptr[3] = func(d_ptr[0], d_ptr[1], d_ptr[2]);
74+
75+
e1_ptr[0] = e2_ptr[0];
6376
}).wait();
6477

6578
assert(a_ptr[0] == -1 && "a_ptr[0] value does not match.");
@@ -78,11 +91,15 @@ int main() {
7891

7992
assert(d_ptr[3] == -1 && "d_ptr[3] value does not match.");
8093

94+
assert(e1_ptr[0] == 5 && "e_ptr[0] value does not match.");
95+
8196
free(a, Q);
8297
free(b, Q);
8398
free(c->b, Q);
8499
free(c, Q);
85100
free(d, Q);
101+
free(e1, Q);
102+
free(e2, Q);
86103

87104
return 0;
88105
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// RUN: %{build} -o %t.out
2+
// RUN: %{run} %t.out
3+
4+
// RUN: %if preview-breaking-changes-supported %{ %clangxx -fsycl -fpreview-breaking-changes %s -o %t2.out %}
5+
// RUN: %if preview-breaking-changes-supported %{ %{run} %t2.out %}
6+
7+
#include <cstdlib>
8+
#include <sycl/sycl.hpp>
9+
10+
template <typename T, typename ResultT>
11+
bool testAndOperator(const std::string &typeName) {
12+
constexpr int N = 5;
13+
std::array<ResultT, N> results{};
14+
15+
sycl::queue q;
16+
sycl::buffer<ResultT, 1> buffer{results.data(), N};
17+
q.submit([&](sycl::handler &cgh) {
18+
sycl::accessor acc{buffer, cgh, sycl::write_only};
19+
cgh.parallel_for(sycl::range<1>{1}, [=](sycl::id<1> id) {
20+
auto testVec1 = sycl::vec<T, 1>(static_cast<T>(1));
21+
auto testVec2 = sycl::vec<T, 1>(static_cast<T>(2));
22+
sycl::vec<ResultT, 1> resVec;
23+
24+
ResultT expected = static_cast<ResultT>(
25+
-(static_cast<ResultT>(1) && static_cast<ResultT>(2)));
26+
acc[0] = expected;
27+
28+
// LHS swizzle
29+
resVec = testVec1.template swizzle<sycl::elem::s0>() && testVec2;
30+
acc[1] = resVec[0];
31+
32+
// RHS swizzle
33+
resVec = testVec1 && testVec2.template swizzle<sycl::elem::s0>();
34+
acc[2] = resVec[0];
35+
36+
// No swizzle
37+
resVec = testVec1 && testVec2;
38+
acc[3] = resVec[0];
39+
40+
// Both swizzle
41+
resVec = testVec1.template swizzle<sycl::elem::s0>() &&
42+
testVec2.template swizzle<sycl::elem::s0>();
43+
acc[4] = resVec[0];
44+
});
45+
}).wait();
46+
47+
bool passed = true;
48+
ResultT expected = results[0];
49+
50+
std::cout << "Testing with T = " << typeName << std::endl;
51+
std::cout << "Expected: " << (int)expected << std::endl;
52+
for (int i = 1; i < N; i++) {
53+
std::cout << "Test " << (i - 1) << ": " << ((int)results[i]) << std::endl;
54+
passed &= expected == results[i];
55+
}
56+
std::cout << std::endl;
57+
return passed;
58+
}
59+
60+
int main() {
61+
bool passed = true;
62+
passed &= testAndOperator<bool, std::int8_t>("bool");
63+
passed &= testAndOperator<std::int8_t, std::int8_t>("std::int8_t");
64+
passed &= testAndOperator<float, std::int32_t>("float");
65+
passed &= testAndOperator<int, std::int32_t>("int");
66+
std::cout << (passed ? "Pass" : "Fail") << std::endl;
67+
return (passed ? EXIT_SUCCESS : EXIT_FAILURE);
68+
}

sycl/test/extensions/annotated_ptr/annotated_ptr.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,18 @@ void TestVectorAddWithAnnotatedMMHosts() {
157157
std::cout << raw[i] << std::endl;
158158
}
159159

160+
class test {
161+
int n;
162+
163+
public:
164+
test(int n_) : n(n_) {}
165+
test(const test &t) { n = t.n; }
166+
};
167+
// expected-error-re@sycl/ext/oneapi/experimental/annotated_ptr/annotated_ptr.hpp:* {{static assertion failed due to requirement {{.+}}: annotated_ptr can only encapsulate either a trivially-copyable type or void!}}
168+
annotated_ptr<test> non_trivially_copyable;
169+
170+
annotated_ptr<void> void_type;
171+
160172
free(raw, q);
161173
}
162174

0 commit comments

Comments
 (0)