Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit f2771a6

Browse files
author
Artem Gindinson
authored
[SYCL] Add E2E tests for device code instrumentation (#484)
Signed-off-by: Artem Gindinson <[email protected]>
1 parent 36752c9 commit f2771a6

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ SYCL/DeviceCodeSplit @AlexeySachkov @Fznamznon
2323

2424
# Device library
2525
SYCL/DeviceLib @vzakhari
26+
SYCL/DeviceLib/ITTAnnotations @vzakhari @MrSidims @AGindinson
2627

2728
# dot_product API
2829
SYCL/DotProduct @rdeodhar
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// UNSUPPORTED: cuda || hip
2+
3+
// RUN: %clangxx -fsycl -fsycl-instrument-device-code %s -o %t.out
4+
// RUN: %HOST_RUN_PLACEHOLDER %t.out
5+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
6+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
7+
// RUN: %ACC_RUN_PLACEHOLDER %t.out
8+
9+
// RUN: %clangxx -fsycl -fsycl-instrument-device-code %s -o %t.cpu.out \
10+
// RUN: -fsycl-targets=spir64_x86_64-unknown-unknown
11+
// RUN: %CPU_RUN_PLACEHOLDER %t.cpu.out
12+
13+
#include "CL/sycl.hpp"
14+
15+
using namespace sycl;
16+
17+
int main() {
18+
queue q{};
19+
20+
int source = 42;
21+
int target = 0;
22+
{
23+
buffer<int> source_buf(&source, 1);
24+
buffer<int> target_buf(&target, 1);
25+
26+
// Ensure that a simple kernel gets run when instrumented with
27+
// ITT start/finish annotations and ITT atomic start/finish annotations.
28+
q.submit([&](handler &cgh) {
29+
auto source_acc =
30+
source_buf.template get_access<access::mode::read_write>(cgh);
31+
auto target_acc =
32+
target_buf.template get_access<access::mode::discard_write>(cgh);
33+
cgh.single_task<class simple_atomic_kernel>([=]() {
34+
auto source_atomic =
35+
ext::oneapi::atomic_ref<int, memory_order::relaxed,
36+
memory_scope::device,
37+
access::address_space::global_space>(
38+
source_acc[0]);
39+
// Store source value into target
40+
target_acc[0] = source_atomic.load();
41+
// Nullify source
42+
source_atomic.store(0);
43+
});
44+
});
45+
}
46+
47+
return 0;
48+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// UNSUPPORTED: cuda || hip
2+
3+
// RUN: %clangxx -fsycl -fsycl-instrument-device-code %s -o %t.out
4+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
5+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
6+
// RUN: %ACC_RUN_PLACEHOLDER %t.out
7+
8+
// RUN: %clangxx -fsycl -fsycl-instrument-device-code %s -o %t.cpu.out \
9+
// RUN: -fsycl-targets=spir64_x86_64-unknown-unknown
10+
// RUN: %CPU_RUN_PLACEHOLDER %t.cpu.out
11+
12+
#include "CL/sycl.hpp"
13+
#include <vector>
14+
15+
using namespace sycl;
16+
17+
int main() {
18+
queue q{};
19+
20+
std::vector<int> data_vec(/*size*/ 10, /*value*/ 0);
21+
{
22+
range<1> num_items(data_vec.size());
23+
buffer<int> buf(data_vec.data(), num_items);
24+
range<1> local_range(2);
25+
26+
// Ensure that a simple kernel gets run when instrumented with
27+
// ITT start/finish annotations and ITT wg_barrier/wi_resume annotations.
28+
q.submit([&](handler &cgh) {
29+
auto acc = buf.get_access<access::mode::read_write>(cgh);
30+
accessor<int, 1, access::mode::read_write, access::target::local>
31+
local_acc(local_range, cgh);
32+
cgh.parallel_for<class simple_barrier_kernel>(
33+
nd_range<1>(num_items, local_range), [=](nd_item<1> item) {
34+
size_t idx = item.get_global_linear_id();
35+
int pos = idx & 1;
36+
int opp = pos ^ 1;
37+
local_acc[pos] = acc[idx];
38+
item.barrier(access::fence_space::local_space);
39+
acc[idx] = local_acc[opp];
40+
});
41+
});
42+
}
43+
44+
return 0;
45+
}

0 commit comments

Comments
 (0)