Skip to content

Commit 08b2022

Browse files
authored
[SYCL] Mark half class to use aspect (#6970)
As part of an optional kernel feature implementation types that using special aspect should be marked appropriately.
1 parent 25ba5bc commit 08b2022

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

sycl/include/sycl/half_type.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#pragma once
1010

11+
#include <sycl/aspects.hpp>
1112
#include <sycl/detail/defines.hpp>
1213
#include <sycl/detail/export.hpp>
1314
#include <sycl/detail/iostream_proxy.hpp>
@@ -265,7 +266,11 @@ using Vec8StorageT = half_vec<8>;
265266
using Vec16StorageT = half_vec<16>;
266267
#endif
267268

269+
#ifndef __SYCL_DEVICE_ONLY__
268270
class half {
271+
#else
272+
class [[__sycl_detail__::__uses_aspects__(aspect::fp16)]] half {
273+
#endif
269274
public:
270275
half() = default;
271276
constexpr half(const half &) = default;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %clangxx %s -S -o %t.ll -fsycl-device-only
2+
// RUN: FileCheck %s --input-file %t.ll
3+
4+
// CHECK: !sycl_types_that_use_aspects = !{![[#MDNUM:]]}
5+
// CHECK: ![[#MDNUM]] = !{!"class.sycl::_V1::detail::half_impl::half", i32 [[#ASPECT_NUM:]]}
6+
// CHECK: !{{.*}} = !{!"fp16", i32 [[#ASPECT_NUM]]}
7+
8+
#include <sycl/sycl.hpp>
9+
10+
int main() {
11+
sycl::queue q;
12+
q.submit([&](sycl::handler &h) {
13+
h.single_task([=]() {
14+
sycl::half h;
15+
h = 10.0;
16+
});
17+
});
18+
return 0;
19+
}

0 commit comments

Comments
 (0)