From b417ca4cb67ddff089d779060a2e1ea59e411d2d Mon Sep 17 00:00:00 2001 From: Jakub Chlanda Date: Fri, 26 Jul 2024 14:19:30 +0100 Subject: [PATCH 1/2] [SYCL] Enable JIT tests relying on debug output Wrap the tests in `REQUIRE: asserts` in order to make sure that the compiler can generate the messages. --- sycl-fusion/test/materializer/debug_output.ll | 6 ++++-- sycl/test-e2e/AmdNvidiaJIT/kernel_and_bundle.cpp | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/sycl-fusion/test/materializer/debug_output.ll b/sycl-fusion/test/materializer/debug_output.ll index b9d0250118f1c..5f6dc214e303c 100644 --- a/sycl-fusion/test/materializer/debug_output.ll +++ b/sycl-fusion/test/materializer/debug_output.ll @@ -1,5 +1,7 @@ -; https://github.com/intel/llvm/issues/14783 -; REQUIRES: TEMPORARY_DISABLED +; This test relies on debug output from a pass, make sure that the compiler can +; generate it. +; REQUIRES: asserts + ; RUN: %if hip_amd %{ env SYCL_JIT_COMPILER_DEBUG="sycl-spec-const-materializer" opt\ ; RUN: -load-pass-plugin %shlibdir/SYCLKernelFusion%shlibext --mtriple amdgcn-amd-amdhsa\ ; RUN: -passes=sycl-spec-const-materializer,sccp -S %s 2> %t.stderr\ diff --git a/sycl/test-e2e/AmdNvidiaJIT/kernel_and_bundle.cpp b/sycl/test-e2e/AmdNvidiaJIT/kernel_and_bundle.cpp index 21eccd983c7cb..411b846b01ed0 100644 --- a/sycl/test-e2e/AmdNvidiaJIT/kernel_and_bundle.cpp +++ b/sycl/test-e2e/AmdNvidiaJIT/kernel_and_bundle.cpp @@ -1,8 +1,18 @@ +// UNSUPPORTED: windows // REQUIRES: cuda || hip +// This test relies on debug output from a pass, make sure that the compiler +// can generate it. +// REQUIRES: asserts + // RUN: %{build} -fsycl-embed-ir -o %t.out // RUN: env SYCL_JIT_AMDGCN_PTX_KERNELS=1 env SYCL_JIT_COMPILER_DEBUG="sycl-spec-const-materializer" %{run} %t.out &> %t.txt ; FileCheck %s --input-file %t.txt +// Test the JIT compilation in an e2e fashion, the only way to make sure that +// the JIT pipeline has been executed and that the original binary has been +// replaced with the JIT-ed one is to inspect the output of one of its passes, +// that otherwise does not get run. + #include #include From d9528fe34cb89a168f2242c83526fadaf9866565 Mon Sep 17 00:00:00 2001 From: Jakub Chlanda Date: Tue, 30 Jul 2024 13:20:03 +0100 Subject: [PATCH 2/2] Introuduce has_ndebug --- sycl-fusion/test/materializer/debug_output.ll | 62 ------------------- .../AmdNvidiaJIT/kernel_and_bundle.cpp | 2 +- sycl/test-e2e/lit.cfg.py | 13 ++++ 3 files changed, 14 insertions(+), 63 deletions(-) delete mode 100644 sycl-fusion/test/materializer/debug_output.ll diff --git a/sycl-fusion/test/materializer/debug_output.ll b/sycl-fusion/test/materializer/debug_output.ll deleted file mode 100644 index 5f6dc214e303c..0000000000000 --- a/sycl-fusion/test/materializer/debug_output.ll +++ /dev/null @@ -1,62 +0,0 @@ -; This test relies on debug output from a pass, make sure that the compiler can -; generate it. -; REQUIRES: asserts - -; RUN: %if hip_amd %{ env SYCL_JIT_COMPILER_DEBUG="sycl-spec-const-materializer" opt\ -; RUN: -load-pass-plugin %shlibdir/SYCLKernelFusion%shlibext --mtriple amdgcn-amd-amdhsa\ -; RUN: -passes=sycl-spec-const-materializer,sccp -S %s 2> %t.stderr\ -; RUN: | FileCheck %s %} -; RUN: %if hip_amd %{ FileCheck --input-file=%t.stderr --check-prefix=CHECK-DEBUG %s %} - -; RUN: %if cuda %{ env SYCL_JIT_COMPILER_DEBUG="sycl-spec-const-materializer" opt\ -; RUN: -load-pass-plugin %shlibdir/SYCLKernelFusion%shlibext\ -; RUN: --mtriple nvptx64-nvidia-cuda -passes=sycl-spec-const-materializer,sccp -S %s 2> %t.stderr\ -; RUN: | FileCheck %s %} -; RUN: %if hip_amd %{ FileCheck --input-file=%t.stderr --check-prefix=CHECK-DEBUG %s %} - -source_filename = "debug_output.ll" -target datalayout = "e-i64:64-i128:128-v16:16-v32:32-n16:32:64" - -; This is a derivative of basic.ll, which checks for the debug output of -; specialization constant materializer pass. - -;CHECK-DEBUG: Working on function: -;CHECK-DEBUG-NEXT: ================== -;CHECK-DEBUG-NEXT: __test_kernel -;CHECK-DEBUG: Replaced: 2 loads from spec const buffer. -;CHECK-DEBUG-NEXT: Load to global variable mappings: -;CHECK-DEBUG-NEXT: Load: -;CHECK-DEBUG-NEXT: %load1 = load i32, ptr %bc, align 4 -;CHECK-DEBUG-NEXT: Global Variable: -;CHECK-DEBUG-NEXT: @SpecConsBlob___test_kernel_0 = weak_odr addrspace(4) constant i32 7 -;CHECK-DEBUG: Load: -;CHECK-DEBUG-NEXT: %load2 = load [2 x i32], ptr %bc2, align 4 -;CHECK-DEBUG-NEXT: Global Variable: -;CHECK-DEBUG-NEXT: @SpecConsBlob___test_kernel_1 = weak_odr addrspace(4) constant [2 x i32] [i32 3, i32 1] - -;CHECK: @SpecConsBlob___test_kernel_0 = weak_odr addrspace(4) constant i32 7 -;CHECK: @SpecConsBlob___test_kernel_1 = weak_odr addrspace(4) constant [2 x i32] [i32 3, i32 1] - -;CHECK: __test_kernel -define weak_odr protected amdgpu_kernel void @__test_kernel(ptr addrspace(1) noundef align 4 %out, ptr addrspace(1) noundef align 1 %_arg__specialization_constants_buffer) { -entry: - %0 = addrspacecast ptr addrspace(1) %_arg__specialization_constants_buffer to ptr - %gep = getelementptr i8, ptr %0, i32 0 - %bc = bitcast ptr %gep to ptr - %load1 = load i32, ptr %bc, align 4 - %gep1 = getelementptr i8, ptr %0, i32 4 - %bc2 = bitcast ptr %gep1 to ptr - %load2 = load [2 x i32], ptr %bc2, align 4 - ;CHECK: extractvalue [2 x i32] [i32 3, i32 1], 0 - ;CHECK: extractvalue [2 x i32] [i32 3, i32 1], 1 - ;CHECK: add nsw i32 %extract1, 7 - %extract1 = extractvalue [2 x i32] %load2, 0 - %extract2 = extractvalue [2 x i32] %load2, 1 - %add1 = add nsw i32 %extract1, %load1 - %add2 = add nsw i32 %add1, %extract2 - store i32 %add2, ptr addrspace(1) %out, align 4 - ret void -} - -!SYCL_SpecConst_data = !{!1} -!1 = !{!"\07\00\00\00\03\00\00\00\01\00\00\00"} diff --git a/sycl/test-e2e/AmdNvidiaJIT/kernel_and_bundle.cpp b/sycl/test-e2e/AmdNvidiaJIT/kernel_and_bundle.cpp index 411b846b01ed0..bea29d5c89a80 100644 --- a/sycl/test-e2e/AmdNvidiaJIT/kernel_and_bundle.cpp +++ b/sycl/test-e2e/AmdNvidiaJIT/kernel_and_bundle.cpp @@ -3,7 +3,7 @@ // This test relies on debug output from a pass, make sure that the compiler // can generate it. -// REQUIRES: asserts +// REQUIRES: has_ndebug // RUN: %{build} -fsycl-embed-ir -o %t.out // RUN: env SYCL_JIT_AMDGCN_PTX_KERNELS=1 env SYCL_JIT_COMPILER_DEBUG="sycl-spec-const-materializer" %{run} %t.out &> %t.txt ; FileCheck %s --input-file %t.txt diff --git a/sycl/test-e2e/lit.cfg.py b/sycl/test-e2e/lit.cfg.py index 5cbad03666f76..927866eb178ae 100644 --- a/sycl/test-e2e/lit.cfg.py +++ b/sycl/test-e2e/lit.cfg.py @@ -210,6 +210,7 @@ def check_igc_tag_and_add_feature(): def open_check_file(file_name): return open(os.path.join(config.sycl_obj_root, file_name), "w") + # check if compiler supports CL command line options cl_options = False sp = subprocess.getstatusoutput(config.dpcpp_compiler + " /help") @@ -217,6 +218,18 @@ def open_check_file(file_name): cl_options = True config.available_features.add("cl_options") +# check if the compiler was built in NDEBUG configuration +has_ndebug = False +ps = subprocess.Popen( + [config.dpcpp_compiler, "-mllvm", "-debug", "-x", "c", "-", "-S", "-o", "-"], + stdin=subprocess.PIPE, + stdout=subprocess.DEVNULL, + stderr=subprocess.PIPE, +) +_ = ps.communicate(input=b"int main(){}\n") +if ps.wait() == 0: + config.available_features.add("has_ndebug") + # Check for Level Zero SDK check_l0_file = "l0_include.cpp" with open_check_file(check_l0_file) as fp: