Skip to content

Commit fae4acc

Browse files
[SYCL][Tests] Add more syclbin-dump tests (#19272)
1 parent f12ef02 commit fae4acc

File tree

7 files changed

+108
-14
lines changed

7 files changed

+108
-14
lines changed

sycl/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ add_custom_target( sycl-toolchain ALL
400400
DEPENDS sycl-runtime-libraries
401401
sycl-compiler
402402
sycl-ls
403+
syclbin-dump
403404
${XPTIFW_LIBS}
404405
COMMENT "Building SYCL compiler toolchain..."
405406
)
@@ -472,6 +473,7 @@ set( SYCL_TOOLCHAIN_DEPLOY_COMPONENTS
472473
spirv-to-ir-wrapper
473474
sycl-post-link
474475
sycl-ls
476+
syclbin-dump
475477
clang-resource-headers
476478
OpenCL-Headers
477479
opencl-aot
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// UNSUPPORTED: windows
2+
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/19373
3+
4+
// REQUIRES: ocloc
5+
6+
// RUN: %clangxx --offload-new-driver -fsyclbin=input -fsycl-targets=spir64_gen -Xsycl-target-backend=spir64_gen "-device bmg-g21" -o %t.input_bmg_g21_gpu_device_arch.syclbin %s
7+
// RUN: %clangxx --offload-new-driver -fsyclbin=input -fsycl-targets=spir64_gen -Xsycl-target-backend=spir64_gen "-device *" -o %t.input_all_gpu_device_archs.syclbin %s
8+
// RUN: %clangxx --offload-new-driver -fsyclbin=object -fsycl-targets=spir64_gen -Xsycl-target-backend=spir64_gen "-device bmg-g21" -o %t.object_bmg_g21_gpu_device_arch.syclbin %s
9+
// RUN: %clangxx --offload-new-driver -fsyclbin=executable -fsycl-targets=spir64_gen -Xsycl-target-backend=spir64_gen "-device bmg-g21" -o %t.executable_bmg_g21_gpu_device_arch.syclbin %s
10+
// RUN: %clangxx --offload-new-driver -fsyclbin -fsycl-targets=spir64_gen -Xsycl-target-backend=spir64_gen "-device bmg-g21" -o %t.default_bmg_g21_gpu_device_arch.syclbin %s
11+
12+
// RUN: syclbin-dump %t.input_bmg_g21_gpu_device_arch.syclbin | FileCheck %s --check-prefix CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH
13+
// RUN: syclbin-dump %t.input_all_gpu_device_archs.syclbin | FileCheck %s --check-prefix CHECK-INPUT-ALL-GPU-DEVICE-ARCHS
14+
// RUN: syclbin-dump %t.object_bmg_g21_gpu_device_arch.syclbin | FileCheck %s --check-prefix CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH
15+
// RUN: syclbin-dump %t.executable_bmg_g21_gpu_device_arch.syclbin | FileCheck %s --check-prefix CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH
16+
// RUN: syclbin-dump %t.default_bmg_g21_gpu_device_arch.syclbin | FileCheck %s --check-prefix CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH
17+
18+
// Checks the generated SYCLBIN contents of a simple SYCL free function kernel.
19+
20+
#include <sycl/sycl.hpp>
21+
22+
extern "C" {
23+
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY(
24+
(sycl::ext::oneapi::experimental::single_task_kernel))
25+
void TestKernel(int *Ptr, int Size) {
26+
for (size_t I = 0; I < Size; ++I)
27+
Ptr[I] = I;
28+
}
29+
}
30+
31+
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH: Version: {{[1-9]+}}
32+
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Global metadata:
33+
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: SYCLBIN/global metadata:
34+
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: state: 0
35+
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Number of Abstract Modules: 1
36+
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Abstract Module 0:
37+
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Metadata:
38+
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH: Number of IR Modules: 0
39+
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Number of Native Device Code Images: 1
40+
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Native device code image 0:
41+
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Metadata:
42+
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: SYCLBIN/native device code image metadata:
43+
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: arch:{{.*}}
44+
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: target:{{.*}}spir64_gen-unknown
45+
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Raw native device code image bytes: <Binary blob of {{.*}} bytes>
46+
47+
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS: Version: {{[1-9]+}}
48+
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: Global metadata:
49+
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: SYCLBIN/global metadata:
50+
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: state: 0
51+
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: Number of Abstract Modules: 1
52+
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: Abstract Module 0:
53+
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: Metadata:
54+
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS: Number of IR Modules: 0
55+
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: Number of Native Device Code Images: 1
56+
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: Native device code image 0:
57+
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: Metadata:
58+
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: SYCLBIN/native device code image metadata:
59+
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: arch:{{.*}}
60+
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: target:{{.*}}spir64_gen-unknown
61+
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: Raw native device code image bytes: <Binary blob of {{.*}} bytes>
62+
63+
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH: Version: {{[1-9]+}}
64+
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Global metadata:
65+
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: SYCLBIN/global metadata:
66+
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: state: 1
67+
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Number of Abstract Modules: 1
68+
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Abstract Module 0:
69+
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Metadata:
70+
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH: Number of IR Modules: 0
71+
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Number of Native Device Code Images: 1
72+
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Native device code image 0:
73+
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Metadata:
74+
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: SYCLBIN/native device code image metadata:
75+
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: arch:{{.*}}
76+
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: target:{{.*}}spir64_gen-unknown
77+
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Raw native device code image bytes: <Binary blob of {{.*}} bytes>
78+
79+
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH: Version: {{[1-9]+}}
80+
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: Global metadata:
81+
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: SYCLBIN/global metadata:
82+
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: state: 2
83+
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: Number of Abstract Modules: 1
84+
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: Abstract Module 0:
85+
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: Metadata:
86+
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH: Number of IR Modules: 0
87+
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: Number of Native Device Code Images: 1
88+
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: Native device code image 0:
89+
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: Metadata:
90+
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: SYCLBIN/native device code image metadata:
91+
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: arch:{{.*}}
92+
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: target:{{.*}}spir64_gen-unknown
93+
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: Raw native device code image bytes: <Binary blob of {{.*}} bytes>

sycl/test-e2e/lit.cfg.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,12 @@ def open_check_file(file_name):
630630
if not sycl_ls:
631631
lit_config.fatal("can't find `sycl-ls`")
632632

633+
syclbin_dump = FindTool("syclbin-dump").resolve(
634+
llvm_config, os.pathsep.join([config.dpcpp_bin_dir, config.llvm_tools_dir])
635+
)
636+
if not syclbin_dump:
637+
lit_config.fatal("can't find `syclbin-dump`")
638+
633639
if (
634640
len(config.sycl_build_targets) == 1
635641
and next(iter(config.sycl_build_targets)) == "target-all"
@@ -807,6 +813,7 @@ def remove_level_zero_suffix(devices):
807813
r"\| \bnot\b", command=FindTool("not"), verbatim=True, unresolved="ignore"
808814
),
809815
ToolSubst("sycl-ls", command=sycl_ls, unresolved="ignore"),
816+
ToolSubst("syclbin-dump", command=syclbin_dump, unresolved="ignore"),
810817
] + feature_tools
811818

812819
# Try and find each of these tools in the DPC++ bin directory, in the llvm tools directory

sycl/test/e2e_test_requirements/no_sycl_hpp_in_e2e_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// CHECK-DAG: README.md
77
// CHECK-DAG: lit.cfg.py
88
//
9-
// CHECK-NUM-MATCHES: 28
9+
// CHECK-NUM-MATCHES: 29
1010
//
1111
// This test verifies that `<sycl/sycl.hpp>` isn't used in E2E tests. Instead,
1212
// fine-grained includes should used, see
126 KB
Binary file not shown.

sycl/test/syclbin/input_files.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: not syclbin-dump nonexistent.syclbin 2>&1 | FileCheck %s --check-prefix CHECK-NONEXISTENT-FILE
2+
// RUN: not syclbin-dump %S/Inputs/malformed.syclbin 2>&1 | FileCheck %s --check-prefix CHECK-MALFORMED-FILE
3+
4+
// CHECK-NONEXISTENT-FILE: Failed to open or read file nonexistent.syclbin
5+
// CHECK-MALFORMED-FILE: Invalid data was encountered while parsing the file

sycl/tools/syclbin-dump/syclbin-dump.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,6 @@ raw_ostream &operator<<(raw_ostream &OS, const ScopedIndent &) {
5050
return OS.indent(CurrentIndentationLevel);
5151
}
5252

53-
std::string_view StateToString(llvm::object::SYCLBIN::BundleState State) {
54-
switch (State) {
55-
case llvm::object::SYCLBIN::BundleState::Input:
56-
return "input";
57-
case llvm::object::SYCLBIN::BundleState::Object:
58-
return "object";
59-
case llvm::object::SYCLBIN::BundleState::Executable:
60-
return "executable";
61-
default:
62-
return "UNKNOWN";
63-
}
64-
}
65-
6653
std::string PropertyValueToString(const llvm::util::PropertyValue &PropVal) {
6754
switch (PropVal.getType()) {
6855
case llvm::util::PropertyValue::UINT32:

0 commit comments

Comments
 (0)