Skip to content

[SYCL][Tests] Add more syclbin-dump tests #19272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: sycl
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions sycl/test-e2e/SYCLBIN/simple_kernel_aot.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// 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
// 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
// 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
// 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
// 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

// RUN: syclbin-dump %t.input_bmg_g21_gpu_device_arch.syclbin | FileCheck %s --check-prefix CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH
// RUN: syclbin-dump %t.input_all_gpu_device_archs.syclbin | FileCheck %s --check-prefix CHECK-INPUT-ALL-GPU-DEVICE-ARCHS
// RUN: syclbin-dump %t.object_bmg_g21_gpu_device_arch.syclbin | FileCheck %s --check-prefix CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH
// RUN: syclbin-dump %t.executable_bmg_g21_gpu_device_arch.syclbin | FileCheck %s --check-prefix CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH
// RUN: syclbin-dump %t.default_bmg_g21_gpu_device_arch.syclbin | FileCheck %s --check-prefix CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH

// Checks the generated SYCLBIN contents of a simple SYCL free function kernel.

#include <sycl/sycl.hpp>

extern "C" {
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY(
(sycl::ext::oneapi::experimental::single_task_kernel))
void TestKernel(int *Ptr, int Size) {
for (size_t I = 0; I < Size; ++I)
Ptr[I] = I;
}
}

// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH: Version: {{[1-9]+}}
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Global metadata:
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: SYCLBIN/global metadata:
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: state: 0
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Number of Abstract Modules: 1
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Abstract Module 0:
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Metadata:
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH: Number of IR Modules: 0
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Number of Native Device Code Images: 1
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Native device code image 0:
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Metadata:
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: SYCLBIN/native device code image metadata:
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: arch:{{.*}}
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: target:{{.*}}spir64_gen-unknown
// CHECK-INPUT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Raw native device code image bytes: <Binary blob of {{.*}} bytes>

// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS: Version: {{[1-9]+}}
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: Global metadata:
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: SYCLBIN/global metadata:
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: state: 0
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: Number of Abstract Modules: 1
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: Abstract Module 0:
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: Metadata:
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS: Number of IR Modules: 0
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: Number of Native Device Code Images: 1
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: Native device code image 0:
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: Metadata:
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: SYCLBIN/native device code image metadata:
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: arch:{{.*}}
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: target:{{.*}}spir64_gen-unknown
// CHECK-INPUT-ALL-GPU-DEVICE-ARCHS-NEXT: Raw native device code image bytes: <Binary blob of {{.*}} bytes>

// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH: Version: {{[1-9]+}}
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Global metadata:
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: SYCLBIN/global metadata:
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: state: 1
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Number of Abstract Modules: 1
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Abstract Module 0:
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Metadata:
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH: Number of IR Modules: 0
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Number of Native Device Code Images: 1
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Native device code image 0:
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Metadata:
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: SYCLBIN/native device code image metadata:
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: arch:{{.*}}
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: target:{{.*}}spir64_gen-unknown
// CHECK-OBJECT-BMG-G21-GPU-DEVICE-ARCH-NEXT: Raw native device code image bytes: <Binary blob of {{.*}} bytes>

// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH: Version: {{[1-9]+}}
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: Global metadata:
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: SYCLBIN/global metadata:
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: state: 2
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: Number of Abstract Modules: 1
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: Abstract Module 0:
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: Metadata:
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH: Number of IR Modules: 0
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: Number of Native Device Code Images: 1
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: Native device code image 0:
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: Metadata:
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: SYCLBIN/native device code image metadata:
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: arch:{{.*}}
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: target:{{.*}}spir64_gen-unknown
// CHECK-EXECUTABLE-BMG-G21-GPU-DEVICE-ARCH-NEXT: Raw native device code image bytes: <Binary blob of {{.*}} bytes>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// CHECK-DAG: README.md
// CHECK-DAG: lit.cfg.py
//
// CHECK-NUM-MATCHES: 29
// CHECK-NUM-MATCHES: 30
//
// This test verifies that `<sycl/sycl.hpp>` isn't used in E2E tests. Instead,
// fine-grained includes should used, see
Expand Down
Binary file added sycl/test/syclbin/Inputs/malformed.syclbin
Binary file not shown.
5 changes: 5 additions & 0 deletions sycl/test/syclbin/input_files.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// RUN: syclbin-dump nonexistent.syclbin | FileCheck %s --check-prefix CHECK-NONEXISTENT-FILE
// RUN: syclbin-dump Inputs/malformed.syclbin | FileCheck %s --check-prefix CHECK-MALFORMED-FILE

// CHECK-NONEXISTENT-FILE: Failed to open or read file nonexistent.syclbin
// CHECK-MALFORMED-FILE: Invalid data was encountered while parsing the file
13 changes: 0 additions & 13 deletions sycl/tools/syclbin-dump/syclbin-dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,6 @@ raw_ostream &operator<<(raw_ostream &OS, const ScopedIndent &) {
return OS.indent(CurrentIndentationLevel);
}

std::string_view StateToString(llvm::object::SYCLBIN::BundleState State) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed as it was not used and it was affecting the code coverage

switch (State) {
case llvm::object::SYCLBIN::BundleState::Input:
return "input";
case llvm::object::SYCLBIN::BundleState::Object:
return "object";
case llvm::object::SYCLBIN::BundleState::Executable:
return "executable";
default:
return "UNKNOWN";
}
}

std::string PropertyValueToString(const llvm::util::PropertyValue &PropVal) {
switch (PropVal.getType()) {
case llvm::util::PropertyValue::UINT32:
Expand Down
Loading