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

Commit b0732c3

Browse files
authored
[SYCL] Add new test case for buffer creation with pinned host memory (#97)
1 parent d95cd02 commit b0732c3

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// REQUIRES: level_zero
2+
3+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t2.out
4+
// RUN: env SYCL_PI_TRACE=2 ZE_DEBUG=1 %GPU_RUN_PLACEHOLDER %t2.out 2>&1 %GPU_CHECK_PLACEHOLDER
5+
// RUN: %HOST_RUN_PLACEHOLDER %t2.out
6+
// RUN: %CPU_RUN_PLACEHOLDER %t2.out
7+
// RUN: %GPU_RUN_PLACEHOLDER %t2.out
8+
// RUN: %ACC_RUN_PLACEHOLDER %t2.out
9+
10+
#include <CL/sycl.hpp>
11+
12+
#include <cassert>
13+
#include <string>
14+
15+
using namespace cl::sycl;
16+
17+
int main() {
18+
{
19+
int data1[10] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
20+
{
21+
buffer<int, 1> a(data1, range<1>(10), {property::buffer::use_host_ptr()});
22+
buffer<int, 1> b(
23+
range<1>(10),
24+
{ext::oneapi::property::buffer::use_pinned_host_memory()});
25+
queue myQueue;
26+
myQueue.submit([&](handler &cgh) {
27+
auto A = a.get_access<access::mode::read_write>(cgh);
28+
auto B = b.get_access<access::mode::read_write>(cgh);
29+
cgh.parallel_for<class init_b>(range<1>{10}, [=](id<1> index) {
30+
B[index] = 0;
31+
A[index] = B[index] + 1;
32+
});
33+
});
34+
} // Data is copied back because there is a user side shared_ptr
35+
for (int i = 0; i < 10; i++)
36+
assert(data1[i] == 1);
37+
}
38+
}
39+
40+
// CHECK:---> piMemBufferCreate
41+
// CHECK-NEXT: {{.*}} : {{.*}}
42+
// CHECK-NEXT: {{.*}} : 9
43+
// CHECK:ZE ---> zeMemAllocHost

0 commit comments

Comments
 (0)