forked from intel/llvm-test-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatomic.cpp
More file actions
48 lines (40 loc) · 1.44 KB
/
atomic.cpp
File metadata and controls
48 lines (40 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// UNSUPPORTED: cuda
// RUN: %clangxx -fsycl -fsycl-instrument-device-code %s -o %t.out
// RUN: %HOST_RUN_PLACEHOLDER %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// RUN: %ACC_RUN_PLACEHOLDER %t.out
// RUN: %clangxx -fsycl -fsycl-instrument-device-code %s -o %t.cpu.out \
// RUN: -fsycl-targets=spir64_x86_64-unknown-unknown
// RUN: %CPU_RUN_PLACEHOLDER %t.cpu.out
#include "CL/sycl.hpp"
using namespace sycl;
int main() {
queue q{};
int source = 42;
int target = 0;
{
buffer<int> source_buf(&source, 1);
buffer<int> target_buf(&target, 1);
// Ensure that a simple kernel gets run when instrumented with
// ITT start/finish annotations and ITT atomic start/finish annotations.
q.submit([&](handler &cgh) {
auto source_acc =
source_buf.template get_access<access::mode::read_write>(cgh);
auto target_acc =
target_buf.template get_access<access::mode::discard_write>(cgh);
cgh.single_task<class simple_atomic_kernel>([=]() {
auto source_atomic =
ext::oneapi::atomic_ref<int, memory_order::relaxed,
memory_scope::device,
access::address_space::global_space>(
source_acc[0]);
// Store source value into target
target_acc[0] = source_atomic.load();
// Nullify source
source_atomic.store(0);
});
});
}
return 0;
}