Skip to content

Commit d5f28d2

Browse files
committed
Device code test for cuda native fcts.
Signed-off-by: JackAKirk <[email protected]>
1 parent fe57ef6 commit d5f28d2

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// REQUIRES: cuda
2+
3+
// RUN: %clangxx -fsycl -fsycl-targets=nvptx64-nvidia-cuda -S -Xclang -emit-llvm %s -o -| FileCheck %s
4+
5+
#include <sycl/sycl.hpp>
6+
7+
using namespace sycl;
8+
9+
int main() {
10+
11+
queue q;
12+
13+
float input[2];
14+
float res[13];
15+
{
16+
buffer<float, 1> input_buff(&input[0], range<1>(2));
17+
buffer<float, 1> res_buff(&res[0], range<1>(13));
18+
q.submit([&](handler &cgh) {
19+
accessor<float, 1, access::mode::write, target::device> res_acc(res_buff,
20+
cgh);
21+
accessor<float, 1, access::mode::read, target::device> input_acc(
22+
input_buff, cgh);
23+
cgh.single_task([=]() {
24+
// CHECK: tail call float @llvm.nvvm.cos.approx.f
25+
res_acc[0] = sycl::native::cos(input_acc[0]);
26+
// CHECK: tail call float @llvm.nvvm.sin.approx.f
27+
res_acc[1] = sycl::native::sin(input_acc[0]);
28+
// CHECK: tail call float @llvm.nvvm.ex2.approx.f
29+
res_acc[2] = sycl::native::exp2(input_acc[0]);
30+
// CHECK: tail call float @llvm.nvvm.lg2.approx.f
31+
res_acc[3] = sycl::native::log2(input_acc[0]);
32+
// CHECK: tail call float @llvm.nvvm.rsqrt.approx.f
33+
res_acc[4] = sycl::native::rsqrt(input_acc[0]);
34+
// CHECK: tail call float @llvm.nvvm.sqrt.approx.f
35+
res_acc[5] = sycl::native::sqrt(input_acc[0]);
36+
// CHECK: tail call float @llvm.nvvm.rcp.approx.f
37+
res_acc[6] = sycl::native::recip(input_acc[0]);
38+
// CHECK: tail call float @llvm.nvvm.div.approx.f
39+
res_acc[7] = sycl::native::divide(input_acc[0], input_acc[1]);
40+
41+
// Functions that use the above builtins:
42+
43+
// CHECK: tail call float @llvm.nvvm.sin.approx.f
44+
// CHECK: tail call float @llvm.nvvm.cos.approx.f
45+
// CHECK: tail call float @llvm.nvvm.div.approx.f
46+
res_acc[8] = sycl::native::tan(input_acc[0]);
47+
// CHECK: fmul float {{.*}}, 0x3FF7154760000000
48+
// CHECK: tail call float @llvm.nvvm.ex2.approx.f
49+
res_acc[9] = sycl::native::exp(input_acc[0]);
50+
// CHECK: fmul float {{.*}}, 0x400A934F00000000
51+
// CHECK: tail call float @llvm.nvvm.ex2.approx.f
52+
res_acc[10] = sycl::native::exp10(input_acc[0]);
53+
// CHECK: tail call float @llvm.nvvm.lg2.approx.f
54+
// CHECK: fmul float {{.*}}, 0x3FE62E4300000000
55+
res_acc[11] = sycl::native::log(input_acc[0]);
56+
// CHECK: tail call float @llvm.nvvm.lg2.approx.f
57+
// CHECK: fmul float {{.*}}, 0x3FD3441360000000
58+
res_acc[12] = sycl::native::log10(input_acc[0]);
59+
60+
// CHECK: tail call float @llvm.nvvm.lg2.approx.f
61+
// CHECK: fmul float {{.*}}, {{.*}}
62+
// CHECK: tail call float @llvm.nvvm.ex2.approx.f
63+
res_acc[13] = sycl::native::powr(input_acc[0], input_acc[1]);
64+
});
65+
});
66+
}
67+
68+
return 0;
69+
};

0 commit comments

Comments
 (0)