Skip to content

Commit 306a781

Browse files
[SYCL][NewOffloadDriver] Fix SYCL E2E image compression test for new offload model (#20717)
This patch addresses test failures in SYCL E2E image compression by testing this feature for two offloading models in separate tests: (1) The `--no-offload-new-driver` flag is added to the test command in `Compression/compression_separate_compile.cpp`. This ensures the test uses the old offloading model where `clang-offload-wrapper` (which the test validates) is actually invoked. (2) Created a new test file `NewOffloadDriver/image_compression.cpp` to verify image compression functionality works correctly with the new offloading driver. With this patch, the` Compression/compression_separate_compile.cpp` SYCL E2E test will pass with the new offloading model.
1 parent 33aea69 commit 306a781

File tree

2 files changed

+94
-8
lines changed

2 files changed

+94
-8
lines changed

sycl/test-e2e/Compression/compression_separate_compile.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// End-to-End test for testing device image compression when we
2-
// seperatly compile and link device images.
2+
// separately compile and link device images.
3+
// This test validates the old offloading model.
4+
// The corresponding image compression test for the new offloading
5+
// model can be found in NewOffloadDriver/image_compression.cpp
36

47
// REQUIRES: zstd, opencl-aot, cpu, linux
58

@@ -8,24 +11,24 @@
811

912
// CPU AOT targets host isa, so we compile everything on the run system instead.
1013
////////////////////// Compile device images
11-
// RUN: %{run-aux} %clangxx -fsycl -fsycl-targets=spir64_x86_64 -fsycl-host-compiler=clang++ -fsycl-host-compiler-options='-std=c++17 -Wno-attributes -Wno-deprecated-declarations -fPIC -DENABLE_KERNEL1' -DENABLE_KERNEL1 -c %s -o %t_kernel1_aot.o
12-
// RUN: %{run-aux} %clangxx -fsycl -fsycl-targets=spir64_x86_64 -fsycl-host-compiler=clang++ -fsycl-host-compiler-options='-std=c++17 -Wno-attributes -Wno-deprecated-declarations -fPIC -DENABLE_KERNEL2' -DENABLE_KERNEL2 -c %s -o %t_kernel2_aot.o
14+
// RUN: %{run-aux} %clangxx --no-offload-new-driver -fsycl -fsycl-targets=spir64_x86_64 -fsycl-host-compiler=clang++ -fsycl-host-compiler-options='-std=c++17 -Wno-attributes -Wno-deprecated-declarations -fPIC -DENABLE_KERNEL1' -DENABLE_KERNEL1 -c %s -o %t_kernel1_aot.o
15+
// RUN: %{run-aux} %clangxx --no-offload-new-driver -fsycl -fsycl-targets=spir64_x86_64 -fsycl-host-compiler=clang++ -fsycl-host-compiler-options='-std=c++17 -Wno-attributes -Wno-deprecated-declarations -fPIC -DENABLE_KERNEL2' -DENABLE_KERNEL2 -c %s -o %t_kernel2_aot.o
1316

1417
////////////////////// Link device images
15-
// RUN: %{run-aux} %clangxx --offload-compress -fsycl -fsycl-link -fsycl-targets=spir64_x86_64 -fPIC %t_kernel1_aot.o %t_kernel2_aot.o -o %t_compressed_image.o -v
18+
// RUN: %{run-aux} %clangxx --no-offload-new-driver --offload-compress -fsycl -fsycl-link -fsycl-targets=spir64_x86_64 -fPIC %t_kernel1_aot.o %t_kernel2_aot.o -o %t_compressed_image.o -v
1619

1720
// Make sure the clang-offload-wrapper is called with the --offload-compress
18-
// option.
19-
// RUN: %{run-aux} %clangxx --offload-compress -fsycl -fsycl-link -fsycl-targets=spir64_x86_64 -fPIC %t_kernel1_aot.o %t_kernel2_aot.o -o %t_compressed_image.o -### &> %t_driver_opts.txt
21+
// option when using the old offloading model.
22+
// RUN: %{run-aux} %clangxx --no-offload-new-driver --offload-compress -fsycl -fsycl-link -fsycl-targets=spir64_x86_64 -fPIC %t_kernel1_aot.o %t_kernel2_aot.o -o %t_compressed_image.o -### &> %t_driver_opts.txt
2023
// RUN: %{run-aux} FileCheck -input-file=%t_driver_opts.txt %s --check-prefix=CHECK-DRIVER-OPTS
2124

2225
// CHECK-DRIVER-OPTS: clang-offload-wrapper{{.*}} "-offload-compress"
2326

2427
////////////////////// Compile the host program
25-
// RUN: %{run-aux} %clangxx -fsycl -std=c++17 -Wno-attributes -Wno-deprecated-declarations -fPIC -c %s -o %t_main.o
28+
// RUN: %{run-aux} %clangxx --no-offload-new-driver -fsycl -std=c++17 -Wno-attributes -Wno-deprecated-declarations -fPIC -c %s -o %t_main.o
2629

2730
////////////////////// Link the host program and compressed device images
28-
// RUN: %{run-aux} %clangxx -fsycl %t_main.o %t_kernel1_aot.o %t_kernel2_aot.o %t_compressed_image.o -o %t_compress.out
31+
// RUN: %{run-aux} %clangxx --no-offload-new-driver -fsycl %t_main.o %t_kernel1_aot.o %t_kernel2_aot.o %t_compressed_image.o -o %t_compress.out
2932

3033
// RUN: %{run} %t_compress.out
3134

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// End-to-End test for testing device image compression when we
2+
// separately compile and link device images.
3+
// This test is copied from Compression/compression_separate_compile.cpp
4+
// and modified to test with the New Offloading Model.
5+
6+
// REQUIRES: zstd, opencl-aot, cpu, linux
7+
8+
// XFAIL: target-native_cpu
9+
// XFAIL-TRACKER: https://github.com/intel/llvm/issues/20397
10+
11+
// CPU AOT targets host isa, so we compile everything on the run system instead.
12+
////////////////////// Compile device images
13+
// RUN: %{run-aux} %clangxx --offload-new-driver -fsycl -fsycl-targets=spir64_x86_64 -fsycl-host-compiler=clang++ -fsycl-host-compiler-options='-std=c++17 -Wno-attributes -Wno-deprecated-declarations -fPIC -DENABLE_KERNEL1' -DENABLE_KERNEL1 -c %s -o %t_kernel1_aot.o
14+
// RUN: %{run-aux} %clangxx --offload-new-driver -fsycl -fsycl-targets=spir64_x86_64 -fsycl-host-compiler=clang++ -fsycl-host-compiler-options='-std=c++17 -Wno-attributes -Wno-deprecated-declarations -fPIC -DENABLE_KERNEL2' -DENABLE_KERNEL2 -c %s -o %t_kernel2_aot.o
15+
16+
////////////////////// Link device images
17+
// RUN: %{run-aux} %clangxx --offload-new-driver --offload-compress -fsycl -fsycl-link -fsycl-targets=spir64_x86_64 -fPIC %t_kernel1_aot.o %t_kernel2_aot.o -o %t_compressed_image.o -v
18+
19+
// Make sure the clang-linker-wrapper is called with the --compress
20+
// option when using the new offloading model.
21+
// RUN: %{run-aux} %clangxx --offload-new-driver --offload-compress -fsycl -fsycl-link -fsycl-targets=spir64_x86_64 -fPIC %t_kernel1_aot.o %t_kernel2_aot.o -o %t_compressed_image.o -### &> %t_driver_opts.txt
22+
// RUN: %{run-aux} FileCheck -input-file=%t_driver_opts.txt %s --check-prefix=CHECK-DRIVER-OPTS
23+
24+
// CHECK-DRIVER-OPTS: clang-linker-wrapper{{.*}} "--compress"
25+
26+
////////////////////// Compile the host program
27+
// RUN: %{run-aux} %clangxx --offload-new-driver -fsycl -std=c++17 -Wno-attributes -Wno-deprecated-declarations -fPIC -c %s -o %t_main.o
28+
29+
////////////////////// Link the host program and compressed device images
30+
// RUN: %{run-aux} %clangxx --offload-new-driver -fsycl %t_main.o %t_kernel1_aot.o %t_kernel2_aot.o %t_compressed_image.o -o %t_compress.out
31+
32+
// RUN: %{run} %t_compress.out
33+
34+
#include <sycl/detail/core.hpp>
35+
36+
using namespace sycl;
37+
38+
// Kernel 1
39+
#ifdef ENABLE_KERNEL1
40+
class test_kernel1;
41+
void run_kernel1(int *a, queue q) {
42+
q.single_task<test_kernel1>([=]() { *a *= 3; }).wait();
43+
}
44+
#endif
45+
46+
// Kernel 2
47+
#ifdef ENABLE_KERNEL2
48+
class test_kernel2;
49+
void run_kernel2(int *a, queue q) {
50+
q.single_task<test_kernel2>([=]() { *a += 42; }).wait();
51+
}
52+
#endif
53+
54+
// Main application.
55+
#if not defined(ENABLE_KERNEL1) && not defined(ENABLE_KERNEL2)
56+
#include <sycl/properties/all_properties.hpp>
57+
#include <sycl/usm.hpp>
58+
59+
#include <iostream>
60+
61+
class kernel_init;
62+
void run_kernel1(int *a, queue q);
63+
void run_kernel2(int *a, queue q);
64+
int main() {
65+
int retCode = 0;
66+
queue q;
67+
68+
if (!q.get_device().get_info<info::device::usm_shared_allocations>())
69+
return 0;
70+
71+
int *p = malloc_shared<int>(1, q);
72+
*p = 42;
73+
74+
run_kernel1(p, q);
75+
run_kernel2(p, q);
76+
q.wait();
77+
78+
retCode = *p != (42 * 3 + 42);
79+
80+
free(p, q);
81+
return retCode;
82+
}
83+
#endif

0 commit comments

Comments
 (0)