From 3a2ea2a959e5c868d5a8622a799399ee10059002 Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Mon, 13 Jan 2025 15:02:47 -0800 Subject: [PATCH 1/2] [SYCL][E2E] Introduce `%{sycl_target_opts}` substitution ...and use it to pass `amd_arch` options to compilation only when compiling for AMD triples instead of unconditional usage in `%clangxx` substitution. That would avoid passing the option unnecessary when running `llvm-lit` with multiple target devices and a given test isn't supported for HIP. We might not have such configuration presently, but the same logic will be applied for "split" build/run of E2E tests and we'd definitely want to build tests for all the possible targets at once. Another use case for it is the "spirv backend" testing where we'd want to pass extra option for any compilations targeting spirv triple. --- .../Assert/assert_in_kernels_ndebug.cpp | 2 +- .../assert_in_multiple_tus_one_ndebug.cpp | 2 +- .../assert_in_multiple_tus_one_ndebug_win.cpp | 2 +- .../Assert/assert_in_one_kernel_ndebug.cpp | 2 +- ...simultaneously_multiple_tus_one_ndebug.cpp | 2 +- sycl/test-e2e/BFloat16/bfloat16_builtins.cpp | 4 ++-- .../bfloat16_builtins_cuda_generic.cpp | 2 +- sycl/test-e2e/Basic/multisource.cpp | 4 ++-- sycl/test-e2e/Basic/multisource_spv_obj.cpp | 6 +++--- .../DeviceImageDependencies/dynamic.cpp | 2 +- .../DeviceImageDependencies/objects.cpp | 2 +- .../test-e2e/NewOffloadDriver/multisource.cpp | 8 ++++---- .../sycl-external-with-optional-features.cpp | 2 +- .../OneapiDeviceSelector/illegal_input.cpp | 2 +- .../sycl-external-with-optional-features.cpp | 2 +- sycl/test-e2e/README.md | 2 +- .../Regression/DAE-separate-compile.cpp | 2 +- sycl/test-e2e/Regression/commandlist/gpu.cpp | 2 +- sycl/test-e2e/SeparateCompile/same-kernel.cpp | 2 +- .../sycl-external-within-staticlib.cpp | 4 ++-- .../SeparateCompile/sycl-external.cpp | 4 ++-- sycl/test-e2e/format.py | 20 +++++++++++++------ sycl/test-e2e/lit.cfg.py | 10 +--------- .../test-e2e/syclcompat/kernel/kernel_lin.cpp | 4 ++-- .../test-e2e/syclcompat/kernel/kernel_win.cpp | 4 ++-- 25 files changed, 49 insertions(+), 49 deletions(-) diff --git a/sycl/test-e2e/Assert/assert_in_kernels_ndebug.cpp b/sycl/test-e2e/Assert/assert_in_kernels_ndebug.cpp index 4ca45de3d54f3..7c02b92f0aad9 100644 --- a/sycl/test-e2e/Assert/assert_in_kernels_ndebug.cpp +++ b/sycl/test-e2e/Assert/assert_in_kernels_ndebug.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} -DNDEBUG %S/assert_in_kernels.cpp -o %t.out +// RUN: %clangxx -fsycl %{sycl_target_opts} -DNDEBUG %S/assert_in_kernels.cpp -o %t.out // RUN: %{run} %t.out | FileCheck %s // // CHECK-NOT: One shouldn't see this message diff --git a/sycl/test-e2e/Assert/assert_in_multiple_tus_one_ndebug.cpp b/sycl/test-e2e/Assert/assert_in_multiple_tus_one_ndebug.cpp index 8ffea706d4f58..3b66660b8c2b5 100644 --- a/sycl/test-e2e/Assert/assert_in_multiple_tus_one_ndebug.cpp +++ b/sycl/test-e2e/Assert/assert_in_multiple_tus_one_ndebug.cpp @@ -9,7 +9,7 @@ // XFAIL: (opencl && gpu) // XFAIL-TRACKER: https://github.com/intel/llvm/issues/11364 -// RUN: %clangxx -DSYCL_FALLBACK_ASSERT=1 -fsycl -fsycl-targets=%{sycl_triple} -DDEFINE_NDEBUG_INFILE2 -I %S/Inputs %S/assert_in_multiple_tus.cpp %S/Inputs/kernels_in_file2.cpp -o %t.out +// RUN: %clangxx -DSYCL_FALLBACK_ASSERT=1 -fsycl %{sycl_target_opts} -DDEFINE_NDEBUG_INFILE2 -I %S/Inputs %S/assert_in_multiple_tus.cpp %S/Inputs/kernels_in_file2.cpp -o %t.out // Shouldn't fail on ACC as fallback assert isn't enqueued there // RUN: %{run} %t.out &> %t.txt ; FileCheck %s --input-file %t.txt %if fpga %{ --check-prefix=CHECK-ACC %} // diff --git a/sycl/test-e2e/Assert/assert_in_multiple_tus_one_ndebug_win.cpp b/sycl/test-e2e/Assert/assert_in_multiple_tus_one_ndebug_win.cpp index 2cbc05540fa69..9e02e01681190 100644 --- a/sycl/test-e2e/Assert/assert_in_multiple_tus_one_ndebug_win.cpp +++ b/sycl/test-e2e/Assert/assert_in_multiple_tus_one_ndebug_win.cpp @@ -1,5 +1,5 @@ // REQUIRES: windows -// RUN: %clangxx -DSYCL_FALLBACK_ASSERT=1 -fsycl -fsycl-targets=%{sycl_triple} -DDEFINE_NDEBUG_INFILE2 -I %S/Inputs %S/assert_in_multiple_tus.cpp %S/Inputs/kernels_in_file2.cpp -o %t.out +// RUN: %clangxx -DSYCL_FALLBACK_ASSERT=1 -fsycl %{sycl_target_opts} -DDEFINE_NDEBUG_INFILE2 -I %S/Inputs %S/assert_in_multiple_tus.cpp %S/Inputs/kernels_in_file2.cpp -o %t.out // Shouldn't fail on ACC as fallback assert isn't enqueued there // RUN: %{run} %t.out &> %t.txt ; FileCheck %s --input-file %t.txt %if fpga %{ --check-prefix=CHECK-ACC %} // diff --git a/sycl/test-e2e/Assert/assert_in_one_kernel_ndebug.cpp b/sycl/test-e2e/Assert/assert_in_one_kernel_ndebug.cpp index 1f68c39e08438..0180ec3752ec6 100644 --- a/sycl/test-e2e/Assert/assert_in_one_kernel_ndebug.cpp +++ b/sycl/test-e2e/Assert/assert_in_one_kernel_ndebug.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} -DNDEBUG %S/assert_in_one_kernel.cpp -o %t.out +// RUN: %clangxx -fsycl %{sycl_target_opts} -DNDEBUG %S/assert_in_one_kernel.cpp -o %t.out // RUN: %{run} %t.out | FileCheck %s // // CHECK-NOT: from assert statement diff --git a/sycl/test-e2e/Assert/assert_in_simultaneously_multiple_tus_one_ndebug.cpp b/sycl/test-e2e/Assert/assert_in_simultaneously_multiple_tus_one_ndebug.cpp index 731187fe4cdf7..e7f419cedf7e7 100644 --- a/sycl/test-e2e/Assert/assert_in_simultaneously_multiple_tus_one_ndebug.cpp +++ b/sycl/test-e2e/Assert/assert_in_simultaneously_multiple_tus_one_ndebug.cpp @@ -5,7 +5,7 @@ // XFAIL: (opencl && gpu) // XFAIL-TRACKER: https://github.com/intel/llvm/issues/11364 // -// RUN: %clangxx -DSYCL_FALLBACK_ASSERT=1 -fsycl -fsycl-targets=%{sycl_triple} -DDEFINE_NDEBUG_INFILE2 -I %S/Inputs %S/assert_in_simultaneously_multiple_tus.cpp %S/Inputs/kernels_in_file2.cpp -o %t.out %threads_lib +// RUN: %clangxx -DSYCL_FALLBACK_ASSERT=1 -fsycl %{sycl_target_opts} -DDEFINE_NDEBUG_INFILE2 -I %S/Inputs %S/assert_in_simultaneously_multiple_tus.cpp %S/Inputs/kernels_in_file2.cpp -o %t.out %threads_lib // RUN: %if cpu %{ %{run} %t.out &> %t.cpu.txt ; FileCheck %s --input-file %t.cpu.txt %} // // Since this is a multi-threaded application enable memory tracking and diff --git a/sycl/test-e2e/BFloat16/bfloat16_builtins.cpp b/sycl/test-e2e/BFloat16/bfloat16_builtins.cpp index 9c69e0cd7bf71..7d58e048519f4 100644 --- a/sycl/test-e2e/BFloat16/bfloat16_builtins.cpp +++ b/sycl/test-e2e/BFloat16/bfloat16_builtins.cpp @@ -5,11 +5,11 @@ // + below sm_80 always uses generic impls // DEFINE: %{mathflags} = %if cl_options %{/clang:-fno-fast-math%} %else %{-fno-fast-math%} -// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %if any-device-is-cuda %{ -Xsycl-target-backend=nvptx64-nvidia-cuda --cuda-gpu-arch=sm_80 %} %s -o %t.out %{mathflags} +// RUN: %clangxx -fsycl %{sycl_target_opts} %if any-device-is-cuda %{ -Xsycl-target-backend=nvptx64-nvidia-cuda --cuda-gpu-arch=sm_80 %} %s -o %t.out %{mathflags} // RUN: %{run} %t.out // Test "new" (ABI breaking) for all platforms ( sm_80/native if CUDA ) -// RUN: %if preview-breaking-changes-supported %{ %clangxx -fsycl -fpreview-breaking-changes -fsycl-targets=%{sycl_triple} %if any-device-is-cuda %{ -Xsycl-target-backend=nvptx64-nvidia-cuda --cuda-gpu-arch=sm_80 %} %s -o %t2.out %{mathflags} %} +// RUN: %if preview-breaking-changes-supported %{ %clangxx -fsycl -fpreview-breaking-changes %{sycl_target_opts} %if any-device-is-cuda %{ -Xsycl-target-backend=nvptx64-nvidia-cuda --cuda-gpu-arch=sm_80 %} %s -o %t2.out %{mathflags} %} // RUN: %if preview-breaking-changes-supported %{ %{run} %t2.out %} #include "bfloat16_builtins.hpp" diff --git a/sycl/test-e2e/BFloat16/bfloat16_builtins_cuda_generic.cpp b/sycl/test-e2e/BFloat16/bfloat16_builtins_cuda_generic.cpp index 6db30932609f5..719bf4709ae4c 100644 --- a/sycl/test-e2e/BFloat16/bfloat16_builtins_cuda_generic.cpp +++ b/sycl/test-e2e/BFloat16/bfloat16_builtins_cuda_generic.cpp @@ -7,7 +7,7 @@ // DEFINE: %{mathflags} = %if cl_options %{/clang:-fno-fast-math%} %else %{-fno-fast-math%} // If CUDA, test "new" again for sm_75/generic -// RUN: %if any-device-is-cuda %{ %if preview-breaking-changes-supported %{ %clangxx -fsycl -fpreview-breaking-changes -fsycl-targets=%{sycl_triple} -Xsycl-target-backend=nvptx64-nvidia-cuda --cuda-gpu-arch=sm_75 %s -o %t3.out %{mathflags} %} %} +// RUN: %if any-device-is-cuda %{ %if preview-breaking-changes-supported %{ %clangxx -fsycl -fpreview-breaking-changes %{sycl_target_opts} -Xsycl-target-backend=nvptx64-nvidia-cuda --cuda-gpu-arch=sm_75 %s -o %t3.out %{mathflags} %} %} // RUN: %if any-device-is-cuda %{ %if preview-breaking-changes-supported %{ %{run} %t3.out %} %} #include "bfloat16_builtins.hpp" diff --git a/sycl/test-e2e/Basic/multisource.cpp b/sycl/test-e2e/Basic/multisource.cpp index 23c95ce2eddd3..db7b4dbf39e74 100644 --- a/sycl/test-e2e/Basic/multisource.cpp +++ b/sycl/test-e2e/Basic/multisource.cpp @@ -9,14 +9,14 @@ // Separate kernel sources and host code sources // RUN: %{build} -c -o %t.kernel.o -DINIT_KERNEL -DCALC_KERNEL // RUN: %{build} -c -o %t.main.o -DMAIN_APP -// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %t.kernel.o %t.main.o -Wno-unused-command-line-argument -o %t1.fat +// RUN: %clangxx -fsycl %{sycl_target_opts} %t.kernel.o %t.main.o -Wno-unused-command-line-argument -o %t1.fat // RUN: %{run} %t1.fat // Multiple sources with kernel code // RUN: %{build} -c -o %t.init.o -DINIT_KERNEL // RUN: %{build} -c -o %t.calc.o -DCALC_KERNEL // RUN: %{build} -c -o %t.main.o -DMAIN_APP -// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %t.init.o %t.calc.o %t.main.o -Wno-unused-command-line-argument -o %t2.fat +// RUN: %clangxx -fsycl %{sycl_target_opts} %t.init.o %t.calc.o %t.main.o -Wno-unused-command-line-argument -o %t2.fat // RUN: %{run} %t2.fat #include diff --git a/sycl/test-e2e/Basic/multisource_spv_obj.cpp b/sycl/test-e2e/Basic/multisource_spv_obj.cpp index 0f097ce3cd5db..25ff92eda2c77 100644 --- a/sycl/test-e2e/Basic/multisource_spv_obj.cpp +++ b/sycl/test-e2e/Basic/multisource_spv_obj.cpp @@ -11,21 +11,21 @@ // Separate kernel sources and host code sources // RUN: %{build} -fsycl-device-obj=spirv -c -o %t.kernel.o -DINIT_KERNEL -DCALC_KERNEL // RUN: %{build} -fsycl-device-obj=spirv -c -o %t.main.o -DMAIN_APP -// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %t.kernel.o %t.main.o -Wno-unused-command-line-argument -o %t1.fat +// RUN: %clangxx -fsycl %{sycl_target_opts} %t.kernel.o %t.main.o -Wno-unused-command-line-argument -o %t1.fat // RUN: %{run} %t1.fat // Multiple sources with kernel code // RUN: %{build} -fsycl-device-obj=spirv -c -o %t.init.o -DINIT_KERNEL // RUN: %{build} -fsycl-device-obj=spirv -c -o %t.calc.o -DCALC_KERNEL // RUN: %{build} -fsycl-device-obj=spirv -c -o %t.main.o -DMAIN_APP -// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %t.init.o %t.calc.o %t.main.o -Wno-unused-command-line-argument -o %t2.fat +// RUN: %clangxx -fsycl %{sycl_target_opts} %t.init.o %t.calc.o %t.main.o -Wno-unused-command-line-argument -o %t2.fat // RUN: %{run} %t2.fat // Multiple sources with kernel code, mixed SPIR-V and LLVM-IR objects // RUN: %{build} -fsycl-device-obj=spirv -c -o %t.init.o -DINIT_KERNEL // RUN: %{build} -fsycl-device-obj=llvmir -c -o %t.calc.o -DCALC_KERNEL // RUN: %{build} -c -o %t.main.o -DMAIN_APP -// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %t.init.o %t.calc.o %t.main.o -Wno-unused-command-line-argument -o %t3.fat +// RUN: %clangxx -fsycl %{sycl_target_opts} %t.init.o %t.calc.o %t.main.o -Wno-unused-command-line-argument -o %t3.fat // RUN: %{run} %t3.fat #include diff --git a/sycl/test-e2e/DeviceImageDependencies/dynamic.cpp b/sycl/test-e2e/DeviceImageDependencies/dynamic.cpp index 5952e4e418935..1bdaf3b1d6270 100644 --- a/sycl/test-e2e/DeviceImageDependencies/dynamic.cpp +++ b/sycl/test-e2e/DeviceImageDependencies/dynamic.cpp @@ -10,7 +10,7 @@ // RUN: %clangxx %{dynamic_lib_options} %S/Inputs/b.cpp %if windows %{%T/libdevice_c.lib%} -o %T/libdevice_b.%{dynamic_lib_suffix} // RUN: %clangxx %{dynamic_lib_options} %S/Inputs/a.cpp %if windows %{%T/libdevice_b.lib%} -o %T/libdevice_a.%{dynamic_lib_suffix} -// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} -fsycl-allow-device-image-dependencies -fsycl-device-code-split=per_kernel %S/Inputs/basic.cpp -o %t.out \ +// RUN: %clangxx -fsycl %{sycl_target_opts} -fsycl-allow-device-image-dependencies -fsycl-device-code-split=per_kernel %S/Inputs/basic.cpp -o %t.out \ // RUN: %if windows \ // RUN: %{%T/libdevice_a.lib%} \ // RUN: %else \ diff --git a/sycl/test-e2e/DeviceImageDependencies/objects.cpp b/sycl/test-e2e/DeviceImageDependencies/objects.cpp index 17409b209781c..eea085dc9b905 100644 --- a/sycl/test-e2e/DeviceImageDependencies/objects.cpp +++ b/sycl/test-e2e/DeviceImageDependencies/objects.cpp @@ -6,5 +6,5 @@ // RUN: %clangxx -fsycl %S/Inputs/b.cpp -I %S/Inputs -c -o %t_b.o // RUN: %clangxx -fsycl %S/Inputs/c.cpp -I %S/Inputs -c -o %t_c.o // RUN: %clangxx -fsycl %S/Inputs/d.cpp -I %S/Inputs -c -o %t_d.o -// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} -fsycl-device-code-split=per_kernel -fsycl-allow-device-image-dependencies %t_a.o %t_b.o %t_c.o %t_d.o %S/Inputs/basic.cpp -o %t.out +// RUN: %clangxx -fsycl %{sycl_target_opts} -fsycl-device-code-split=per_kernel -fsycl-allow-device-image-dependencies %t_a.o %t_b.o %t_c.o %t_d.o %S/Inputs/basic.cpp -o %t.out // RUN: %{run} %t.out diff --git a/sycl/test-e2e/NewOffloadDriver/multisource.cpp b/sycl/test-e2e/NewOffloadDriver/multisource.cpp index cf9f518c89995..0612b54bfc23b 100644 --- a/sycl/test-e2e/NewOffloadDriver/multisource.cpp +++ b/sycl/test-e2e/NewOffloadDriver/multisource.cpp @@ -11,7 +11,7 @@ // Test with `--offload-new-driver` // RUN: %{build} --offload-new-driver -c -o %t.kernel.o -DINIT_KERNEL -DCALC_KERNEL // RUN: %{build} --offload-new-driver -c -o %t.main.o -DMAIN_APP -// RUN: %clangxx -Wno-error=unused-command-line-argument -fsycl -fsycl-targets=%{sycl_triple} --offload-new-driver %t.kernel.o %t.main.o -o %t1.fat +// RUN: %clangxx -Wno-error=unused-command-line-argument -fsycl %{sycl_target_opts} --offload-new-driver %t.kernel.o %t.main.o -o %t1.fat // RUN: %{run} %t1.fat // Multiple sources with kernel code @@ -19,7 +19,7 @@ // RUN: %{build} --offload-new-driver -c -o %t.init.o -DINIT_KERNEL // RUN: %{build} --offload-new-driver -c -o %t.calc.o -DCALC_KERNEL // RUN: %{build} --offload-new-driver -c -o %t.main.o -DMAIN_APP -// RUN: %clangxx -Wno-error=unused-command-line-argument -fsycl -fsycl-targets=%{sycl_triple} --offload-new-driver %t.init.o %t.calc.o %t.main.o -o %t2.fat +// RUN: %clangxx -Wno-error=unused-command-line-argument -fsycl %{sycl_target_opts} --offload-new-driver %t.init.o %t.calc.o %t.main.o -o %t2.fat // RUN: %{run} %t2.fat // Multiple sources with kernel code with old-style objects @@ -27,7 +27,7 @@ // RUN: %{build} --no-offload-new-driver -c -o %t.init.o -DINIT_KERNEL // RUN: %{build} --no-offload-new-driver -c -o %t.calc.o -DCALC_KERNEL // RUN: %{build} --no-offload-new-driver -c -o %t.main.o -DMAIN_APP -// RUN: %clangxx -Wno-error=unused-command-line-argument -fsycl -fsycl-targets=%{sycl_triple} --offload-new-driver %t.init.o %t.calc.o %t.main.o -o %t3.fat +// RUN: %clangxx -Wno-error=unused-command-line-argument -fsycl %{sycl_target_opts} --offload-new-driver %t.init.o %t.calc.o %t.main.o -o %t3.fat // RUN: %{run} %t3.fat // Multiple sources with kernel code with old-style objects in a static archive @@ -36,7 +36,7 @@ // RUN: %{build} --no-offload-new-driver -c -o %t.calc.o -DCALC_KERNEL // RUN: %{build} --no-offload-new-driver -c -o %t.main.o -DMAIN_APP // RUN: llvm-ar r %t.a %t.init.o %t.calc.o -// RUN: %clangxx -Wno-error=unused-command-line-argument -fsycl -fsycl-targets=%{sycl_triple} --offload-new-driver %t.main.o %t.a -o %t4.fat +// RUN: %clangxx -Wno-error=unused-command-line-argument -fsycl %{sycl_target_opts} --offload-new-driver %t.main.o %t.a -o %t4.fat // RUN: %{run} %t4.fat #include diff --git a/sycl/test-e2e/NewOffloadDriver/sycl-external-with-optional-features.cpp b/sycl/test-e2e/NewOffloadDriver/sycl-external-with-optional-features.cpp index 144466f673bba..b2659744d0338 100644 --- a/sycl/test-e2e/NewOffloadDriver/sycl-external-with-optional-features.cpp +++ b/sycl/test-e2e/NewOffloadDriver/sycl-external-with-optional-features.cpp @@ -1,7 +1,7 @@ // Test with `--offload-new-driver` // RUN: %{build} -DSOURCE1 --offload-new-driver -c -o %t1.o // RUN: %{build} -DSOURCE2 --offload-new-driver -c -o %t2.o -// RUN: %clangxx -Wno-error=unused-command-line-argument -fsycl -fsycl-targets=%{sycl_triple} --offload-new-driver %t1.o %t2.o -o %t.exe +// RUN: %clangxx -Wno-error=unused-command-line-argument -fsycl %{sycl_target_opts} --offload-new-driver %t1.o %t2.o -o %t.exe // RUN: %{run} %t.exe // XFAIL: cuda // XFAIL-TRACKER: https://github.com/intel/llvm/issues/16413 diff --git a/sycl/test-e2e/OneapiDeviceSelector/illegal_input.cpp b/sycl/test-e2e/OneapiDeviceSelector/illegal_input.cpp index 35430c7b12ff6..c929e9261623d 100644 --- a/sycl/test-e2e/OneapiDeviceSelector/illegal_input.cpp +++ b/sycl/test-e2e/OneapiDeviceSelector/illegal_input.cpp @@ -1,5 +1,5 @@ -// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %S/Inputs/trivial.cpp -o %t.out +// RUN: %clangxx -fsycl %{sycl_target_opts} %S/Inputs/trivial.cpp -o %t.out // RUN: not --crash env ONEAPI_DEVICE_SELECTOR="macaroni:*" %{run-unfiltered-devices} %t.out // RUN: not --crash env ONEAPI_DEVICE_SELECTOR=":" %{run-unfiltered-devices} %t.out // RUN: not --crash env ONEAPI_DEVICE_SELECTOR="level_zero:." %{run-unfiltered-devices} %t.out diff --git a/sycl/test-e2e/OptionalKernelFeatures/sycl-external-with-optional-features.cpp b/sycl/test-e2e/OptionalKernelFeatures/sycl-external-with-optional-features.cpp index 5a04ea4ed55df..ec713c0ab2718 100644 --- a/sycl/test-e2e/OptionalKernelFeatures/sycl-external-with-optional-features.cpp +++ b/sycl/test-e2e/OptionalKernelFeatures/sycl-external-with-optional-features.cpp @@ -1,6 +1,6 @@ // RUN: %{build} -DSOURCE1 -c -o %t1.o // RUN: %{build} -DSOURCE2 -c -o %t2.o -// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %t1.o %t2.o -Wno-unused-command-line-argument -o %t.exe +// RUN: %clangxx -fsycl %{sycl_target_opts} %t1.o %t2.o -Wno-unused-command-line-argument -o %t.exe // RUN: %{run} %t.exe #ifdef SOURCE1 diff --git a/sycl/test-e2e/README.md b/sycl/test-e2e/README.md index f3b2ce0582335..5d19795212305 100644 --- a/sycl/test-e2e/README.md +++ b/sycl/test-e2e/README.md @@ -67,7 +67,7 @@ is substituted with just `[Optional run_launcher if that is configured]`. Another little nuance is `%{sycl_triple}` substitution. It is constructed by concatenating triples for all the devices from `sycl_devices` supported by a given test. After that there is also a convenient `%{build}` substitution that -is equivalent to `%clangxx -fsycl -fsycl-targets=%{sycl_triple} %s`. +is equivalent to `%clangxx -fsycl %{sycl_target_opts} %s`. ## Prerequisites diff --git a/sycl/test-e2e/Regression/DAE-separate-compile.cpp b/sycl/test-e2e/Regression/DAE-separate-compile.cpp index ab6712507f439..d787c288d64df 100644 --- a/sycl/test-e2e/Regression/DAE-separate-compile.cpp +++ b/sycl/test-e2e/Regression/DAE-separate-compile.cpp @@ -5,7 +5,7 @@ // The test checks that the scenario works correctly. // // RUN: %{build} -O2 -c -o %t.o -// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %t.o %O0 -Wno-unused-command-line-argument -o %t.out +// RUN: %clangxx -fsycl %{sycl_target_opts} %t.o %O0 -Wno-unused-command-line-argument -o %t.out // RUN: %{run} %t.out // Failing on HIP AMD, enable after fixed diff --git a/sycl/test-e2e/Regression/commandlist/gpu.cpp b/sycl/test-e2e/Regression/commandlist/gpu.cpp index 552f0f1109b1e..02db522a23943 100644 --- a/sycl/test-e2e/Regression/commandlist/gpu.cpp +++ b/sycl/test-e2e/Regression/commandlist/gpu.cpp @@ -1,4 +1,4 @@ // REQUIRES: gpu -// RUN: %clangxx -Wno-error=vla-cxx-extension -fsycl -fsycl-targets=%{sycl_triple} %S/Inputs/FindPrimesSYCL.cpp %S/Inputs/main.cpp -o %t.out %threads_lib +// RUN: %clangxx -Wno-error=vla-cxx-extension -fsycl %{sycl_target_opts} %S/Inputs/FindPrimesSYCL.cpp %S/Inputs/main.cpp -o %t.out %threads_lib // RUN: %{run} %t.out diff --git a/sycl/test-e2e/SeparateCompile/same-kernel.cpp b/sycl/test-e2e/SeparateCompile/same-kernel.cpp index 8bdadbe7ad62b..27b701a0b1550 100644 --- a/sycl/test-e2e/SeparateCompile/same-kernel.cpp +++ b/sycl/test-e2e/SeparateCompile/same-kernel.cpp @@ -12,7 +12,7 @@ // RUN: %{build} -DB_CPP=1 -c -o %t-same-kernel-b.o // // >> ---- link the full hetero app -// RUN: %clangxx %t-same-kernel-a.o %t-same-kernel-b.o -Wno-unused-command-line-argument -o %t-same-kernel.exe -fsycl -fsycl-targets=%{sycl_triple} +// RUN: %clangxx -fsycl %{sycl_target_opts} %t-same-kernel-a.o %t-same-kernel-b.o -Wno-unused-command-line-argument -o %t-same-kernel.exe // RUN: %{run} %t-same-kernel.exe #include diff --git a/sycl/test-e2e/SeparateCompile/sycl-external-within-staticlib.cpp b/sycl/test-e2e/SeparateCompile/sycl-external-within-staticlib.cpp index 219634f47646c..d62becf4d5567 100644 --- a/sycl/test-e2e/SeparateCompile/sycl-external-within-staticlib.cpp +++ b/sycl/test-e2e/SeparateCompile/sycl-external-within-staticlib.cpp @@ -5,7 +5,7 @@ // RUN: %{build} -O3 -DSOURCE3 -c -o %t3.o // RUN: rm -f %t.a // RUN: llvm-ar crv %t.a %t1.o %t2.o -// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} -O3 %t3.o %t.a -Wno-unused-command-line-argument -o %t1.exe +// RUN: %clangxx -fsycl %{sycl_target_opts} -O3 %t3.o %t.a -Wno-unused-command-line-argument -o %t1.exe // RUN: %{run} %t1.exe // Check the repacked case as it can behave differently. @@ -13,7 +13,7 @@ // RUN: echo addlib %t.a >> %t.txt // RUN: echo save >> %t.txt // RUN: cat %t.txt | llvm-ar -M -// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} -O3 %t3.o %t_repacked.a -Wno-unused-command-line-argument -o %t2.exe +// RUN: %clangxx -fsycl %{sycl_target_opts} -O3 %t3.o %t_repacked.a -Wno-unused-command-line-argument -o %t2.exe // RUN: %{run} %t2.exe #include diff --git a/sycl/test-e2e/SeparateCompile/sycl-external.cpp b/sycl/test-e2e/SeparateCompile/sycl-external.cpp index 37facb7ecfc57..85e2c97d6512a 100644 --- a/sycl/test-e2e/SeparateCompile/sycl-external.cpp +++ b/sycl/test-e2e/SeparateCompile/sycl-external.cpp @@ -2,14 +2,14 @@ // different object file. // RUN: %{build} -DSOURCE1 -c -o %t1.o // RUN: %{build} -DSOURCE2 -c -o %t2.o -// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %t1.o %t2.o -Wno-unused-command-line-argument -o %t1.exe +// RUN: %clangxx -fsycl %{sycl_target_opts} %t1.o %t2.o -Wno-unused-command-line-argument -o %t1.exe // RUN: %{run} %t1.exe // // Test2 - check that kernel can call a SYCL_EXTERNAL function defined in a // static library. // RUN: rm -f %t.a // RUN: llvm-ar crv %t.a %t1.o -// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %t2.o %t.a -Wno-unused-command-line-argument -o %t2.exe +// RUN: %clangxx -fsycl %{sycl_target_opts} %t2.o %t.a -Wno-unused-command-line-argument -o %t2.exe // RUN: %{run} %t2.exe #include diff --git a/sycl/test-e2e/format.py b/sycl/test-e2e/format.py index fc04da53e6730..be33d6237735d 100644 --- a/sycl/test-e2e/format.py +++ b/sycl/test-e2e/format.py @@ -13,7 +13,7 @@ import re -def get_triple(test, backend): +def get_triple(backend): if backend == "cuda": return "nvptx64-nvidia-cuda" if backend == "hip": @@ -168,17 +168,25 @@ def execute(self, test, litConfig): for sycl_device in devices_for_test: (backend, _) = sycl_device.split(":") - triples.add(get_triple(test, backend)) + triples.add(get_triple(backend)) substitutions = lit.TestRunner.getDefaultSubstitutions(test, tmpDir, tmpBase) + substitutions.append(("%{sycl_triple}", format(",".join(triples)))) - # -fsycl-targets is needed for CUDA/HIP, so just use it be default so - # -that new tests by default would runnable there (unless they have - # -other restrictions). + + sycl_target_opts = "-fsycl-targets=%{sycl_triple}" + if get_triple("hip") in triples: + sycl_target_opts += ( + " -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch={}".format( + test.config.amd_arch + ) + ) + substitutions.append(("%{sycl_target_opts}", sycl_target_opts)) + substitutions.append( ( "%{build}", - "%clangxx -fsycl -fsycl-targets=%{sycl_triple} %verbose_print %s", + "%clangxx -fsycl %{sycl_target_opts} %verbose_print %s", ) ) if platform.system() == "Windows": diff --git a/sycl/test-e2e/lit.cfg.py b/sycl/test-e2e/lit.cfg.py index 23a1ec5692afd..9ffb648c6bc7c 100644 --- a/sycl/test-e2e/lit.cfg.py +++ b/sycl/test-e2e/lit.cfg.py @@ -685,8 +685,6 @@ def open_check_file(file_name): # discovered already. config.sycl_dev_features = {} -# Architecture flag for compiling for AMD HIP devices. Empty otherwise. -arch_flag = "" # Version of the driver for a given device. Empty for non-Intel devices. config.intel_driver_ver = {} for sycl_device in config.sycl_devices: @@ -838,9 +836,6 @@ def open_check_file(file_name): ) config.amd_arch = arch.replace(amd_arch_prefix, "") llvm_config.with_system_environment("ROCM_PATH") - arch_flag = ( - "-Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=" + config.amd_arch - ) config.substitutions.append( ("%rocm_path", os.environ.get("ROCM_PATH", "/opt/rocm")) ) @@ -856,10 +851,7 @@ def open_check_file(file_name): config.substitutions.append(("%clang", " true ")) else: config.substitutions.append( - ( - "%clangxx", - " " + config.dpcpp_compiler + " " + config.cxx_flags + " " + arch_flag, - ) + ("%clangxx", " " + config.dpcpp_compiler + " " + config.cxx_flags) ) config.substitutions.append( ("%clang", " " + config.dpcpp_compiler + " " + config.c_flags) diff --git a/sycl/test-e2e/syclcompat/kernel/kernel_lin.cpp b/sycl/test-e2e/syclcompat/kernel/kernel_lin.cpp index eca55f738d83a..d93a7880d404e 100644 --- a/sycl/test-e2e/syclcompat/kernel/kernel_lin.cpp +++ b/sycl/test-e2e/syclcompat/kernel/kernel_lin.cpp @@ -2,6 +2,6 @@ // TODO: Supported for ROCM 5. Further development required to support AMDGPU. // UNSUPPORTED: hip -// RUN: %clangxx -fPIC -shared -fsycl -fsycl-targets=%{sycl_triple} %S/Inputs/kernel_module.cpp -o %t.so -// RUN: %clangxx -DTEST_SHARED_LIB='"%t.so"' -ldl -fsycl -fsycl-targets=%{sycl_triple} %S/Inputs/kernel_function.cpp -o %t.out +// RUN: %clangxx -fPIC -shared -fsycl %{sycl_target_opts} %S/Inputs/kernel_module.cpp -o %t.so +// RUN: %clangxx -DTEST_SHARED_LIB='"%t.so"' -ldl -fsycl %{sycl_target_opts} %S/Inputs/kernel_function.cpp -o %t.out // RUN: %{run} %t.out diff --git a/sycl/test-e2e/syclcompat/kernel/kernel_win.cpp b/sycl/test-e2e/syclcompat/kernel/kernel_win.cpp index 02ec26ab78a48..85ecf5687ca63 100644 --- a/sycl/test-e2e/syclcompat/kernel/kernel_win.cpp +++ b/sycl/test-e2e/syclcompat/kernel/kernel_win.cpp @@ -3,6 +3,6 @@ // DEFINE: %{sharedflag} = %if cl_options %{/clang:-shared%} %else %{-shared%} -// RUN: %clangxx %{sharedflag} -fsycl -fsycl-targets=%{sycl_triple} %S\Inputs\kernel_module.cpp -o %t.dll -// RUN: %clangxx -DTEST_SHARED_LIB='"%/t.dll"' -fsycl -fsycl-targets=%{sycl_triple} %S\Inputs\kernel_function.cpp -o %t.out +// RUN: %clangxx %{sharedflag} -fsycl %{sycl_target_opts} %S\Inputs\kernel_module.cpp -o %t.dll +// RUN: %clangxx -DTEST_SHARED_LIB='"%/t.dll"' -fsycl %{sycl_target_opts} %S\Inputs\kernel_function.cpp -o %t.out // RUN: %{run} %t.out From 4a7d057436672a8499a1fa588d407d1e38d04ad3 Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Tue, 14 Jan 2025 13:53:16 -0800 Subject: [PATCH 2/2] Try to fix failing test --- sycl/test-e2e/Regression/multiple-targets.cpp | 8 ++++---- sycl/test-e2e/format.py | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sycl/test-e2e/Regression/multiple-targets.cpp b/sycl/test-e2e/Regression/multiple-targets.cpp index a2498c3301b99..aa8c125d90738 100644 --- a/sycl/test-e2e/Regression/multiple-targets.cpp +++ b/sycl/test-e2e/Regression/multiple-targets.cpp @@ -4,16 +4,16 @@ // // REQUIRES: cuda || hip || native_cpu // REQUIRES: build-and-run-mode -// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple},spir64 -o %t1.out %s +// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple},spir64 %if any-device-is-hip %{ %{hip_arch_opts} %} -o %t1.out %s // RUN: %{run} %t1.out // -// RUN: %clangxx -fsycl -fsycl-targets=spir64,%{sycl_triple} -o %t2.out %s +// RUN: %clangxx -fsycl -fsycl-targets=spir64,%{sycl_triple} %if any-device-is-hip %{ %{hip_arch_opts} %} -o %t2.out %s // RUN: %{run} %t2.out // -// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple},spir64 -fsycl-device-code-split=per_kernel -o %t3.out %s +// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple},spir64 %if any-device-is-hip %{ %{hip_arch_opts} %} -fsycl-device-code-split=per_kernel -o %t3.out %s // RUN: %{run} %t3.out // -// RUN: %clangxx -fsycl -fsycl-targets=spir64,%{sycl_triple} -fsycl-device-code-split=per_kernel -o %t4.out %s +// RUN: %clangxx -fsycl -fsycl-targets=spir64,%{sycl_triple} %if any-device-is-hip %{ %{hip_arch_opts} %} -fsycl-device-code-split=per_kernel -o %t4.out %s // RUN: %{run} %t4.out #include diff --git a/sycl/test-e2e/format.py b/sycl/test-e2e/format.py index be33d6237735d..29e89e759bb96 100644 --- a/sycl/test-e2e/format.py +++ b/sycl/test-e2e/format.py @@ -176,11 +176,13 @@ def execute(self, test, litConfig): sycl_target_opts = "-fsycl-targets=%{sycl_triple}" if get_triple("hip") in triples: - sycl_target_opts += ( + hip_arch_opts = ( " -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch={}".format( test.config.amd_arch ) ) + sycl_target_opts += hip_arch_opts + substitutions.append(("%{hip_arch_opts}", hip_arch_opts)) substitutions.append(("%{sycl_target_opts}", sycl_target_opts)) substitutions.append(