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

Commit cd495f0

Browse files
[SYCL][L0] check eager init mode (#1091)
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent 1ea3cc0 commit cd495f0

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

SYCL/Plugin/level_zero_eager_init.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// REQUIRES: level_zero, level_zero_dev_kit
2+
3+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out
4+
// RUN: env ZE_DEBUG=1 SYCL_EAGER_INIT=1 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER
5+
//
6+
// The test is to check that under SYCL_EAGER_INIT=1 there is no calls to
7+
// heavy L0 initialization in the hot reportable path.
8+
//
9+
// CHECK-LABEL: HOT HOT HOT
10+
// CHECK-NOT: zeCommandQueueCreate
11+
// CHECK-NOT: zeCommandListCreate
12+
// CHECK-NOT: zeFenceCreate
13+
//
14+
15+
#include <CL/sycl.hpp>
16+
17+
#include <array>
18+
#include <iostream>
19+
20+
constexpr cl::sycl::access::mode sycl_read = cl::sycl::access::mode::read;
21+
constexpr cl::sycl::access::mode sycl_write = cl::sycl::access::mode::write;
22+
23+
/* This is the class used to name the kernel for the runtime.
24+
* This must be done when the kernel is expressed as a lambda. */
25+
template <typename T> class SimpleVadd;
26+
27+
template <typename T, size_t N>
28+
void simple_vadd(cl::sycl::queue &Queue, const std::array<T, N> &VA,
29+
const std::array<T, N> &VB, std::array<T, N> &VC) {
30+
cl::sycl::range<1> numOfItems{N};
31+
cl::sycl::buffer<T, 1> bufferA(VA.data(), numOfItems);
32+
cl::sycl::buffer<T, 1> bufferB(VB.data(), numOfItems);
33+
cl::sycl::buffer<T, 1> bufferC(VC.data(), numOfItems);
34+
35+
Queue.submit([&](cl::sycl::handler &cgh) {
36+
auto accessorA = bufferA.template get_access<sycl_read>(cgh);
37+
auto accessorB = bufferB.template get_access<sycl_read>(cgh);
38+
auto accessorC = bufferC.template get_access<sycl_write>(cgh);
39+
40+
cgh.parallel_for<class SimpleVadd<T>>(
41+
numOfItems, [=](cl::sycl::id<1> wiID) {
42+
accessorC[wiID] = accessorA[wiID] + accessorB[wiID];
43+
});
44+
});
45+
}
46+
47+
int main() {
48+
const size_t array_size = 4;
49+
std::array<cl::sycl::cl_int, array_size> A = {{1, 2, 3, 4}},
50+
B = {{1, 2, 3, 4}}, C;
51+
cl::sycl::queue Q;
52+
53+
// simple_vadd(Q, A, B, C);
54+
std::cerr << "\n\n\nHOT HOT HOT\n\n\n";
55+
simple_vadd(Q, A, B, C);
56+
return 0;
57+
}

0 commit comments

Comments
 (0)