Skip to content

Commit c905dcd

Browse files
committed
Add front end lit tests for host pipes
1 parent 823985f commit c905dcd

File tree

3 files changed

+105
-0
lines changed

3 files changed

+105
-0
lines changed

clang/test/CodeGenSYCL/Inputs/sycl.hpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,34 @@ class [[__sycl_detail__::device_global]] [[__sycl_detail__::global_variable_allo
151151
} // namespace oneapi
152152
} // namespace ext
153153

154+
namespace ext {
155+
namespace intel {
156+
namespace experimental {
157+
158+
// host_pipe class decorated with attribute
159+
template <class _name, class _dataT>
160+
class
161+
host_pipe {
162+
163+
public:
164+
struct
165+
#ifdef __SYCL_DEVICE_ONLY__
166+
// [[ __sycl_detail__::add_ir_attributes_global_variable(
167+
// "sycl-host-pipe", nullptr)]] [[__sycl_detail__::host_pipe]]
168+
[[__sycl_detail__::host_pipe]]
169+
#endif
170+
__pipeType { const char __p; };
171+
172+
static constexpr __pipeType __pipe = {0};
173+
static _dataT read() {
174+
(void)__pipe;
175+
}
176+
};
177+
178+
} // namespace experimental
179+
} // namespace intel
180+
} // namespace ext
181+
154182
template <int dim>
155183
struct id {
156184
template <typename... T>

clang/test/CodeGenSYCL/host_pipe.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -triple spir64-unknown-unknown-sycldevice -disable-llvm-passes -fsycl-unique-prefix=THE_PREFIX -std=c++17 -opaque-pointers -emit-llvm %s -o - | FileCheck %s
2+
#include "sycl.hpp"
3+
4+
// Test cases below show that 'sycl-unique-id' LLVM IR attribute is attached to the
5+
// global variable whose type is decorated with host_pipe attribute, and that a
6+
// unique string is generated.
7+
8+
// XFAIL:*
9+
10+
using namespace sycl::ext::intel::experimental;
11+
using namespace sycl;
12+
queue q;
13+
14+
// check that "sycl-unique-id" attribute is created for host pipes
15+
// CHECK: @_ZN4sycl3_V13ext5intel12experimental9host_pipeIZZZ3foovENKUlRNS0_7handlerEE_clES6_ENKUlvE_clEvE5HPIntiE6__pipeE = internal addrspace(1) constant %"struct.sycl::_V1::ext::intel::experimental::host_pipe<HPInt, int>::__pipeType" zeroinitializer, align 1 #[[HPINT_ATTRS:[0-9]+]]
16+
// CHECK: @_ZN4sycl3_V13ext5intel12experimental9host_pipeIZZZ3foovENKUlRNS0_7handlerEE_clES6_ENKUlvE_clEvE7HPFloatiE6__pipeE = internal addrspace(1) constant %"struct.sycl::_V1::ext::intel::experimental::host_pipe<HPFloat, int>::__pipeType" zeroinitializer, align 1 #[[HPFLOAT_ATTRS:[0-9]+]]
17+
18+
void foo() {
19+
q.submit([&](handler &h) {
20+
h.single_task<class kernel_name_1>([=]() {
21+
host_pipe<class HPInt, int>::read();
22+
host_pipe<class HPFloat, int>::read();
23+
});
24+
});
25+
}
26+
27+
// CHECK: attributes #[[HPINT_ATTRS]] = { "sycl-unique-id"="THE_PREFIX____ZN4sycl3_V13ext5intel12experimental9host_pipeIZZZ3foovENKUlRNS0_7handlerEE_clES6_ENKUlvE_clEvE5HPIntiE6__pipeE" }
28+
// CHECK: attributes #[[HPFLOAT_ATTRS]] = { "sycl-unique-id"="THE_PREFIX____ZN4sycl3_V13ext5intel12experimental9host_pipeIZZZ3foovENKUlRNS0_7handlerEE_clES6_ENKUlvE_clEvE7HPFloatiE6__pipeE"
29+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// RUN: %clang_cc1 -fsycl-is-device -std=c++17 -internal-isystem %S/Inputs -triple spir64-unknown-unknown -fsycl-int-footer=%t.footer.h -fsycl-int-header=%t.header.h -fsycl-unique-prefix=THE_PREFIX %s -emit-llvm -o %t.ll
2+
// RUN: FileCheck -input-file=%t.footer.h %s --check-prefix=CHECK-FOOTER
3+
// RUN: FileCheck -input-file=%t.header.h %s --check-prefix=CHECK-HEADER
4+
#include "sycl.hpp"
5+
6+
// Test cases below show that 'sycl-unique-id' LLVM IR attribute is attached to the
7+
// global variable whose type is decorated with host_pipe attribute, and that a
8+
// unique string is generated.
9+
10+
using namespace sycl::ext::intel::experimental;
11+
using namespace sycl;
12+
queue q;
13+
14+
void foo() {
15+
q.submit([&](handler &h) {
16+
h.single_task<class kernel_name_1>([=]() {
17+
host_pipe<class HPInt, int>::read();
18+
host_pipe<class HPFloat, int>::read();
19+
});
20+
});
21+
}
22+
23+
// CHECK-HEADER: namespace sycl {
24+
// CHECK-HEADER-NEXT: __SYCL_INLINE_VER_NAMESPACE(_V1) {
25+
// CHECK-HEADER-NEXT: namespace detail {
26+
// CHECK-HEADER-NEXT: namespace {
27+
// CHECK-HEADER-NEXT: class __sycl_host_pipe_registration {
28+
// CHECK-HEADER-NEXT: public:
29+
// CHECK-HEADER-NEXT: __sycl_host_pipe_registration() noexcept;
30+
// CHECK-HEADER-NEXT: };
31+
// CHECK-HEADER-NEXT: __sycl_host_pipe_registration __sycl_host_pipe_registrar;
32+
// CHECK-HEADER-NEXT: } // namespace
33+
// CHECK-HEADER: } // namespace detail
34+
// CHECK-HEADER: } // __SYCL_INLINE_VER_NAMESPACE(_V1)
35+
// CHECK-HEADER: } // namespace sycl
36+
37+
// CHECK-FOOTER: #include <sycl/detail/defines_elementary.hpp>
38+
// CHECK-FOOTER: #include <sycl/detail/host_pipe_map.hpp>
39+
// CHECK-FOOTER-NEXT: namespace sycl::detail {
40+
// CHECK-FOOTER-NEXT: namespace {
41+
// CHECK-FOOTER-NEXT: __sycl_host_pipe_registration::__sycl_host_pipe_registration() noexcept {
42+
43+
// CHECK-FOOTER: host_pipe_map::add((void *)&::sycl::ext::intel::experimental::host_pipe<HPInt, int>::__pipe, "THE_PREFIX____ZN4sycl3_V13ext5intel12experimental9host_pipeIZZZ3foovENKUlRNS0_7handlerEE_clES6_ENKUlvE_clEvE5HPIntiE6__pipeE");
44+
// CHECK-FOOTER: host_pipe_map::add((void *)&::sycl::ext::intel::experimental::host_pipe<HPFloat, int>::__pipe, "THE_PREFIX____ZN4sycl3_V13ext5intel12experimental9host_pipeIZZZ3foovENKUlRNS0_7handlerEE_clES6_ENKUlvE_clEvE7HPFloatiE6__pipeE");
45+
46+
// CHECK-FOOTER: } // namespace (unnamed)
47+
// CHECK-FOOTER: } // namespace sycl::detail
48+

0 commit comments

Comments
 (0)