diff --git a/sycl/test-e2e/AOT/multiple-devices.cpp b/sycl/test-e2e/AOT/multiple-devices.cpp index 78e7356541365..6fe0f51317517 100644 --- a/sycl/test-e2e/AOT/multiple-devices.cpp +++ b/sycl/test-e2e/AOT/multiple-devices.cpp @@ -5,27 +5,50 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// +// End-to-end test for verifying that the targets specified at link command +// line are used to select images from the fat binary built for multiple +// targets, and that compilation occurs for those targets. + +// UNSUPPORTED: new-offload-model +// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/20988 +// +// Explanation: Old offloading model was accepting compilation of a fat binary +// for AOT target without specifying specific device. In that case specific +// device to AOT-compile for was specified at link command line and compilation +// was happening only for targets specified in link command line, ignoring +// targets specified in compile command line, which doesn't look correct. In the +// new offloading model, the AOT images for all targets specified in compile +// command line are honored and AOT-compiled at link stage. To make it correct, +// if AOT target is specified at compile time, specific device should also be +// provided at compilation command line. +// +// A modified test can be found at NewOffloadDriver/aot-multiple-device.cpp // REQUIRES: opencl-aot, ocloc, any-device-is-cpu, any-device-is-gpu, target-spir, opencl-cpu-rt // Produce a fat object for all targets (generic SPIR-V, CPU, GPU) // RUN: %clangxx -fsycl -fsycl-targets=spir64,spir64_x86_64,spir64_gen %S/Inputs/aot.cpp -c -o %t.o -// CPU, GPU -// RUN: %{run-aux} %clangxx -fsycl -fsycl-targets=spir64_x86_64,spir64_gen -Xsycl-target-backend=spir64_gen %gpu_aot_target_opts %t.o -o %t_cpu_gpu.out +// Verify that AOT compilation occurs for the targets (GPU, CPU) +// specified in the link command line. Note that generic SPIR-V compilation +// is enabled by default even when AOT GPU or CPU targets are specified. +// RUN: %{run-aux} %clangxx -fsycl -fsycl-targets=spir64_x86_64,spir64_gen -Xsycl-target-backend=spir64_gen %gpu_aot_target_opts -v %t.o -o %t_cpu_gpu.out 2>&1 | FileCheck %s --check-prefix=CHECK-AOT-CPU --check-prefix=CHECK-AOT-GPU --check-prefix=CHECK-GENERIC // RUN: %{run} %t_cpu_gpu.out -// No AOT-compiled image for CPU -// RUN: %clangxx -fsycl -fsycl-targets=spir64,spir64_gen -Xsycl-target-backend=spir64_gen %gpu_aot_target_opts %t.o -o %t_spv_gpu.out +// Verify that AOT compilation occurs for the targets (GPU) specified in +// the link command line. +// RUN: %clangxx -fsycl -fsycl-targets=spir64,spir64_gen -Xsycl-target-backend=spir64_gen %gpu_aot_target_opts -v %t.o -o %t_spv_gpu.out 2>&1 | FileCheck %s --check-prefix=CHECK-GENERIC --check-prefix=CHECK-AOT-GPU --check-prefix=CHECK-NO-AOT-CPU // Check that execution on AOT-compatible devices is unaffected // RUN: env ONEAPI_DEVICE_SELECTOR="*:gpu" %{run-unfiltered-devices} %t_spv_gpu.out -// No AOT-compiled image for GPU -// RUN: %{run-aux} %clangxx -fsycl -fsycl-targets=spir64,spir64_x86_64 %t.o -o %t_spv_cpu.out +// Verify that AOT compilation occurs for the targets (CPU) specified in +// the link command line. +// RUN: %{run-aux} %clangxx -fsycl -fsycl-targets=spir64,spir64_x86_64 -v %t.o -o %t_spv_cpu.out 2>&1 | FileCheck %s --check-prefix=CHECK-GENERIC --check-prefix=CHECK-AOT-CPU --check-prefix=CHECK-NO-AOT-GPU // Check that execution on AOT-compatible devices is unaffected // RUN: env ONEAPI_DEVICE_SELECTOR="*:cpu" %{run-unfiltered-devices} %t_spv_cpu.out -// No AOT-compiled image for FPGA -// RUN: %{run-aux} %clangxx -fsycl -fsycl-targets=spir64,spir64_x86_64,spir64_gen -Xsycl-target-backend=spir64_gen %gpu_aot_target_opts %t.o -o %t_spv_cpu_gpu.out -// Check that execution on AOT-compatible devices is unaffected -// RUN: %{run} %t_spv_cpu_gpu.out +// CHECK-GENERIC-DAG: clang-offload-wrapper{{.*}} -target=spir64{{[^_]}} +// CHECK-AOT-CPU-DAG: clang-offload-wrapper{{.*}} -target=spir64_x86_64 +// CHECK-AOT-GPU-DAG: clang-offload-wrapper{{.*}} -target=spir64_gen +// CHECK-NO-AOT-CPU-NOT: clang-offload-wrapper{{.*}} -target=spir64_x86_64 +// CHECK-NO-AOT-GPU-NOT: clang-offload-wrapper{{.*}} -target=spir64_gen diff --git a/sycl/test-e2e/NewOffloadDriver/aot-multiple-devices.cpp b/sycl/test-e2e/NewOffloadDriver/aot-multiple-devices.cpp new file mode 100644 index 0000000000000..cbee51ad49877 --- /dev/null +++ b/sycl/test-e2e/NewOffloadDriver/aot-multiple-devices.cpp @@ -0,0 +1,41 @@ +//==--------------- aot-multiple-device.cpp -------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// End-to-end test for verifying that when compiling a fat binary for multiple +// device targets, all targets from the fat binary are processed during linking, +// regardless of which specific targets are specified in the link command +// line. + +// This test is copied from AOT/multiple_devices.cpp +// and modified to test with the New Offloading Model. + +// REQUIRES: opencl-aot, ocloc, any-device-is-cpu, any-device-is-gpu, target-spir, opencl-cpu-rt + +// Produce a fat object for all targets (generic SPIR-V, CPU, GPU). +// It is required to specify the device name when compiling AOT for GPU. +// RUN: %{run-aux} %clangxx --offload-new-driver -fsycl -fsycl-targets=spir64,spir64_x86_64,spir64_gen -Xsycl-target-backend=spir64_gen %gpu_aot_target_opts %S/Inputs/aot.cpp -c -o %t.o + +// Check that all targets compiled in the fat binary are selected during +// linking. +// RUN: %{run-aux} %clangxx --offload-new-driver -fsycl -fsycl-targets=spir64_x86_64,spir64_gen -Xsycl-target-backend=spir64_gen %gpu_aot_target_opts -v %t.o -o %t_cpu_gpu.out 2>&1 | FileCheck %s --check-prefix=CHECK-DEVICE +// RUN: %{run} %t_cpu_gpu.out + +// Check that all targets compiled in the fat binary are selected during +// linking (including CPU even though it is not specified during linking). +// RUN: %{run-aux} %clangxx --offload-new-driver -fsycl -fsycl-targets=spir64,spir64_gen -Xsycl-target-backend=spir64_gen %gpu_aot_target_opts -v %t.o -o %t_spv_gpu.out 2>&1 | FileCheck %s --check-prefix=CHECK-DEVICE +// Check that execution on AOT-compatible devices is unaffected +// RUN: env ONEAPI_DEVICE_SELECTOR="*:gpu" %{run-unfiltered-devices} %t_spv_gpu.out + +// Check that all targets compiled in the fat binary are selected during +// linking (including GPU even though it is not specified during linking). +// RUN: %{run-aux} %clangxx --offload-new-driver -fsycl -fsycl-targets=spir64,spir64_x86_64 -v %t.o -o %t_spv_cpu.out 2>&1 | FileCheck %s --check-prefix=CHECK-DEVICE +// Check that execution on AOT-compatible devices is unaffected. +// RUN: env ONEAPI_DEVICE_SELECTOR="*:cpu" %{run-unfiltered-devices} %t_spv_cpu.out + +// CHECK-DEVICE-DAG: spirv-to-ir-wrapper{{.*}}spir64_gen-unknown-unknown{{.*}} +// CHECK-DEVICE-DAG: spirv-to-ir-wrapper{{.*}}spir64_x86_64-unknown-unknown{{.*}} +// CHECK-DEVICE-DAG: spirv-to-ir-wrapper{{.*}}spir64-unknown-unknown{{.*}}