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

Commit 6bc57b4

Browse files
authored
[SYCL] Test Level Zero static link flow (#716)
Add a test that traces the PI calls and the Level Zero driver calls, and makes sure that the sequence of calls is consistent with the "static linking" implementation.
1 parent 6c240b1 commit 6bc57b4

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// RUN: %clangxx -fsycl %s -o %t.out
2+
// RUN: %GPU_RUN_PLACEHOLDER SYCL_PI_TRACE=-1 ZE_DEBUG=1 %t.out 2>&1 | FileCheck %s
3+
// REQUIRES: level_zero
4+
//
5+
//==--- level-zero-static-link-flow.cpp.cpp - Check L0 static link flow --==//
6+
//
7+
// Run a simple program that uses online linking and verify that the sequence
8+
// of calls to the plugin and to the Level Zero driver are consistent with the
9+
// "static linking" implementation.
10+
//
11+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
12+
// See https://llvm.org/LICENSE.txt for license information.
13+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
14+
//
15+
//===--------------------------------------------------------------===//
16+
17+
// The key thing we check here is that the call to "zeModuleCreate" does not
18+
// happen from "piProgramCompile". Instead, we expect it to be delayed and
19+
// called from "piProgramLink".
20+
//
21+
// CHECK: ---> piProgramCreate
22+
// CHECK: ---> piProgramCompile
23+
// CHECK-NOT: ZE ---> zeModuleCreate
24+
// CHECK: ---> piProgramLink
25+
// CHECK: ZE ---> zeModuleCreate
26+
27+
#include <sycl/sycl.hpp>
28+
29+
class MyKernel;
30+
31+
void test() {
32+
sycl::queue Queue;
33+
sycl::context Context = Queue.get_context();
34+
35+
auto BundleInput =
36+
sycl::get_kernel_bundle<MyKernel, sycl::bundle_state::input>(Context);
37+
auto BundleObject = sycl::compile(BundleInput);
38+
sycl::link(BundleObject);
39+
40+
// We need to define the kernel function, but we don't actually need to
41+
// submit it to the device.
42+
if (false) {
43+
Queue.submit([&](sycl::handler &CGH) { CGH.single_task<MyKernel>([=] {}); })
44+
.wait();
45+
}
46+
}
47+
48+
int main() {
49+
test();
50+
51+
return 0;
52+
}

0 commit comments

Comments
 (0)