forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmem_advise.cpp
More file actions
63 lines (50 loc) · 1.56 KB
/
mem_advise.cpp
File metadata and controls
63 lines (50 loc) · 1.56 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// REQUIRES: aspect-usm_shared_allocations
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// This test checks whether the free function command mem_advise operation is
// valid.
#define __DPCPP_ENABLE_UNFINISHED_KHR_EXTENSIONS
#include <sycl/detail/core.hpp>
#include <sycl/khr/free_function_commands.hpp>
#include <sycl/usm.hpp>
int main() {
int Failed = 0;
constexpr size_t N = 1024;
sycl::context Context;
sycl::queue Queue;
int *Memory = sycl::malloc_shared<int>(N, Queue);
constexpr size_t ChunkSize = N / 3;
try {
sycl::khr::mem_advise(Queue, Memory, ChunkSize, 0);
} catch (sycl::exception &Excep) {
std::cout << "SYCL exception caught:" << Excep.what() << std::endl;
++Failed;
}
try {
sycl::khr::mem_advise(Queue, Memory, ChunkSize, 0);
} catch (sycl::exception &Excep) {
std::cout << "SYCL exception caught:" << Excep.what() << std::endl;
++Failed;
}
try {
sycl::khr::submit(Queue, [&](sycl::handler &CGH) {
sycl::khr::mem_advise(CGH, Memory + ChunkSize, ChunkSize, 0);
});
} catch (sycl::exception &Excep) {
std::cout << "SYCL exception caught:" << Excep.what() << std::endl;
++Failed;
}
try {
sycl::event Event =
sycl::khr::submit_tracked(Queue, [&](sycl::handler &Handler) {
sycl::khr::mem_advise(Handler, Memory + ChunkSize * 2, ChunkSize, 0);
});
Event.wait();
} catch (sycl::exception &Excep) {
std::cout << "SYCL exception caught:" << Excep.what() << std::endl;
++Failed;
}
Queue.wait();
sycl::free(Memory, Queue);
return Failed;
}