From a4b7b2c025532526d1475d18ecb9476d55d92e78 Mon Sep 17 00:00:00 2001 From: gejin Date: Tue, 1 Sep 2020 15:46:50 +0800 Subject: [PATCH 01/14] [SYCL] Link SYCL device libraries by default. As not all backends have supported spv file online link, we decided to disable fallback spv libraries online link at this time. Instead, all wrapper and fallback .o files will be linked offline. When all backends support spv online link, we will switch to online link for jit compilation transparently. Signed-off-by: gejin --- clang/lib/Driver/Driver.cpp | 79 +++++++++++++++++-- .../program_manager/program_manager.cpp | 7 +- sycl/test/devicelib/assert-aot.cpp | 2 +- sycl/test/devicelib/assert-windows.cpp | 3 +- sycl/test/devicelib/assert.cpp | 3 +- sycl/test/devicelib/cmath-aot.cpp | 8 +- sycl/test/devicelib/cmath_fp64_test.cpp | 3 +- sycl/test/devicelib/cmath_test.cpp | 3 +- sycl/test/devicelib/complex-fpga.cpp | 15 ++++ sycl/test/devicelib/math_fp64_test.cpp | 3 +- .../test/devicelib/math_fp64_windows_test.cpp | 3 +- sycl/test/devicelib/math_override_test.cpp | 6 +- sycl/test/devicelib/math_test.cpp | 3 +- sycl/test/devicelib/math_windows_test.cpp | 3 +- .../devicelib/std_complex_math_fp64_test.cpp | 3 +- sycl/test/devicelib/std_complex_math_test.cpp | 3 +- 16 files changed, 111 insertions(+), 36 deletions(-) create mode 100644 sycl/test/devicelib/complex-fpga.cpp diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 836219453b682..c5a6cbd585c96 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -2714,6 +2714,14 @@ static SmallVector getLinkerArgs(Compilation &C, return LibArgs; } +static bool IsSYCLDeviceLibObj(std::string ObjFilePath) { + StringRef ObjFileName = llvm::sys::path::filename(ObjFilePath); + bool Ret = (ObjFileName.startswith("libsycl-") && ObjFileName.endswith(".o")) + ? true + : false; + return Ret; +} + // Goes through all of the arguments, including inputs expected for the // linker directly, to determine if we need to perform additional work for // static offload libraries. @@ -3789,7 +3797,10 @@ class OffloadingActionBuilder final { if (IA->getType() == types::TY_Object) { if (!isObjectFile(FileName)) return ABRT_Inactive; - if (Args.hasArg(options::OPT_fintelfpga)) + // For SYCL device libraries, don't need to add them to + // FPGAObjectInputs as there is no fpga dep files inside. + if (Args.hasArg(options::OPT_fintelfpga) && + !IsSYCLDeviceLibObj(FileName)) FPGAObjectInputs.push_back(IA); } // When creating FPGA device fat objects, all host objects are @@ -3853,6 +3864,53 @@ class OffloadingActionBuilder final { SYCLDeviceActions.clear(); } + void addSYCLDeviceLibs(const ToolChain *TC, ActionList &DeviceLinkObjects, + bool isSpirvAOT, bool isMSVCEnv) { + enum SYCLDeviceLibType { + sycl_devicelib_wrapper, + sycl_devicelib_fallback + }; + StringRef LibLoc, LibSysUtils; + if (isMSVCEnv) { + LibLoc = Args.MakeArgString(TC->getDriver().Dir + "/../bin"); + LibSysUtils = "libsycl-msvc"; + } else { + LibLoc = Args.MakeArgString(TC->getDriver().Dir + "/../lib"); + LibSysUtils = "libsycl-glibc"; + } + SmallVector sycl_device_wrapper_libs = { + LibSysUtils, "libsycl-complex", "libsycl-complex-fp64", + "libsycl-cmath", "libsycl-cmath-fp64"}; + // For AOT compilation, we need to link sycl_device_fallback_libs as + // default too. + SmallVector sycl_device_fallback_libs = { + "libsycl-fallback-cassert", "libsycl-fallback-complex", + "libsycl-fallback-complex-fp64", "libsycl-fallback-cmath", + "libsycl-fallback-cmath-fp64"}; + auto addInputs = [&](SYCLDeviceLibType t) { + auto sycl_libs = (t == sycl_devicelib_wrapper) + ? sycl_device_wrapper_libs + : sycl_device_fallback_libs; + for (const StringRef &Lib : sycl_libs) { + SmallString<128> LibName(LibLoc); + llvm::sys::path::append(LibName, Lib); + llvm::sys::path::replace_extension(LibName, ".o"); + Arg *InputArg = MakeInputArg(Args, C.getDriver().getOpts(), + Args.MakeArgString(LibName)); + auto *SYCLDeviceLibsInputAction = + C.MakeAction(*InputArg, types::TY_Object); + auto *SYCLDeviceLibsUnbundleAction = + C.MakeAction( + SYCLDeviceLibsInputAction); + addDeviceDepences(SYCLDeviceLibsUnbundleAction); + DeviceLinkObjects.push_back(SYCLDeviceLibsUnbundleAction); + } + }; + addInputs(sycl_devicelib_wrapper); + if (isSpirvAOT) + addInputs(sycl_devicelib_fallback); + } + void appendLinkDependences(OffloadAction::DeviceDependences &DA) override { assert(ToolChains.size() == DeviceLinkerInputs.size() && "Toolchains and linker inputs sizes do not match."); @@ -3932,6 +3990,11 @@ class OffloadingActionBuilder final { } ActionList DeviceLibObjects; ActionList LinkObjects; + auto TT = SYCLTripleList[I]; + auto isNVPTX = (*TC)->getTriple().isNVPTX(); + bool isSpirvAOT = TT.getSubArch() == llvm::Triple::SPIRSubArch_fpga || + TT.getSubArch() == llvm::Triple::SPIRSubArch_gen || + TT.getSubArch() == llvm::Triple::SPIRSubArch_x86_64; for (const auto &Input : LI) { // FPGA aoco does not go through the link, everything else does. if (Input->getType() == types::TY_FPGA_AOCO) @@ -3939,6 +4002,15 @@ class OffloadingActionBuilder final { else LinkObjects.push_back(Input); } + // FIXME: Link all wrapper and fallback device libraries as default, + // When spv online link is supported by all backends, the fallback + // device libraries are only needed when current toolchain is using + // AOT compilation. + if (!isNVPTX) { + addSYCLDeviceLibs( + *TC, LinkObjects, true, + C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment()); + } // The linkage actions subgraph leading to the offload wrapper. // [cond] Means incoming/outgoing dependence is created only when cond // is true. A function of: @@ -3993,7 +4065,6 @@ class OffloadingActionBuilder final { Action *DeviceLinkAction = C.MakeAction(LinkObjects, types::TY_LLVM_BC); // setup some flags upfront - auto isNVPTX = (*TC)->getTriple().isNVPTX(); if (isNVPTX && DeviceCodeSplit) { // TODO Temporary limitation, need to support code splitting for PTX @@ -4005,10 +4076,6 @@ class OffloadingActionBuilder final { D.Diag(diag::err_drv_unsupported_opt_for_target) << OptName << (*TC)->getTriple().str(); } - auto TT = SYCLTripleList[I]; - bool isSpirvAOT = TT.getSubArch() == llvm::Triple::SPIRSubArch_fpga || - TT.getSubArch() == llvm::Triple::SPIRSubArch_gen || - TT.getSubArch() == llvm::Triple::SPIRSubArch_x86_64; // reflects whether current target is ahead-of-time and can't support // runtime setting of specialization constants bool isAOT = isNVPTX || isSpirvAOT; diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index 6dd637feb2656..6675fb71d19b9 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -371,9 +371,12 @@ RT::PiProgram ProgramManager::getBuiltPIProgram(OSModuleHandle M, // If device image is not SPIR-V, DeviceLibReqMask will be 0 which means // no fallback device library will be linked. uint32_t DeviceLibReqMask = 0; - if (Img.getFormat() == PI_DEVICE_BINARY_TYPE_SPIRV && + // FIXME: disable the fallback device libraries online link as not all + // backend supports spv online link. Need to enable it when all backends + // support spv online link. + /* if (Img.getFormat() == PI_DEVICE_BINARY_TYPE_SPIRV && !SYCLConfig::get()) - DeviceLibReqMask = getDeviceLibReqMask(Img); + DeviceLibReqMask = getDeviceLibReqMask(Img); */ ProgramPtr BuiltProgram = build(std::move(ProgramManaged), ContextImpl, Img.getCompileOptions(), diff --git a/sycl/test/devicelib/assert-aot.cpp b/sycl/test/devicelib/assert-aot.cpp index 3867b97039987..811f174b399d7 100644 --- a/sycl/test/devicelib/assert-aot.cpp +++ b/sycl/test/devicelib/assert-aot.cpp @@ -1,5 +1,5 @@ // REQUIRES: opencl-aot, cpu, linux -// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %S/assert.cpp %sycl_libs_dir/libsycl-glibc.o %sycl_libs_dir/libsycl-fallback-cassert.o -o %t.aot.out +// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %S/assert.cpp -o %t.aot.out // RUN: %CPU_RUN_PLACEHOLDER %t.aot.out >%t.aot.msg // RUN: FileCheck %S/assert.cpp --input-file %t.aot.msg --check-prefixes=CHECK-MESSAGE diff --git a/sycl/test/devicelib/assert-windows.cpp b/sycl/test/devicelib/assert-windows.cpp index fb38520601d98..01db1858e5e67 100644 --- a/sycl/test/devicelib/assert-windows.cpp +++ b/sycl/test/devicelib/assert-windows.cpp @@ -4,8 +4,7 @@ // Disable the test until the fix reaches SYCL test infrastructure. // XFAIL: * // -// RUN: %clangxx -fsycl -c %s -o %t.o -// RUN: %clangxx -fsycl %t.o %sycl_libs_dir/../bin/libsycl-msvc.o -o %t.out +// RUN: %clangxx -fsycl %s -o %t.out // // MSVC implementation of assert does not call an unreachable built-in, so the // program doesn't terminate when fallback is used. diff --git a/sycl/test/devicelib/assert.cpp b/sycl/test/devicelib/assert.cpp index 343d949b74052..e86923ee09f10 100644 --- a/sycl/test/devicelib/assert.cpp +++ b/sycl/test/devicelib/assert.cpp @@ -1,6 +1,5 @@ // REQUIRES: cpu,linux -// RUN: %clangxx -fsycl -c %s -o %t.o -// RUN: %clangxx -fsycl %t.o %sycl_libs_dir/libsycl-glibc.o -o %t.out +// RUN: %clangxx -fsycl %s -o %t.out // (see the other RUN lines below; it is a bit complicated) // // assert() call in device code guarantees nothing: on some devices it behaves diff --git a/sycl/test/devicelib/cmath-aot.cpp b/sycl/test/devicelib/cmath-aot.cpp index e58a87d9f51bc..18ac5095bd074 100644 --- a/sycl/test/devicelib/cmath-aot.cpp +++ b/sycl/test/devicelib/cmath-aot.cpp @@ -1,14 +1,14 @@ // REQUIRES: opencl-aot, cpu // UNSUPPORTED: windows -// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %S/cmath_test.cpp %sycl_libs_dir/libsycl-cmath.o %sycl_libs_dir/libsycl-fallback-cmath.o -o %t.cmath.out +// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %S/cmath_test.cpp -o %t.cmath.out // RUN: %CPU_RUN_PLACEHOLDER %t.cmath.out -// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %S/cmath_fp64_test.cpp %sycl_libs_dir/libsycl-cmath-fp64.o %sycl_libs_dir/libsycl-fallback-cmath-fp64.o -o %t.cmath.fp64.out +// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %S/cmath_fp64_test.cpp -o %t.cmath.fp64.out // RUN: %CPU_RUN_PLACEHOLDER %t.cmath.fp64.out -// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %S/std_complex_math_test.cpp %sycl_libs_dir/libsycl-complex.o %sycl_libs_dir/libsycl-cmath.o %sycl_libs_dir/libsycl-fallback-complex.o %sycl_libs_dir/libsycl-fallback-cmath.o -o %t.complex.out +// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %S/std_complex_math_test.cpp -o %t.complex.out // RUN: %CPU_RUN_PLACEHOLDER %t.complex.out -// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %S/std_complex_math_fp64_test.cpp %sycl_libs_dir/libsycl-complex-fp64.o %sycl_libs_dir/libsycl-cmath-fp64.o %sycl_libs_dir/libsycl-fallback-complex-fp64.o %sycl_libs_dir/libsycl-fallback-cmath-fp64.o -o %t.complex.fp64.out +// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %S/std_complex_math_fp64_test.cpp -o %t.complex.fp64.out // RUN: %CPU_RUN_PLACEHOLDER %t.complex.fp64.out diff --git a/sycl/test/devicelib/cmath_fp64_test.cpp b/sycl/test/devicelib/cmath_fp64_test.cpp index 30954e0eff59f..92b71027088a8 100644 --- a/sycl/test/devicelib/cmath_fp64_test.cpp +++ b/sycl/test/devicelib/cmath_fp64_test.cpp @@ -1,6 +1,5 @@ // UNSUPPORTED: windows -// RUN: %clangxx -fsycl -c %s -o %t.o -// RUN: %clangxx -fsycl %t.o %sycl_libs_dir/libsycl-cmath-fp64.o -o %t.out +// RUN: %clangxx -fsycl %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out diff --git a/sycl/test/devicelib/cmath_test.cpp b/sycl/test/devicelib/cmath_test.cpp index bb2e37345d6fc..ffb4fc039b54b 100644 --- a/sycl/test/devicelib/cmath_test.cpp +++ b/sycl/test/devicelib/cmath_test.cpp @@ -1,6 +1,5 @@ // UNSUPPORTED: windows -// RUN: %clangxx -fsycl -c %s -o %t.o -// RUN: %clangxx -fsycl %t.o %sycl_libs_dir/libsycl-cmath.o -o %t.out +// RUN: %clangxx -fsycl %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out diff --git a/sycl/test/devicelib/complex-fpga.cpp b/sycl/test/devicelib/complex-fpga.cpp new file mode 100644 index 0000000000000..4d9e4db39e84b --- /dev/null +++ b/sycl/test/devicelib/complex-fpga.cpp @@ -0,0 +1,15 @@ +//==----- accelerator.cpp - AOT compilation for fpga devices using aoc ----==// +// +// 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 +// +//===------------------------------------------------------------------------===// + +// REQUIRES: aoc, accelerator + +// RUN: %clangxx -fsycl -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice %S/std_complex_math_test.cpp -o %t.out +// RUN: %ACC_RUN_PLACEHOLDER %t.out + +// RUN: %clangxx -fsycl -fintelfpga %S/std_complex_math_test.cpp -o %t.out +// RUN: %ACC_RUN_PLACEHOLDER %t.out diff --git a/sycl/test/devicelib/math_fp64_test.cpp b/sycl/test/devicelib/math_fp64_test.cpp index dec0bf7341d92..23c81033e9ea4 100644 --- a/sycl/test/devicelib/math_fp64_test.cpp +++ b/sycl/test/devicelib/math_fp64_test.cpp @@ -1,6 +1,5 @@ // REQUIRES: cpu, linux -// RUN: %clangxx -fsycl -c %s -o %t.o -// RUN: %clangxx -fsycl %t.o %sycl_libs_dir/libsycl-cmath-fp64.o -o %t.out +// RUN: %clangxx -fsycl %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out diff --git a/sycl/test/devicelib/math_fp64_windows_test.cpp b/sycl/test/devicelib/math_fp64_windows_test.cpp index 64d4e000c5ff5..ac728ad4bf8b5 100644 --- a/sycl/test/devicelib/math_fp64_windows_test.cpp +++ b/sycl/test/devicelib/math_fp64_windows_test.cpp @@ -1,6 +1,5 @@ // REQUIRES: cpu, windows -// RUN: %clangxx -fsycl -c %s -o %t.o -// RUN: %clangxx -fsycl %t.o %sycl_libs_dir/../bin/libsycl-cmath-fp64.o -o %t.out +// RUN: %clangxx -fsycl %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out diff --git a/sycl/test/devicelib/math_override_test.cpp b/sycl/test/devicelib/math_override_test.cpp index e634bf77fbd37..b3014f9bea884 100644 --- a/sycl/test/devicelib/math_override_test.cpp +++ b/sycl/test/devicelib/math_override_test.cpp @@ -1,6 +1,5 @@ // UNSUPPORTED: windows -// RUN: %clangxx -fsycl -c %s -o %t.o -// RUN: %clangxx -fsycl %t.o %sycl_libs_dir/libsycl-cmath.o -o %t.out +// RUN: %clangxx -fsycl %s -o %t.out -fno-builtin // RUN: env SYCL_DEVICE_TYPE=HOST %t.out #include #include @@ -16,6 +15,8 @@ constexpr s::access::mode sycl_write = s::access::mode::write; SYCL_EXTERNAL extern "C" float sinf(float x) { return x + 100.f; } +SYCL_EXTERNAL +extern "C" float cosf(float x); class DeviceTest; void device_test() { @@ -37,7 +38,6 @@ void device_test() { }); }); } - assert(approx_equal_fp(result_sin, 100.f) && approx_equal_fp(result_cos, 1.f)); } diff --git a/sycl/test/devicelib/math_test.cpp b/sycl/test/devicelib/math_test.cpp index 1e3885960b2c5..8394874b7b76c 100644 --- a/sycl/test/devicelib/math_test.cpp +++ b/sycl/test/devicelib/math_test.cpp @@ -1,6 +1,5 @@ // REQUIRES: cpu, linux -// RUN: %clangxx -fsycl -c %s -o %t.o -// RUN: %clangxx -fsycl %t.o %sycl_libs_dir/libsycl-cmath.o -o %t.out +// RUN: %clangxx -fsycl %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out diff --git a/sycl/test/devicelib/math_windows_test.cpp b/sycl/test/devicelib/math_windows_test.cpp index fa295c8bff84c..964db574beec5 100644 --- a/sycl/test/devicelib/math_windows_test.cpp +++ b/sycl/test/devicelib/math_windows_test.cpp @@ -1,6 +1,5 @@ // REQUIRES: cpu, windows -// RUN: %clangxx -fsycl -c %s -o %t.o -// RUN: %clangxx -fsycl %t.o %sycl_libs_dir/../bin/libsycl-cmath.o -o %t.out +// RUN: %clangxx -fsycl %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out diff --git a/sycl/test/devicelib/std_complex_math_fp64_test.cpp b/sycl/test/devicelib/std_complex_math_fp64_test.cpp index 40eeadfd04321..673583b39a20d 100644 --- a/sycl/test/devicelib/std_complex_math_fp64_test.cpp +++ b/sycl/test/devicelib/std_complex_math_fp64_test.cpp @@ -1,6 +1,5 @@ // UNSUPPORTED: windows -// RUN: %clangxx -fsycl -c %s -o %t.o -// RUN: %clangxx -fsycl %t.o %sycl_libs_dir/libsycl-complex-fp64.o %sycl_libs_dir/libsycl-cmath-fp64.o -o %t.out +// RUN: %clangxx -fsycl %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out diff --git a/sycl/test/devicelib/std_complex_math_test.cpp b/sycl/test/devicelib/std_complex_math_test.cpp index b2578076243ff..fb6b1feaf1319 100644 --- a/sycl/test/devicelib/std_complex_math_test.cpp +++ b/sycl/test/devicelib/std_complex_math_test.cpp @@ -1,6 +1,5 @@ // UNSUPPORTED: windows -// RUN: %clangxx -fsycl -c %s -o %t.o -// RUN: %clangxx -fsycl %t.o %sycl_libs_dir/libsycl-complex.o %sycl_libs_dir/libsycl-cmath.o -o %t.out +// RUN: %clangxx -fsycl %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out From 6d1f7d371a2c37f06374b49954ab5c75afe2b93b Mon Sep 17 00:00:00 2001 From: gejin Date: Thu, 3 Sep 2020 15:17:12 +0800 Subject: [PATCH 02/14] add options -f[no-]sycl-device-lib= libc and libm-fp32 libs are linked by default Signed-off-by: gejin --- clang/include/clang/Driver/Options.td | 9 +++ clang/lib/Driver/Driver.cpp | 69 +++++++++++++++---- clang/test/Driver/sycl-offload-intelfpga.cpp | 30 ++++---- sycl/test/devicelib/assert.cpp | 8 --- sycl/test/devicelib/cmath_fp64_test.cpp | 2 +- .../test/devicelib/math_fp64_windows_test.cpp | 2 +- .../devicelib/std_complex_math_fp64_test.cpp | 2 +- sycl/test/spec_const/spec_const_redefine.cpp | 8 +-- 8 files changed, 86 insertions(+), 44 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 7d4e1487adeed..e834d15d4a18c 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3557,6 +3557,15 @@ def fsycl_dead_args_optimization : Flag<["-"], "fsycl-dead-args-optimization">, def fno_sycl_dead_args_optimization : Flag<["-"], "fno-sycl-dead-args-optimization">, Group, Flags<[NoArgumentUnused, CoreOption]>, HelpText<"Disables " "elimination of DPC++ dead kernel arguments">; +def fsycl_device_lib_EQ : CommaJoined<["-"], "fsycl-device-lib=">, Group, Flags<[DriverOption, CoreOption]>, + Values<"libc, libm-fp32, libm-fp64, all">, HelpText<"Control the addition " + "of device libraries when compiling for other devices. Valid arguments " + "are libc, libm-fp32, libm-fp64, all">; +def fno_sycl_device_lib_EQ : CommaJoined<["-"], "fno-sycl-device-lib=">, Group, Flags<[DriverOption, CoreOption]>, + Values<"libc, libm-fp32, libm-fp64, all">, HelpText<"Control the deletion" + "of device libraries when compiling for other devices. Valid arguments " + "are libc, libm-fp32, libm-fp64, all">; + //===----------------------------------------------------------------------===// // CC1 Options //===----------------------------------------------------------------------===// diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index c5a6cbd585c96..c81b88a8e3062 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -5,7 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// - +#include #include "clang/Driver/Driver.h" #include "InputInfo.h" #include "ToolChains/AIX.h" @@ -3798,7 +3798,7 @@ class OffloadingActionBuilder final { if (!isObjectFile(FileName)) return ABRT_Inactive; // For SYCL device libraries, don't need to add them to - // FPGAObjectInputs as there is no fpga dep files inside. + // FPGAObjectInputs as there is no FPGA dep files inside. if (Args.hasArg(options::OPT_fintelfpga) && !IsSYCLDeviceLibObj(FileName)) FPGAObjectInputs.push_back(IA); @@ -3870,30 +3870,71 @@ class OffloadingActionBuilder final { sycl_devicelib_wrapper, sycl_devicelib_fallback }; - StringRef LibLoc, LibSysUtils; + struct DeviceLibOptInfo { + StringRef devicelib_name; + StringRef devicelib_option; + }; + + bool NoDeviceLibs = false; + llvm::StringMap devicelib_link_info = { + {"libc", true}, {"libm-fp32", true}, {"libm-fp64", false}}; + if (Arg *A = Args.getLastArg(options::OPT_fsycl_device_lib_EQ, + options::OPT_fno_sycl_device_lib_EQ)) { + if (A->getValues().size() == 0) + C.getDriver().Diag(diag::warn_drv_empty_joined_argument) + << A->getAsString(Args); + else { + if (A->getOption().matches(options::OPT_fno_sycl_device_lib_EQ)) + NoDeviceLibs = true; + + for (StringRef Val : A->getValues()) { + if (Val == "all") { + for (auto &K : devicelib_link_info.keys()) + devicelib_link_info[K] = true && !NoDeviceLibs; + break; + } + auto LinkInfoIter = devicelib_link_info.find(Val); + if (LinkInfoIter == devicelib_link_info.end()) { + C.getDriver().Diag(diag::err_drv_unsupported_option_argument) + << A->getOption().getName() << Val; + } + devicelib_link_info[Val] = true && !NoDeviceLibs; + } + } + } + + StringRef LibSysUtils; + SmallString<128> LibLoc(TC->getDriver().Dir); if (isMSVCEnv) { - LibLoc = Args.MakeArgString(TC->getDriver().Dir + "/../bin"); + llvm::sys::path::append(LibLoc, "/../bin"); LibSysUtils = "libsycl-msvc"; } else { - LibLoc = Args.MakeArgString(TC->getDriver().Dir + "/../lib"); + llvm::sys::path::append(LibLoc, "/../lib"); LibSysUtils = "libsycl-glibc"; } - SmallVector sycl_device_wrapper_libs = { - LibSysUtils, "libsycl-complex", "libsycl-complex-fp64", - "libsycl-cmath", "libsycl-cmath-fp64"}; + SmallVector sycl_device_wrapper_libs = { + {LibSysUtils, "libc"}, + {"libsycl-complex", "libm-fp32"}, + {"libsycl-complex-fp64", "libm-fp64"}, + {"libsycl-cmath", "libm-fp32"}, + {"libsycl-cmath-fp64", "libm-fp64"}}; // For AOT compilation, we need to link sycl_device_fallback_libs as // default too. - SmallVector sycl_device_fallback_libs = { - "libsycl-fallback-cassert", "libsycl-fallback-complex", - "libsycl-fallback-complex-fp64", "libsycl-fallback-cmath", - "libsycl-fallback-cmath-fp64"}; + SmallVector sycl_device_fallback_libs = { + {"libsycl-fallback-cassert", "libc"}, + {"libsycl-fallback-complex", "libm-fp32"}, + {"libsycl-fallback-complex-fp64", "libm-fp64"}, + {"libsycl-fallback-cmath", "libm-fp32"}, + {"libsycl-fallback-cmath-fp64", "libm-fp64"}}; auto addInputs = [&](SYCLDeviceLibType t) { auto sycl_libs = (t == sycl_devicelib_wrapper) ? sycl_device_wrapper_libs : sycl_device_fallback_libs; - for (const StringRef &Lib : sycl_libs) { + for (const DeviceLibOptInfo &Lib : sycl_libs) { + if (!devicelib_link_info[Lib.devicelib_option]) + continue; SmallString<128> LibName(LibLoc); - llvm::sys::path::append(LibName, Lib); + llvm::sys::path::append(LibName, Lib.devicelib_name); llvm::sys::path::replace_extension(LibName, ".o"); Arg *InputArg = MakeInputArg(Args, C.getDriver().getOpts(), Args.MakeArgString(LibName)); diff --git a/clang/test/Driver/sycl-offload-intelfpga.cpp b/clang/test/Driver/sycl-offload-intelfpga.cpp index de589affbc5e7..e1758709eaf58 100644 --- a/clang/test/Driver/sycl-offload-intelfpga.cpp +++ b/clang/test/Driver/sycl-offload-intelfpga.cpp @@ -21,11 +21,11 @@ /// -fintelfpga -fsycl-link tests // RUN: touch %t.o -// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -fsycl-link %t.o -o libfoo.a 2>&1 \ +// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fintelfpga -fsycl-link %t.o -o libfoo.a 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-FPGA-LINK,CHK-FPGA-EARLY %s -// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -fsycl-link=early %t.o -o libfoo.a 2>&1 \ +// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fintelfpga -fsycl-link=early %t.o -o libfoo.a 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-FPGA-LINK,CHK-FPGA-EARLY %s -// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -fsycl-link=image %t.o -o libfoo.a 2>&1 \ +// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fintelfpga -fsycl-link=image %t.o -o libfoo.a 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-FPGA-LINK,CHK-FPGA-IMAGE %s // CHK-FPGA-LINK-NOT: clang-offload-bundler{{.*}} "-check-section" // CHK-FPGA-LINK: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64_fpga-unknown-unknown-sycldevice" "-inputs=[[INPUT:.+\.o]]" "-outputs=[[OUTPUT1:.+\.o]]" "-unbundle" @@ -50,9 +50,9 @@ /// -fintelfpga -fsycl-link clang-cl specific // RUN: touch %t.obj -// RUN: %clang_cl -### -fsycl -fintelfpga -fsycl-link %t.obj -Folibfoo.lib 2>&1 \ +// RUN: %clang_cl -### -fsycl -fintelfpga -fno-sycl-device-lib=all -fsycl-link %t.obj -Folibfoo.lib 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-FPGA-LINK-WIN %s -// RUN: %clang_cl -### -fsycl -fintelfpga -fsycl-link %t.obj -o libfoo.lib 2>&1 \ +// RUN: %clang_cl -### -fsycl -fintelfpga -fno-sycl-device-lib=all -fsycl-link %t.obj -o libfoo.lib 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-FPGA-LINK-WIN %s // CHK-FPGA-LINK-WIN: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64_fpga-unknown-unknown-sycldevice{{.*}}" "-inputs=[[INPUT:.+\.obj]]" "-outputs=[[OUTPUT1:.+\.obj]]" "-unbundle" // CHK-FPGA-LINK-WIN-NOT: clang-offload-bundler{{.*}} @@ -185,9 +185,9 @@ /// -fintelfpga -fsycl-link from source // RUN: touch %t.cpp -// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -fsycl-link=early %t.cpp -ccc-print-phases 2>&1 \ +// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fintelfpga -fsycl-link=early %t.cpp -ccc-print-phases 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-FPGA-LINK-SRC,CHK-FPGA-LINK-SRC-DEFAULT %s -// RUN: %clang_cl -### -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -fsycl-link=early %t.cpp -ccc-print-phases 2>&1 \ +// RUN: %clang_cl -### -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fintelfpga -fsycl-link=early %t.cpp -ccc-print-phases 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-FPGA-LINK-SRC,CHK-FPGA-LINK-SRC-CL %s // CHK-FPGA-LINK-SRC: 0: input, "[[INPUT:.+\.cpp]]", c++, (host-sycl) // CHK-FPGA-LINK-SRC: 1: preprocessor, {0}, c++-cpp-output, (host-sycl) @@ -275,9 +275,9 @@ /// -fintelfpga dependency file use from object phases test // RUN: touch %t-1.o -// RUN: %clangxx -fsycl -fintelfpga -ccc-print-phases -### %t-1.o 2>&1 \ +// RUN: %clangxx -fsycl -fno-sycl-device-lib=all -fintelfpga -ccc-print-phases -### %t-1.o 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-FPGA-DEP-FILES-OBJ-PHASES -DINPUT=%t-1.o %s -// RUN: %clang_cl -fsycl -fintelfpga -ccc-print-phases -### %t-1.o 2>&1 \ +// RUN: %clang_cl -fsycl -fno-sycl-device-lib=all -fintelfpga -ccc-print-phases -### %t-1.o 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-FPGA-DEP-FILES-OBJ-PHASES -DINPUT=%t-1.o %s // CHK-FPGA-DEP-FILES-OBJ-PHASES: 0: input, "[[INPUT]]", object, (host-sycl) // CHK-FPGA-DEP-FILES-OBJ-PHASES: 1: clang-offload-unbundler, {0}, object, (host-sycl) @@ -348,7 +348,7 @@ // RUN: llc -filetype=obj -o %t-aoco_cl.o %t-aoco_cl.bc // RUN: llvm-ar crv %t_aoco.a %t.o %t2.o %t-aoco.o // RUN: llvm-ar crv %t_aoco_cl.a %t.o %t2_cl.o %t-aoco_cl.o -// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -foffload-static-lib=%t_aoco.a %s -### -ccc-print-phases 2>&1 \ +// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fintelfpga -foffload-static-lib=%t_aoco.a %s -### -ccc-print-phases 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-FPGA-AOCO-PHASES %s // CHK-FPGA-AOCO-PHASES: 0: input, "[[INPUTA:.+\.a]]", object, (host-sycl) // CHK-FPGA-AOCO-PHASES: 1: input, "[[INPUTCPP:.+\.cpp]]", c++, (host-sycl) @@ -375,7 +375,7 @@ // CHK-FPGA-AOCO-PHASES: 22: offload, "host-sycl (x86_64-unknown-linux-gnu)" {10}, "device-sycl (spir64_fpga-unknown-unknown-sycldevice)" {21}, image /// FPGA AOCO Windows phases check -// RUN: %clang_cl -fsycl -fintelfpga -foffload-static-lib=%t_aoco_cl.a %s -### -ccc-print-phases 2>&1 \ +// RUN: %clang_cl -fsycl -fno-sycl-device-lib=all -fintelfpga -foffload-static-lib=%t_aoco_cl.a %s -### -ccc-print-phases 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-FPGA-AOCO-PHASES-WIN %s // CHK-FPGA-AOCO-PHASES-WIN: 0: input, "{{.*}}", object, (host-sycl) // CHK-FPGA-AOCO-PHASES-WIN: 1: input, "[[INPUTSRC:.+\.cpp]]", c++, (host-sycl) @@ -401,13 +401,13 @@ // CHK-FPGA-AOCO-PHASES-WIN: 21: offload, "host-sycl (x86_64-pc-windows-msvc)" {10}, "device-sycl (spir64_fpga-unknown-unknown-sycldevice)" {20}, image /// aoco test, checking tools -// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -foffload-static-lib=%t_aoco.a -### %s 2>&1 \ +// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fintelfpga -foffload-static-lib=%t_aoco.a -### %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-FPGA-AOCO,CHK-FPGA-AOCO-LIN %s -// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fintelfpga %t_aoco.a -### %s 2>&1 \ +// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fintelfpga %t_aoco.a -### %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-FPGA-AOCO,CHK-FPGA-AOCO-LIN %s -// RUN: %clang_cl -fsycl -fintelfpga -foffload-static-lib=%t_aoco_cl.a -### %s 2>&1 \ +// RUN: %clang_cl -fsycl -fno-sycl-device-lib=all -fintelfpga -foffload-static-lib=%t_aoco_cl.a -### %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-FPGA-AOCO,CHK-FPGA-AOCO-WIN %s -// RUN: %clang_cl -fsycl -fintelfpga %t_aoco_cl.a -### %s 2>&1 \ +// RUN: %clang_cl -fsycl -fno-sycl-device-lib=all -fintelfpga %t_aoco_cl.a -### %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-FPGA-AOCO,CHK-FPGA-AOCO-WIN %s // CHK-FPGA-AOCO-LIN: clang-offload-bundler{{.*}} "-type=ao" "-targets=sycl-fpga_aoco-intel-unknown-sycldevice" "-inputs=[[INPUTLIB:.+\.a]]" "-check-section" // CHK-FPGA-AOCO-LIN: clang{{.*}} "-emit-obj" {{.*}} "-o" "[[HOSTOBJ:.+\.o]]" diff --git a/sycl/test/devicelib/assert.cpp b/sycl/test/devicelib/assert.cpp index e86923ee09f10..1afa4169bab73 100644 --- a/sycl/test/devicelib/assert.cpp +++ b/sycl/test/devicelib/assert.cpp @@ -75,14 +75,6 @@ // RUN: FileCheck %s --input-file %t.stdout.native --check-prefixes=CHECK-NATIVE || FileCheck %s --input-file %t.stderr.native --check-prefix CHECK-NOTSUPPORTED // RUN: FileCheck %s --input-file %t.stderr.native --check-prefixes=CHECK-MESSAGE || FileCheck %s --input-file %t.stderr.native --check-prefix CHECK-NOTSUPPORTED // -// RUN: env SYCL_PI_TRACE=2 SYCL_DEVICELIB_INHIBIT_NATIVE=cl_intel_devicelib_assert SYCL_DEVICE_TYPE=CPU %t.out >%t.stdout.pi.fallback -// RUN: env SYCL_DEVICELIB_INHIBIT_NATIVE=cl_intel_devicelib_assert SYCL_DEVICE_TYPE=CPU %t.out >%t.stdout.msg.fallback -// RUN: FileCheck %s --input-file %t.stdout.pi.fallback --check-prefixes=CHECK-FALLBACK -// RUN: FileCheck %s --input-file %t.stdout.msg.fallback --check-prefixes=CHECK-MESSAGE -// -// CHECK-NATIVE: ---> piProgramBuild -// CHECK-FALLBACK: ---> piProgramLink -// // Skip the test if the CPU RT doesn't support the extension yet: // CHECK-NOTSUPPORTED: Device has no support for cl_intel_devicelib_assert // diff --git a/sycl/test/devicelib/cmath_fp64_test.cpp b/sycl/test/devicelib/cmath_fp64_test.cpp index 92b71027088a8..52d9d59aa5baf 100644 --- a/sycl/test/devicelib/cmath_fp64_test.cpp +++ b/sycl/test/devicelib/cmath_fp64_test.cpp @@ -1,5 +1,5 @@ // UNSUPPORTED: windows -// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %clangxx -fsycl -fsycl-device-lib=fp64 %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out diff --git a/sycl/test/devicelib/math_fp64_windows_test.cpp b/sycl/test/devicelib/math_fp64_windows_test.cpp index ac728ad4bf8b5..c0b7ad487d2c3 100644 --- a/sycl/test/devicelib/math_fp64_windows_test.cpp +++ b/sycl/test/devicelib/math_fp64_windows_test.cpp @@ -1,5 +1,5 @@ // REQUIRES: cpu, windows -// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %clangxx -fsycl -fsycl-device-lib=fp64 %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out diff --git a/sycl/test/devicelib/std_complex_math_fp64_test.cpp b/sycl/test/devicelib/std_complex_math_fp64_test.cpp index 673583b39a20d..85de5436a5ebc 100644 --- a/sycl/test/devicelib/std_complex_math_fp64_test.cpp +++ b/sycl/test/devicelib/std_complex_math_fp64_test.cpp @@ -1,5 +1,5 @@ // UNSUPPORTED: windows -// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %clangxx -fsycl -fsycl-device-lib=fp64 %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out diff --git a/sycl/test/spec_const/spec_const_redefine.cpp b/sycl/test/spec_const/spec_const_redefine.cpp index fc5e7dcb22ac1..e6413cd92dd8e 100644 --- a/sycl/test/spec_const/spec_const_redefine.cpp +++ b/sycl/test/spec_const/spec_const_redefine.cpp @@ -105,9 +105,9 @@ int main(int argc, char **argv) { } // --- Check that only two JIT compilation happened: -// CHECK-NOT: ---> piProgramLink -// CHECK: ---> piProgramLink -// CHECK: ---> piProgramLink -// CHECK-NOT: ---> piProgramLink +// CHECK-NOT: ---> piProgramBuild +// CHECK: ---> piProgramBuild +// CHECK: ---> piProgramBuild +// CHECK-NOT: ---> piProgramBuild // --- Check that the test completed with expected results: // CHECK: passed From c871ceb2b302079a52708944718abce301f32147 Mon Sep 17 00:00:00 2001 From: gejin Date: Thu, 3 Sep 2020 15:46:07 +0800 Subject: [PATCH 03/14] remove ununsed headr Signed-off-by: gejin --- clang/lib/Driver/Driver.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 93cc6344cc438..a1edb3599106e 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -5,7 +5,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -#include #include "clang/Driver/Driver.h" #include "InputInfo.h" #include "ToolChains/AIX.h" From 6024034a74019f785b3e029be7e8f4725eaa1374 Mon Sep 17 00:00:00 2001 From: gejin Date: Thu, 3 Sep 2020 16:11:40 +0800 Subject: [PATCH 04/14] Fix driver lit test using -fno-sycl-device-lib=all Signed-off-by: gejin --- .../test/Driver/sycl-offload-static-lib-2.cpp | 4 +- clang/test/Driver/sycl-offload-static-lib.cpp | 6 +- clang/test/Driver/sycl-offload-win.c | 4 +- clang/test/Driver/sycl-offload-with-split.c | 38 +++++------ clang/test/Driver/sycl-offload.c | 68 +++++++++---------- 5 files changed, 60 insertions(+), 60 deletions(-) diff --git a/clang/test/Driver/sycl-offload-static-lib-2.cpp b/clang/test/Driver/sycl-offload-static-lib-2.cpp index eff45a9d19f30..cc97a6a53a8de 100644 --- a/clang/test/Driver/sycl-offload-static-lib-2.cpp +++ b/clang/test/Driver/sycl-offload-static-lib-2.cpp @@ -99,9 +99,9 @@ /// ########################################################################### /// test behaviors of static lib with no source/object -// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -L/dummy/dir %t.a -### 2>&1 \ +// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -L/dummy/dir %t.a -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=STATIC_LIB_NOSRC -DINPUTLIB=%t.a -// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -L/dummy/dir %t.lo -### 2>&1 \ +// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -L/dummy/dir %t.lo -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=STATIC_LIB_NOSRC -DINPUTLIB=%t.lo // STATIC_LIB_NOSRC: clang-offload-bundler{{.*}} "-type=ao" "-targets=host-x86_64-unknown-linux-gnu" "-inputs=[[INPUTLIB]]" "-check-section" // STATIC_LIB_NOSRC: ld{{.*}} "-r" "-o" "[[PARTIALOBJ:.+\.o]]" "{{.*}}crt1.o" {{.*}} "-L/dummy/dir" {{.*}} "[[INPUTLIB]]" diff --git a/clang/test/Driver/sycl-offload-static-lib.cpp b/clang/test/Driver/sycl-offload-static-lib.cpp index e32b244162e38..95cb56245d539 100644 --- a/clang/test/Driver/sycl-offload-static-lib.cpp +++ b/clang/test/Driver/sycl-offload-static-lib.cpp @@ -47,7 +47,7 @@ /// test behaviors of -foffload-static-lib= from source // RUN: touch %t.a -// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -foffload-static-lib=%t.a -ccc-print-phases %s 2>&1 \ +// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -foffload-static-lib=%t.a -ccc-print-phases %s 2>&1 \ // RUN: | FileCheck %s -check-prefix=FOFFLOAD_STATIC_LIB_SRC // FOFFLOAD_STATIC_LIB_SRC: 0: input, "[[INPUTA:.+\.a]]", object, (host-sycl) @@ -122,9 +122,9 @@ /// ########################################################################### /// test behaviors of -foffload-static-lib with no source/object -// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -L/dummy/dir -foffload-static-lib=%t.a -### -ccc-print-phases 2>&1 \ +// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -L/dummy/dir -foffload-static-lib=%t.a -### -ccc-print-phases 2>&1 \ // RUN: | FileCheck %s -check-prefixes=FOFFLOAD_STATIC_LIB_NOSRC_PHASES,FOFFLOAD_STATIC_LIB_NOSRC_PHASES_1 -// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -L/dummy/dir -foffload-whole-static-lib=%t.a -### -ccc-print-phases 2>&1 \ +// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -L/dummy/dir -foffload-whole-static-lib=%t.a -### -ccc-print-phases 2>&1 \ // RUN: | FileCheck %s -check-prefixes=FOFFLOAD_STATIC_LIB_NOSRC_PHASES,FOFFLOAD_STATIC_LIB_NOSRC_PHASES_2 // FOFFLOAD_STATIC_LIB_NOSRC_PHASES: 0: input, "[[INPUTA:.+\.a]]", object, (host-sycl) // FOFFLOAD_STATIC_LIB_NOSRC_PHASES: 1: linker, {0}, image, (host-sycl) diff --git a/clang/test/Driver/sycl-offload-win.c b/clang/test/Driver/sycl-offload-win.c index 4d2ab26532a27..3129876c02b14 100644 --- a/clang/test/Driver/sycl-offload-win.c +++ b/clang/test/Driver/sycl-offload-win.c @@ -57,9 +57,9 @@ /// Test behaviors of -foffload-static-lib= from source. // RUN: touch %t.lib -// RUN: %clang --target=x86_64-pc-windows-msvc -fsycl -foffload-static-lib=%t.lib -ccc-print-phases %s 2>&1 \ +// RUN: %clang --target=x86_64-pc-windows-msvc -fsycl -fno-sycl-device-lib=all -foffload-static-lib=%t.lib -ccc-print-phases %s 2>&1 \ // RUN: | FileCheck -DLIB=%t.lib %s -check-prefix=FOFFLOAD_STATIC_LIB_SRC -// RUN: %clang_cl --target=x86_64-pc-windows-msvc -fsycl -foffload-static-lib=%t.lib -ccc-print-phases %s 2>&1 \ +// RUN: %clang_cl --target=x86_64-pc-windows-msvc -fsycl -fno-sycl-device-lib=all -foffload-static-lib=%t.lib -ccc-print-phases %s 2>&1 \ // RUN: | FileCheck -DLIB=%t.lib %s -check-prefix=FOFFLOAD_STATIC_LIB_SRC // FOFFLOAD_STATIC_LIB_SRC: 0: input, "[[INPUTLIB:.+\.lib]]", object, (host-sycl) diff --git a/clang/test/Driver/sycl-offload-with-split.c b/clang/test/Driver/sycl-offload-with-split.c index 4d01f4d5fb800..b8eb462f6448c 100644 --- a/clang/test/Driver/sycl-offload-with-split.c +++ b/clang/test/Driver/sycl-offload-with-split.c @@ -12,17 +12,17 @@ /// preprocessor and another one joining the device linking outputs to the host /// action. The same graph should be generated when no -fsycl-targets is used /// The same phase graph will be used with -fsycl-use-bitcode -// RUN: %clang -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -fsycl-device-code-split -fsycl-targets=spir64-unknown-unknown-sycldevice %s 2>&1 \ +// RUN: %clang -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-device-code-split -fsycl-targets=spir64-unknown-unknown-sycldevice %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-PHASES,CHK-PHASES-DEFAULT-MODE %s -// RUN: %clang_cl -ccc-print-phases -fsycl -fsycl-device-code-split=per_source -fsycl-targets=spir64-unknown-unknown-sycldevice %s 2>&1 \ +// RUN: %clang_cl -ccc-print-phases -fsycl -fno-sycl-device-lib=all -fsycl-device-code-split=per_source -fsycl-targets=spir64-unknown-unknown-sycldevice %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-PHASES,CHK-PHASES-CL-MODE %s -// RUN: %clang -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -fsycl-device-code-split=per_source -fno-sycl-use-bitcode %s 2>&1 \ +// RUN: %clang -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-device-code-split=per_source -fno-sycl-use-bitcode %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-PHASES,CHK-PHASES-DEFAULT-MODE %s -// RUN: %clang_cl -ccc-print-phases -fsycl -fsycl-device-code-split=per_source -fno-sycl-use-bitcode %s 2>&1 \ +// RUN: %clang_cl -ccc-print-phases -fsycl -fno-sycl-device-lib=all -fsycl-device-code-split=per_source -fno-sycl-use-bitcode %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-PHASES,CHK-PHASES-CL-MODE %s -// RUN: %clang -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -fsycl-device-code-split=per_source -fsycl-use-bitcode %s 2>&1 \ +// RUN: %clang -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-device-code-split=per_source -fsycl-use-bitcode %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-PHASES,CHK-PHASES-DEFAULT-MODE %s -// RUN: %clang_cl -ccc-print-phases -fsycl -fsycl-device-code-split=per_source -fsycl-use-bitcode %s 2>&1 \ +// RUN: %clang_cl -ccc-print-phases -fsycl -fno-sycl-device-lib=all -fsycl-device-code-split=per_source -fsycl-use-bitcode %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-PHASES,CHK-PHASES-CL-MODE %s // CHK-PHASES: 0: input, "[[INPUT:.+\.c]]", c, (host-sycl) // CHK-PHASES: 1: preprocessor, {0}, cpp-output, (host-sycl) @@ -49,7 +49,7 @@ /// Check the phases also add a library to make sure it is treated as input by /// the device. -// RUN: %clang -ccc-print-phases -target x86_64-unknown-linux-gnu -lsomelib -fsycl -fsycl-device-code-split -fsycl-targets=spir64-unknown-unknown-sycldevice %s 2>&1 \ +// RUN: %clang -ccc-print-phases -target x86_64-unknown-linux-gnu -lsomelib -fsycl -fno-sycl-device-lib=all -fsycl-device-code-split -fsycl-targets=spir64-unknown-unknown-sycldevice %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-PHASES-LIB %s // CHK-PHASES-LIB: 0: input, "somelib", object, (host-sycl) // CHK-PHASES-LIB: 1: input, "[[INPUT:.+\.c]]", c, (host-sycl) @@ -75,7 +75,7 @@ /// Check the phases when using and multiple source files // RUN: echo " " > %t.c -// RUN: %clang -ccc-print-phases -lsomelib -target x86_64-unknown-linux-gnu -fsycl -fsycl-device-code-split -fsycl-targets=spir64-unknown-unknown-sycldevice %s %t.c 2>&1 \ +// RUN: %clang -ccc-print-phases -lsomelib -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-device-code-split -fsycl-targets=spir64-unknown-unknown-sycldevice %s %t.c 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-PHASES-FILES %s // CHK-PHASES-FILES: 0: input, "somelib", object, (host-sycl) @@ -112,11 +112,11 @@ /// Check separate compilation with offloading - unbundling actions // RUN: touch %t.o -// RUN: %clang -### -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -fsycl-device-code-split -o %t.out -lsomelib -fsycl-targets=spir64-unknown-unknown-sycldevice %t.o 2>&1 \ +// RUN: %clang -### -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-device-code-split -o %t.out -lsomelib -fsycl-targets=spir64-unknown-unknown-sycldevice %t.o 2>&1 \ // RUN: | FileCheck -DINPUT=%t.o -check-prefix=CHK-UBACTIONS %s // RUN: mkdir -p %t_dir // RUN: touch %t_dir/dummy -// RUN: %clang -### -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -fsycl-device-code-split -o %t.out -lsomelib -fsycl-targets=spir64-unknown-unknown-sycldevice %t_dir/dummy 2>&1 \ +// RUN: %clang -### -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-device-code-split -o %t.out -lsomelib -fsycl-targets=spir64-unknown-unknown-sycldevice %t_dir/dummy 2>&1 \ // RUN: | FileCheck -DINPUT=%t_dir/dummy -check-prefix=CHK-UBACTIONS %s // CHK-UBACTIONS: 0: input, "somelib", object, (host-sycl) // CHK-UBACTIONS: 1: input, "[[INPUT]]", object, (host-sycl) @@ -134,7 +134,7 @@ /// Check separate compilation with offloading - unbundling with source // RUN: touch %t.o -// RUN: %clang -### -ccc-print-phases -target x86_64-unknown-linux-gnu -lsomelib -fsycl -fsycl-device-code-split %t.o -fsycl-targets=spir64-unknown-unknown-sycldevice %s 2>&1 \ +// RUN: %clang -### -ccc-print-phases -target x86_64-unknown-linux-gnu -lsomelib -fsycl -fno-sycl-device-lib=all -fsycl-device-code-split %t.o -fsycl-targets=spir64-unknown-unknown-sycldevice %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-UBUACTIONS %s // CHK-UBUACTIONS: 0: input, "somelib", object, (host-sycl) // CHK-UBUACTIONS: 1: input, "[[INPUT1:.+\.o]]", object, (host-sycl) @@ -161,11 +161,11 @@ /// ########################################################################### /// Ahead of Time compilation for fpga, gen, cpu -// RUN: %clang -target x86_64-unknown-linux-gnu -ccc-print-phases -fsycl -fsycl-device-code-split -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice %s 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -ccc-print-phases -fsycl -fno-sycl-device-lib=all -fsycl-device-code-split -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice %s 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-PHASES-AOT,CHK-PHASES-FPGA -// RUN: %clang -target x86_64-unknown-linux-gnu -ccc-print-phases -fsycl -fsycl-device-code-split -fsycl-targets=spir64_gen-unknown-unknown-sycldevice %s 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -ccc-print-phases -fsycl -fno-sycl-device-lib=all -fsycl-device-code-split -fsycl-targets=spir64_gen-unknown-unknown-sycldevice %s 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-PHASES-AOT,CHK-PHASES-GEN -// RUN: %clang -target x86_64-unknown-linux-gnu -ccc-print-phases -fsycl -fsycl-device-code-split -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %s 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -ccc-print-phases -fsycl -fno-sycl-device-lib=all -fsycl-device-code-split -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %s 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-PHASES-AOT,CHK-PHASES-CPU // CHK-PHASES-AOT: 0: input, "[[INPUT:.+\.c]]", c, (host-sycl) // CHK-PHASES-AOT: 1: preprocessor, {0}, cpp-output, (host-sycl) @@ -196,13 +196,13 @@ /// ########################################################################### /// Ahead of Time compilation for fpga, gen, cpu - tool invocation -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fsycl-device-code-split -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice %s -### 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-device-code-split -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice %s -### 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-TOOLS-AOT,CHK-TOOLS-FPGA -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fsycl-device-code-split -fintelfpga %s -### 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-device-code-split -fintelfpga %s -### 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-TOOLS-AOT,CHK-TOOLS-FPGA -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fsycl-device-code-split -fsycl-targets=spir64_gen-unknown-unknown-sycldevice %s -### 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-device-code-split -fsycl-targets=spir64_gen-unknown-unknown-sycldevice %s -### 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-TOOLS-AOT,CHK-TOOLS-GEN -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fsycl-device-code-split -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %s -### 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-device-code-split -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %s -### 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-TOOLS-AOT,CHK-TOOLS-CPU // CHK-TOOLS-AOT: clang{{.*}} "-fsycl-is-device" {{.*}} "-o" "[[OUTPUT1:.+\.bc]]" // CHK-TOOLS-AOT: llvm-link{{.*}} "[[OUTPUT1]]" "-o" "[[OUTPUT2:.+\.bc]]" @@ -226,7 +226,7 @@ /// ########################################################################### /// offload with multiple targets, including AOT -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fsycl-device-code-split -fsycl-targets=spir64-unknown-unknown-sycldevice,spir64_fpga-unknown-unknown-sycldevice,spir64_gen-unknown-unknown-sycldevice -### -ccc-print-phases %s 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-device-code-split -fsycl-targets=spir64-unknown-unknown-sycldevice,spir64_fpga-unknown-unknown-sycldevice,spir64_gen-unknown-unknown-sycldevice -### -ccc-print-phases %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-PHASE-MULTI-TARG %s // CHK-PHASE-MULTI-TARG: 0: input, "[[INPUT:.+\.c]]", c, (host-sycl) // CHK-PHASE-MULTI-TARG: 1: preprocessor, {0}, cpp-output, (host-sycl) diff --git a/clang/test/Driver/sycl-offload.c b/clang/test/Driver/sycl-offload.c index c743f3d8a9996..bc66b16d3f208 100644 --- a/clang/test/Driver/sycl-offload.c +++ b/clang/test/Driver/sycl-offload.c @@ -161,17 +161,17 @@ /// preprocessor and another one joining the device linking outputs to the host /// action. The same graph should be generated when no -fsycl-targets is used /// The same phase graph will be used with -fsycl-use-bitcode -// RUN: %clang -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice %s 2>&1 \ +// RUN: %clang -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice -fno-sycl-device-lib=all %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-PHASES,CHK-PHASES-DEFAULT-MODE %s -// RUN: %clang_cl -ccc-print-phases -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice %s 2>&1 \ +// RUN: %clang_cl -ccc-print-phases -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice -fno-sycl-device-lib=all %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-PHASES,CHK-PHASES-CL-MODE %s -// RUN: %clang -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-use-bitcode %s 2>&1 \ +// RUN: %clang -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-use-bitcode -fno-sycl-device-lib=all %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-PHASES,CHK-PHASES-DEFAULT-MODE %s -// RUN: %clang_cl -ccc-print-phases -fsycl -fno-sycl-use-bitcode %s 2>&1 \ +// RUN: %clang_cl -ccc-print-phases -fsycl -fno-sycl-use-bitcode -fno-sycl-device-lib=all %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-PHASES,CHK-PHASES-CL-MODE %s -// RUN: %clang -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -fsycl-use-bitcode %s 2>&1 \ +// RUN: %clang -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -fsycl-use-bitcode -fno-sycl-device-lib=all %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-PHASES,CHK-PHASES-DEFAULT-MODE %s -// RUN: %clang_cl -ccc-print-phases -fsycl -fsycl-use-bitcode %s 2>&1 \ +// RUN: %clang_cl -ccc-print-phases -fsycl -fsycl-use-bitcode -fno-sycl-device-lib=all %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHK-PHASES,CHK-PHASES-CL-MODE %s // CHK-PHASES: 0: input, "[[INPUT:.+\.c]]", c, (host-sycl) // CHK-PHASES: 1: preprocessor, {0}, cpp-output, (host-sycl) @@ -208,7 +208,7 @@ /// Check the phases also add a library to make sure it is treated as input by /// the device. -// RUN: %clang -ccc-print-phases -target x86_64-unknown-linux-gnu -lsomelib -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice %s 2>&1 \ +// RUN: %clang -ccc-print-phases -target x86_64-unknown-linux-gnu -lsomelib -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice -fno-sycl-device-lib=all %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-PHASES-LIB %s // CHK-PHASES-LIB: 0: input, "somelib", object, (host-sycl) // CHK-PHASES-LIB: 1: input, "[[INPUT:.+\.c]]", c, (host-sycl) @@ -241,7 +241,7 @@ /// Check the phases when using and multiple source files // RUN: echo " " > %t.c -// RUN: %clang -ccc-print-phases -lsomelib -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice %s %t.c 2>&1 \ +// RUN: %clang -ccc-print-phases -lsomelib -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice -fno-sycl-device-lib=all %s %t.c 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-PHASES-FILES %s // CHK-PHASES-FILES: 0: input, "somelib", object, (host-sycl) @@ -296,11 +296,11 @@ /// Check separate compilation with offloading - unbundling actions // RUN: touch %t.o -// RUN: %clang -### -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -o %t.out -lsomelib -fsycl-targets=spir64-unknown-unknown-sycldevice %t.o 2>&1 \ +// RUN: %clang -### -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -o %t.out -lsomelib -fsycl-targets=spir64-unknown-unknown-sycldevice %t.o 2>&1 \ // RUN: | FileCheck -DINPUT=%t.o -check-prefix=CHK-UBACTIONS %s // RUN: mkdir -p %t_dir // RUN: touch %t_dir/dummy -// RUN: %clang -### -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -o %t.out -lsomelib -fsycl-targets=spir64-unknown-unknown-sycldevice %t_dir/dummy 2>&1 \ +// RUN: %clang -### -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -o %t.out -lsomelib -fsycl-targets=spir64-unknown-unknown-sycldevice %t_dir/dummy 2>&1 \ // RUN: | FileCheck -DINPUT=%t_dir/dummy -check-prefix=CHK-UBACTIONS %s // CHK-UBACTIONS: 0: input, "somelib", object, (host-sycl) // CHK-UBACTIONS: 1: input, "[[INPUT]]", object, (host-sycl) @@ -318,7 +318,7 @@ /// Check separate compilation with offloading - unbundling with source // RUN: touch %t.o -// RUN: %clang -### -ccc-print-phases -target x86_64-unknown-linux-gnu -lsomelib -fsycl %t.o -fsycl-targets=spir64-unknown-unknown-sycldevice %s 2>&1 \ +// RUN: %clang -### -ccc-print-phases -target x86_64-unknown-linux-gnu -lsomelib -fsycl -fno-sycl-device-lib=all %t.o -fsycl-targets=spir64-unknown-unknown-sycldevice %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-UBUACTIONS %s // CHK-UBUACTIONS: 0: input, "somelib", object, (host-sycl) // CHK-UBUACTIONS: 1: input, "[[INPUT1:.+\.o]]", object, (host-sycl) @@ -508,7 +508,7 @@ /// Check regular offload with an additional AOT binary passed through -fsycl-add-targets (same triple) -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice -fsycl-add-targets=spir64-unknown-unknown-sycldevice:dummy.spv -ccc-print-phases %s 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-targets=spir64-unknown-unknown-sycldevice -fsycl-add-targets=spir64-unknown-unknown-sycldevice:dummy.spv -ccc-print-phases %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-ADD-TARGETS-REG %s // CHK-ADD-TARGETS-REG: 0: input, "[[INPUT:.+\.c]]", c, (host-sycl) // CHK-ADD-TARGETS-REG: 1: preprocessor, {0}, cpp-output, (host-sycl) @@ -534,7 +534,7 @@ /// ########################################################################### /// Check regular offload with multiple additional AOT binaries passed through -fsycl-add-targets -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice -fsycl-add-targets=spir64_fpga-unknown-unknown-sycldevice:dummy.aocx,spir64_gen-unknown-unknown-sycldevice:dummy_Gen9core.bin,spir64_x86_64-unknown-unknown-sycldevice:dummy.ir -ccc-print-phases %s 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-targets=spir64-unknown-unknown-sycldevice -fsycl-add-targets=spir64_fpga-unknown-unknown-sycldevice:dummy.aocx,spir64_gen-unknown-unknown-sycldevice:dummy_Gen9core.bin,spir64_x86_64-unknown-unknown-sycldevice:dummy.ir -ccc-print-phases %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-ADD-TARGETS-REG-MUL %s // CHK-ADD-TARGETS-REG-MUL: 0: input, "[[INPUT:.+\.c]]", c, (host-sycl) // CHK-ADD-TARGETS-REG-MUL: 1: preprocessor, {0}, cpp-output, (host-sycl) @@ -609,11 +609,11 @@ /// ########################################################################### /// Ahead of Time compilation for fpga, gen, cpu -// RUN: %clang -target x86_64-unknown-linux-gnu -ccc-print-phases -fsycl -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice %s 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -ccc-print-phases -fsycl -fno-sycl-device-lib=all -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice %s 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-PHASES-AOT,CHK-PHASES-FPGA -// RUN: %clang -target x86_64-unknown-linux-gnu -ccc-print-phases -fsycl -fsycl-targets=spir64_gen-unknown-unknown-sycldevice %s 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -ccc-print-phases -fsycl -fno-sycl-device-lib=all -fsycl-targets=spir64_gen-unknown-unknown-sycldevice %s 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-PHASES-AOT,CHK-PHASES-GEN -// RUN: %clang -target x86_64-unknown-linux-gnu -ccc-print-phases -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %s 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -ccc-print-phases -fsycl -fno-sycl-device-lib=all -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %s 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-PHASES-AOT,CHK-PHASES-CPU // CHK-PHASES-AOT: 0: input, "[[INPUT:.+\.c]]", c, (host-sycl) // CHK-PHASES-AOT: 1: preprocessor, {0}, cpp-output, (host-sycl) @@ -642,29 +642,29 @@ /// ########################################################################### /// Ahead of Time compilation for fpga, gen, cpu - tool invocation -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice %s -### 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice %s -### 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-TOOLS-AOT,CHK-TOOLS-FPGA,CHK-TOOLS-FPGA-USM-DISABLE -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fintelfpga %s -### 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fintelfpga %s -### 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-TOOLS-AOT,CHK-TOOLS-FPGA,CHK-TOOLS-FPGA-USM-DISABLE -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice -Xshardware %s -### 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice -Xshardware %s -### 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-TOOLS-AOT,CHK-TOOLS-FPGA,CHK-TOOLS-FPGA-USM-ENABLE -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -Xshardware %s -### 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fintelfpga -Xshardware %s -### 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-TOOLS-AOT,CHK-TOOLS-FPGA,CHK-TOOLS-FPGA-USM-ENABLE -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice -Xssimulation %s -### 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice -Xssimulation %s -### 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-TOOLS-AOT,CHK-TOOLS-FPGA,CHK-TOOLS-FPGA-USM-ENABLE -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -Xssimulation %s -### 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fintelfpga -Xssimulation %s -### 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-TOOLS-AOT,CHK-TOOLS-FPGA,CHK-TOOLS-FPGA-USM-ENABLE -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice -Xsemulator %s -### 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice -Xsemulator %s -### 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-TOOLS-AOT,CHK-TOOLS-FPGA,CHK-TOOLS-FPGA-USM-DISABLE -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -Xsemulator %s -### 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fintelfpga -Xsemulator %s -### 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-TOOLS-AOT,CHK-TOOLS-FPGA,CHK-TOOLS-FPGA-USM-DISABLE -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64_gen-unknown-unknown-sycldevice %s -### 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-targets=spir64_gen-unknown-unknown-sycldevice %s -### 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-TOOLS-AOT,CHK-TOOLS-GEN -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %s -### 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %s -### 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-TOOLS-AOT,CHK-TOOLS-CPU -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64_gen-unknown-unknown-sycldevice %s -### 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-targets=spir64_gen-unknown-unknown-sycldevice %s -### 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-TOOLS-AOT,CHK-TOOLS-GEN -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %s -### 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %s -### 2>&1 \ // RUN: | FileCheck %s -check-prefixes=CHK-TOOLS-AOT,CHK-TOOLS-CPU // CHK-TOOLS-AOT: clang{{.*}} "-fsycl-is-device" {{.*}} "-o" "[[OUTPUT1:.+\.bc]]" // CHK-TOOLS-AOT: llvm-link{{.*}} "[[OUTPUT1]]" "-o" "[[OUTPUT2:.+\.bc]]" @@ -774,7 +774,7 @@ /// ########################################################################### /// offload with multiple targets, including AOT -// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice,spir64_fpga-unknown-unknown-sycldevice,spir64_gen-unknown-unknown-sycldevice -### -ccc-print-phases %s 2>&1 \ +// RUN: %clang -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all -fsycl-targets=spir64-unknown-unknown-sycldevice,spir64_fpga-unknown-unknown-sycldevice,spir64_gen-unknown-unknown-sycldevice -### -ccc-print-phases %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-PHASE-MULTI-TARG %s // CHK-PHASE-MULTI-TARG: 0: input, "[[INPUT:.+\.c]]", c, (host-sycl) // CHK-PHASE-MULTI-TARG: 1: preprocessor, {0}, cpp-output, (host-sycl) @@ -813,9 +813,9 @@ /// ########################################################################### /// Verify that -save-temps does not crash -// RUN: %clang -fsycl -target x86_64-unknown-linux-gnu -save-temps %s -### 2>&1 -// RUN: %clang -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice -target x86_64-unknown-linux-gnu -save-temps %s -### 2>&1 -// RUN: %clangxx -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice -target x86_64-unknown-linux-gnu -save-temps %s -### 2>&1 \ +// RUN: %clang -fsycl -fno-sycl-device-lib=all -target x86_64-unknown-linux-gnu -save-temps %s -### 2>&1 +// RUN: %clang -fsycl -fno-sycl-device-lib=all -fsycl-targets=spir64-unknown-unknown-sycldevice -target x86_64-unknown-linux-gnu -save-temps %s -### 2>&1 +// RUN: %clangxx -fsycl -fno-sycl-device-lib=all -fsycl-targets=spir64-unknown-unknown-sycldevice -target x86_64-unknown-linux-gnu -save-temps %s -### 2>&1 \ // RUN: | FileCheck %s --check-prefixes=CHK-FSYCL-SAVE-TEMPS,CHK-FSYCL-SAVE-TEMPS-CONFL // CHK-FSYCL-SAVE-TEMPS: clang{{.*}} "-fsycl-is-device"{{.*}} "-o" "[[DEVICE_BASE_NAME:[a-z0-9-]+]].ii" // CHK-FSYCL-SAVE-TEMPS: clang{{.*}} "-fsycl-is-device"{{.*}} "-o" "[[DEVICE_BASE_NAME]].bc"{{.*}} "[[DEVICE_BASE_NAME]].ii" @@ -847,9 +847,9 @@ /// passing of a library should not trigger the unbundler // RUN: touch %t.a // RUN: touch %t.lib -// RUN: %clang -ccc-print-phases -fsycl %t.a %s 2>&1 \ +// RUN: %clang -ccc-print-phases -fsycl -fno-sycl-device-lib=all %t.a %s 2>&1 \ // RUN: | FileCheck -check-prefix=LIB-UNBUNDLE-CHECK %s -// RUN: %clang_cl -ccc-print-phases -fsycl %t.lib %s 2>&1 \ +// RUN: %clang_cl -ccc-print-phases -fsycl -fno-sycl-device-lib=all %t.lib %s 2>&1 \ // RUN: | FileCheck -check-prefix=LIB-UNBUNDLE-CHECK %s // LIB-UNBUNDLE-CHECK-NOT: clang-offload-unbundler From a1bca2791e9e75ab3c3556c867c1294b8c829507 Mon Sep 17 00:00:00 2001 From: gejin Date: Thu, 3 Sep 2020 17:01:04 +0800 Subject: [PATCH 05/14] Use correct option value for devicelib test Signed-off-by: gejin --- sycl/test/devicelib/cmath_fp64_test.cpp | 2 +- sycl/test/devicelib/math_fp64_test.cpp | 2 +- sycl/test/devicelib/math_fp64_windows_test.cpp | 2 +- sycl/test/devicelib/std_complex_math_fp64_test.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sycl/test/devicelib/cmath_fp64_test.cpp b/sycl/test/devicelib/cmath_fp64_test.cpp index 52d9d59aa5baf..53a1a57df3c41 100644 --- a/sycl/test/devicelib/cmath_fp64_test.cpp +++ b/sycl/test/devicelib/cmath_fp64_test.cpp @@ -1,5 +1,5 @@ // UNSUPPORTED: windows -// RUN: %clangxx -fsycl -fsycl-device-lib=fp64 %s -o %t.out +// RUN: %clangxx -fsycl -fsycl-device-lib=libm-fp64 %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out diff --git a/sycl/test/devicelib/math_fp64_test.cpp b/sycl/test/devicelib/math_fp64_test.cpp index 23c81033e9ea4..734844752377a 100644 --- a/sycl/test/devicelib/math_fp64_test.cpp +++ b/sycl/test/devicelib/math_fp64_test.cpp @@ -1,5 +1,5 @@ // REQUIRES: cpu, linux -// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %clangxx -fsycl -fsycl-device-lib=libm-fp64 %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out diff --git a/sycl/test/devicelib/math_fp64_windows_test.cpp b/sycl/test/devicelib/math_fp64_windows_test.cpp index c0b7ad487d2c3..c762357614e4e 100644 --- a/sycl/test/devicelib/math_fp64_windows_test.cpp +++ b/sycl/test/devicelib/math_fp64_windows_test.cpp @@ -1,5 +1,5 @@ // REQUIRES: cpu, windows -// RUN: %clangxx -fsycl -fsycl-device-lib=fp64 %s -o %t.out +// RUN: %clangxx -fsycl -fsycl-device-lib=libm-fp64 %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out diff --git a/sycl/test/devicelib/std_complex_math_fp64_test.cpp b/sycl/test/devicelib/std_complex_math_fp64_test.cpp index 85de5436a5ebc..cd474a3365b5e 100644 --- a/sycl/test/devicelib/std_complex_math_fp64_test.cpp +++ b/sycl/test/devicelib/std_complex_math_fp64_test.cpp @@ -1,5 +1,5 @@ // UNSUPPORTED: windows -// RUN: %clangxx -fsycl -fsycl-device-lib=fp64 %s -o %t.out +// RUN: %clangxx -fsycl -fsycl-device-lib=libm-fp64 %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out From dfc2fff11ac709a91aebb917ed09fd59a16c0e33 Mon Sep 17 00:00:00 2001 From: gejin Date: Thu, 3 Sep 2020 21:03:18 +0800 Subject: [PATCH 06/14] Fix aot lit test Signed-off-by: gejin --- sycl/test/devicelib/cmath-aot.cpp | 4 ++-- sycl/test/devicelib/complex-fpga.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sycl/test/devicelib/cmath-aot.cpp b/sycl/test/devicelib/cmath-aot.cpp index 18ac5095bd074..4eee5f65b221b 100644 --- a/sycl/test/devicelib/cmath-aot.cpp +++ b/sycl/test/devicelib/cmath-aot.cpp @@ -4,11 +4,11 @@ // RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %S/cmath_test.cpp -o %t.cmath.out // RUN: %CPU_RUN_PLACEHOLDER %t.cmath.out -// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %S/cmath_fp64_test.cpp -o %t.cmath.fp64.out +// RUN: %clangxx -fsycl -fsycl-device-lib=libm-fp64 -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %S/cmath_fp64_test.cpp -o %t.cmath.fp64.out // RUN: %CPU_RUN_PLACEHOLDER %t.cmath.fp64.out // RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %S/std_complex_math_test.cpp -o %t.complex.out // RUN: %CPU_RUN_PLACEHOLDER %t.complex.out -// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %S/std_complex_math_fp64_test.cpp -o %t.complex.fp64.out +// RUN: %clangxx -fsycl -fsycl-device-lib=libm-fp64 -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %S/std_complex_math_fp64_test.cpp -o %t.complex.fp64.out // RUN: %CPU_RUN_PLACEHOLDER %t.complex.fp64.out diff --git a/sycl/test/devicelib/complex-fpga.cpp b/sycl/test/devicelib/complex-fpga.cpp index 4d9e4db39e84b..aa01ee0a98de0 100644 --- a/sycl/test/devicelib/complex-fpga.cpp +++ b/sycl/test/devicelib/complex-fpga.cpp @@ -5,7 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===------------------------------------------------------------------------===// - +// UNSUPPORTED: windows // REQUIRES: aoc, accelerator // RUN: %clangxx -fsycl -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice %S/std_complex_math_test.cpp -o %t.out From 640ba0d8fb4ca04e473a8af8803c3becb64c22fb Mon Sep 17 00:00:00 2001 From: gejin Date: Fri, 4 Sep 2020 15:54:57 +0800 Subject: [PATCH 07/14] Add Driver Lit tests for -f[no-]sycl-device-lib option Signed-off-by: gejin --- clang/test/Driver/sycl-device-lib-win.cpp | 93 +++++++++++++++++++++++ clang/test/Driver/sycl-device-lib.cpp | 93 +++++++++++++++++++++++ 2 files changed, 186 insertions(+) create mode 100644 clang/test/Driver/sycl-device-lib-win.cpp create mode 100644 clang/test/Driver/sycl-device-lib.cpp diff --git a/clang/test/Driver/sycl-device-lib-win.cpp b/clang/test/Driver/sycl-device-lib-win.cpp new file mode 100644 index 0000000000000..22147a977e4c5 --- /dev/null +++ b/clang/test/Driver/sycl-device-lib-win.cpp @@ -0,0 +1,93 @@ +/// +/// Perform several driver tests for SYCL device libraries on Windows +/// +// REQUIRES: clang-driver, windows + +/// ########################################################################### + +/// test behavior of device library default link +// RUN: %clangxx -fsycl %s -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libm-fp32 -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,libm-fp32 -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libm-fp64 -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT +// SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-msvc.o" "-outputs={{.*}}libsycl-msvc-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-complex.o" "-outputs={{.*}}libsycl-complex-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-cmath.o" "-outputs={{.*}}libsycl-cmath-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cassert.o" "-outputs={{.*}}libsycl-fallback-cassert-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-complex.o" "-outputs={{.*}}libsycl-fallback-complex-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cmath.o" "-outputs={{.*}}libsycl-fallback-cmath-{{.*}}.o" "-unbundle" + +/// ########################################################################### +/// test behavior of device library link with libm-fp64 +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libm-fp64 -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64 +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,libm-fp64 -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64 +// RUN: %clangxx -fsycl %s -fsycl-device-lib=all -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64 +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,libm-fp32,libm-fp64 -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64 +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,all -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64 +// SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-msvc.o" "-outputs={{.*}}libsycl-msvc-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-complex.o" "-outputs={{.*}}libsycl-complex-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-complex-fp64.o" "-outputs={{.*}}libsycl-complex-fp64-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-cmath.o" "-outputs={{.*}}libsycl-cmath-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-cmath-fp64.o" "-outputs={{.*}}libsycl-cmath-fp64-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cassert.o" "-outputs={{.*}}libsycl-fallback-cassert-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-complex.o" "-outputs={{.*}}libsycl-fallback-complex-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-complex-fp64.o" "-outputs={{.*}}libsycl-fallback-complex-fp64-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cmath.o" "-outputs={{.*}}libsycl-fallback-cmath-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cmath-fp64.o" "-outputs={{.*}}libsycl-fallback-cmath-fp64-{{.*}}.o" "-unbundle" + +/// ########################################################################### + +/// test behavior of -fno-sycl-device-lib=libc +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBC +// SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBC: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-complex.o" "-outputs={{.*}}libsycl-complex-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBC-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-cmath.o" "-outputs={{.*}}libsycl-cmath-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBC-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-complex.o" "-outputs={{.*}}libsycl-fallback-complex-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBC-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cmath.o" "-outputs={{.*}}libsycl-fallback-cmath-{{.*}}.o" "-unbundle" + +/// ########################################################################### + +/// test behavior of -fno-sycl-device-lib=libm-fp32 +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libm-fp32 -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBM_FP32 +// SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBM_FP32: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-msvc.o" "-outputs={{.*}}libsycl-msvc-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBM_FP32-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cassert.o" "-outputs={{.*}}libsycl-fallback-cassert-{{.*}}.o" "-unbundle" + +/// ########################################################################### + +/// test behavior of disabling all device libraries +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc,libm-fp32 -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=all -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc,all -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libm-fp32,all -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libm-fp64,all -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc,all,libm-fp64,libm-fp32 -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB +// SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB: {{.*}}clang{{.*}} "-cc1" "-triple" "spir64-unknown-unknown-sycldevice" +// SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB-NEXT: {{.*}}llvm-link{{.*}} {{.*}} "--suppress-warnings" + +/// ########################################################################### + +/// test invalid value for -f[no-]sycl-device-lib +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,dummy -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_INVALID_VALUE +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=dummy,libm-fp32 -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_NO_DEVICE_LIB_INVALID_VALUE +// SYCL_DEVICE_LIB_INVALID_VALUE: error: unsupported argument 'dummy' to option 'fsycl-device-lib=' +// SYCL_NO_DEVICE_LIB_INVALID_VALUE: error: unsupported argument 'dummy' to option 'fno-sycl-device-lib=' diff --git a/clang/test/Driver/sycl-device-lib.cpp b/clang/test/Driver/sycl-device-lib.cpp new file mode 100644 index 0000000000000..7365d4f4948f7 --- /dev/null +++ b/clang/test/Driver/sycl-device-lib.cpp @@ -0,0 +1,93 @@ +/// +/// Perform several driver tests for SYCL device libraries on Linux +/// +// REQUIRES: clang-driver, linux + +/// ########################################################################### + +/// test behavior of device library default link +// RUN: %clangxx -fsycl %s -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libm-fp32 -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,libm-fp32 -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libm-fp64 -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT +// SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-glibc.o" "-outputs={{.*}}libsycl-glibc-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-complex.o" "-outputs={{.*}}libsycl-complex-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-cmath.o" "-outputs={{.*}}libsycl-cmath-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cassert.o" "-outputs={{.*}}libsycl-fallback-cassert-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-complex.o" "-outputs={{.*}}libsycl-fallback-complex-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cmath.o" "-outputs={{.*}}libsycl-fallback-cmath-{{.*}}.o" "-unbundle" + +/// ########################################################################### +/// test behavior of device library link with libm-fp64 +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libm-fp64 -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64 +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,libm-fp64 -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64 +// RUN: %clangxx -fsycl %s -fsycl-device-lib=all -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64 +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,libm-fp32,libm-fp64 -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64 +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,all -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64 +// SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-glibc.o" "-outputs={{.*}}libsycl-glibc-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-complex.o" "-outputs={{.*}}libsycl-complex-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-complex-fp64.o" "-outputs={{.*}}libsycl-complex-fp64-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-cmath.o" "-outputs={{.*}}libsycl-cmath-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-cmath-fp64.o" "-outputs={{.*}}libsycl-cmath-fp64-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cassert.o" "-outputs={{.*}}libsycl-fallback-cassert-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-complex.o" "-outputs={{.*}}libsycl-fallback-complex-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-complex-fp64.o" "-outputs={{.*}}libsycl-fallback-complex-fp64-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cmath.o" "-outputs={{.*}}libsycl-fallback-cmath-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cmath-fp64.o" "-outputs={{.*}}libsycl-fallback-cmath-fp64-{{.*}}.o" "-unbundle" + +/// ########################################################################### + +/// test behavior of -fno-sycl-device-lib=libc +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBC +// SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBC: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-complex.o" "-outputs={{.*}}libsycl-complex-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBC-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-cmath.o" "-outputs={{.*}}libsycl-cmath-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBC-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-complex.o" "-outputs={{.*}}libsycl-fallback-complex-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBC-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cmath.o" "-outputs={{.*}}libsycl-fallback-cmath-{{.*}}.o" "-unbundle" + +/// ########################################################################### + +/// test behavior of -fno-sycl-device-lib=libm-fp32 +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libm-fp32 -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBM_FP32 +// SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBM_FP32: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-glibc.o" "-outputs={{.*}}libsycl-glibc-{{.*}}.o" "-unbundle" +// SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBM_FP32-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cassert.o" "-outputs={{.*}}libsycl-fallback-cassert-{{.*}}.o" "-unbundle" + +/// ########################################################################### + +/// test behavior of disabling all device libraries +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc,libm-fp32 -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=all -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc,all -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libm-fp32,all -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libm-fp64,all -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=libc,all,libm-fp64,libm-fp32 -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB +// SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB: {{.*}}clang{{.*}} "-cc1" "-triple" "spir64-unknown-unknown-sycldevice" +// SYCL_DEVICE_LIB_UNBUNDLE_NO_DEVICE_LIB-NEXT: {{.*}}llvm-link{{.*}} {{.*}} "--suppress-warnings" + +/// ########################################################################### + +/// test invalid value for -f[no-]sycl-device-lib +// RUN: %clangxx -fsycl %s -fsycl-device-lib=libc,dummy -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_INVALID_VALUE +// RUN: %clangxx -fsycl %s -fno-sycl-device-lib=dummy,libm-fp32 -### 2>&1 \ +// RUN: | FileCheck %s -check-prefix=SYCL_NO_DEVICE_LIB_INVALID_VALUE +// SYCL_DEVICE_LIB_INVALID_VALUE: error: unsupported argument 'dummy' to option 'fsycl-device-lib=' +// SYCL_NO_DEVICE_LIB_INVALID_VALUE: error: unsupported argument 'dummy' to option 'fno-sycl-device-lib=' From d184db2f7511cadbfe3dbcb05f3047eb6a41a498 Mon Sep 17 00:00:00 2001 From: gejin Date: Fri, 4 Sep 2020 17:03:18 +0800 Subject: [PATCH 08/14] enable device lib test for gpu device Signed-off-by: gejin --- sycl/test/devicelib/cmath_fp64_test.cpp | 2 ++ sycl/test/devicelib/cmath_test.cpp | 2 ++ sycl/test/devicelib/math_fp64_test.cpp | 3 ++- sycl/test/devicelib/math_fp64_windows_test.cpp | 3 ++- sycl/test/devicelib/math_test.cpp | 3 ++- sycl/test/devicelib/math_windows_test.cpp | 3 ++- sycl/test/devicelib/std_complex_math_fp64_test.cpp | 2 ++ sycl/test/devicelib/std_complex_math_test.cpp | 2 ++ 8 files changed, 16 insertions(+), 4 deletions(-) diff --git a/sycl/test/devicelib/cmath_fp64_test.cpp b/sycl/test/devicelib/cmath_fp64_test.cpp index 53a1a57df3c41..dfaea37c093e2 100644 --- a/sycl/test/devicelib/cmath_fp64_test.cpp +++ b/sycl/test/devicelib/cmath_fp64_test.cpp @@ -1,6 +1,8 @@ // UNSUPPORTED: windows +// REQUIRES: cpu, gpu, accelerator // RUN: %clangxx -fsycl -fsycl-device-lib=libm-fp64 %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out +// RUN: %GPU_RUN_PLACEHOLDER %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out #include diff --git a/sycl/test/devicelib/cmath_test.cpp b/sycl/test/devicelib/cmath_test.cpp index ffb4fc039b54b..df45d02ef30d7 100644 --- a/sycl/test/devicelib/cmath_test.cpp +++ b/sycl/test/devicelib/cmath_test.cpp @@ -1,6 +1,8 @@ // UNSUPPORTED: windows +// REQUIRES: cpu, gpu, accelerator // RUN: %clangxx -fsycl %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out +// RUN: %GPU_RUN_PLACEHOLDER %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out #include diff --git a/sycl/test/devicelib/math_fp64_test.cpp b/sycl/test/devicelib/math_fp64_test.cpp index 734844752377a..c426f81f822d7 100644 --- a/sycl/test/devicelib/math_fp64_test.cpp +++ b/sycl/test/devicelib/math_fp64_test.cpp @@ -1,6 +1,7 @@ -// REQUIRES: cpu, linux +// REQUIRES: cpu, gpu, accelerator, linux // RUN: %clangxx -fsycl -fsycl-device-lib=libm-fp64 %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out +// RUN: %GPU_RUN_PLACEHOLDER %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out #include "math_utils.hpp" diff --git a/sycl/test/devicelib/math_fp64_windows_test.cpp b/sycl/test/devicelib/math_fp64_windows_test.cpp index c762357614e4e..c5b45d641946d 100644 --- a/sycl/test/devicelib/math_fp64_windows_test.cpp +++ b/sycl/test/devicelib/math_fp64_windows_test.cpp @@ -1,6 +1,7 @@ -// REQUIRES: cpu, windows +// REQUIRES: cpu, gpu, accelerator, windows // RUN: %clangxx -fsycl -fsycl-device-lib=libm-fp64 %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out +// RUN: %GPU_RUN_PLACEHOLDER %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out #include "math_utils.hpp" diff --git a/sycl/test/devicelib/math_test.cpp b/sycl/test/devicelib/math_test.cpp index 8394874b7b76c..c9ae975401231 100644 --- a/sycl/test/devicelib/math_test.cpp +++ b/sycl/test/devicelib/math_test.cpp @@ -1,6 +1,7 @@ -// REQUIRES: cpu, linux +// REQUIRES: cpu, gpu, accelerator, linux // RUN: %clangxx -fsycl %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out +// RUN: %GPU_RUN_PLACEHOLDER %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out #include "math_utils.hpp" diff --git a/sycl/test/devicelib/math_windows_test.cpp b/sycl/test/devicelib/math_windows_test.cpp index 964db574beec5..dd12cbe5596da 100644 --- a/sycl/test/devicelib/math_windows_test.cpp +++ b/sycl/test/devicelib/math_windows_test.cpp @@ -1,6 +1,7 @@ -// REQUIRES: cpu, windows +// REQUIRES: cpu, gpu, windows, accelerator // RUN: %clangxx -fsycl %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out +// RUN: %GPU_RUN_PLACEHOLDER %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out #include "math_utils.hpp" diff --git a/sycl/test/devicelib/std_complex_math_fp64_test.cpp b/sycl/test/devicelib/std_complex_math_fp64_test.cpp index cd474a3365b5e..0e69e03e90ef4 100644 --- a/sycl/test/devicelib/std_complex_math_fp64_test.cpp +++ b/sycl/test/devicelib/std_complex_math_fp64_test.cpp @@ -1,6 +1,8 @@ // UNSUPPORTED: windows +// REQUIRES: cpu, gpu, accelerator // RUN: %clangxx -fsycl -fsycl-device-lib=libm-fp64 %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out +// RUN: %GPU_RUN_PLACEHOLDER %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out diff --git a/sycl/test/devicelib/std_complex_math_test.cpp b/sycl/test/devicelib/std_complex_math_test.cpp index fb6b1feaf1319..711ba7ce8b2f2 100644 --- a/sycl/test/devicelib/std_complex_math_test.cpp +++ b/sycl/test/devicelib/std_complex_math_test.cpp @@ -1,6 +1,8 @@ // UNSUPPORTED: windows +// REQUIRES: cpu, gpu, accelerator // RUN: %clangxx -fsycl %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out +// RUN: %GPU_RUN_PLACEHOLDER %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out From 7803a86096eee96252f40893927c0b78ae5a606d Mon Sep 17 00:00:00 2001 From: gejin Date: Mon, 7 Sep 2020 12:35:47 +0800 Subject: [PATCH 09/14] update helper text for -f[no-]sycl-device-lib Signed-off-by: gejin --- clang/include/clang/Driver/Options.td | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 11379e1f956fc..5ad9145fc59f2 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3562,12 +3562,12 @@ def fno_sycl_dead_args_optimization : Flag<["-"], "fno-sycl-dead-args-optimizati Group, Flags<[NoArgumentUnused, CoreOption]>, HelpText<"Disables " "elimination of DPC++ dead kernel arguments">; def fsycl_device_lib_EQ : CommaJoined<["-"], "fsycl-device-lib=">, Group, Flags<[DriverOption, CoreOption]>, - Values<"libc, libm-fp32, libm-fp64, all">, HelpText<"Control the addition " - "of device libraries when compiling for other devices. Valid arguments " + Values<"libc, libm-fp32, libm-fp64, all">, HelpText<"Control inclusion of " + "device libraries into device binary linkage. Valid arguments " "are libc, libm-fp32, libm-fp64, all">; def fno_sycl_device_lib_EQ : CommaJoined<["-"], "fno-sycl-device-lib=">, Group, Flags<[DriverOption, CoreOption]>, - Values<"libc, libm-fp32, libm-fp64, all">, HelpText<"Control the deletion" - "of device libraries when compiling for other devices. Valid arguments " + Values<"libc, libm-fp32, libm-fp64, all">, HelpText<"Control exclusion of " + "device libraries from device binary linkage. Valid arguments " "are libc, libm-fp32, libm-fp64, all">; //===----------------------------------------------------------------------===// From fedbeefd867bce82e1b24a436e5e3635fbf08a37 Mon Sep 17 00:00:00 2001 From: gejin Date: Wed, 9 Sep 2020 10:23:18 +0800 Subject: [PATCH 10/14] Adjust devicelib suffix in IsSYCLDeviceLibs Signed-off-by: gejin --- clang/lib/Driver/Driver.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 929bac5b448a9..b3c775a356859 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -2714,11 +2714,13 @@ static SmallVector getLinkerArgs(Compilation &C, return LibArgs; } -static bool IsSYCLDeviceLibObj(std::string ObjFilePath) { +static bool IsSYCLDeviceLibObj(std::string ObjFilePath, bool isMSVCEnv) { StringRef ObjFileName = llvm::sys::path::filename(ObjFilePath); - bool Ret = (ObjFileName.startswith("libsycl-") && ObjFileName.endswith(".o")) - ? true - : false; + StringRef ObjSuffix = isMSVCEnv ? ".obj" : ".o"; + bool Ret = + (ObjFileName.startswith("libsycl-") && ObjFileName.endswith(ObjSuffix)) + ? true + : false; return Ret; } @@ -3799,8 +3801,11 @@ class OffloadingActionBuilder final { return ABRT_Inactive; // For SYCL device libraries, don't need to add them to // FPGAObjectInputs as there is no FPGA dep files inside. + if (Args.hasArg(options::OPT_fintelfpga) && - !IsSYCLDeviceLibObj(FileName)) + !IsSYCLDeviceLibObj(FileName, C.getDefaultToolChain() + .getTriple() + .isWindowsMSVCEnvironment())) FPGAObjectInputs.push_back(IA); } // When creating FPGA device fat objects, all host objects are From ba91f753f05be325c601f4f1c0dd3bf5e5d6d7c9 Mon Sep 17 00:00:00 2001 From: gejin Date: Wed, 9 Sep 2020 17:28:07 +0800 Subject: [PATCH 11/14] remove unnecessary restrictions for devicelib lit tests Signed-off-by: gejin --- sycl/test/devicelib/cmath_fp64_test.cpp | 2 +- sycl/test/devicelib/cmath_test.cpp | 3 +- sycl/test/devicelib/math_fp64_test.cpp | 2 +- .../test/devicelib/math_fp64_windows_test.cpp | 130 ------------------ sycl/test/devicelib/math_test.cpp | 2 +- sycl/test/devicelib/math_windows_test.cpp | 119 ---------------- 6 files changed, 4 insertions(+), 254 deletions(-) delete mode 100644 sycl/test/devicelib/math_fp64_windows_test.cpp delete mode 100644 sycl/test/devicelib/math_windows_test.cpp diff --git a/sycl/test/devicelib/cmath_fp64_test.cpp b/sycl/test/devicelib/cmath_fp64_test.cpp index 141758cfc040c..d1f42613c6c5f 100644 --- a/sycl/test/devicelib/cmath_fp64_test.cpp +++ b/sycl/test/devicelib/cmath_fp64_test.cpp @@ -1,7 +1,7 @@ -// REQUIRES: cpu, linux // RUN: %clangxx -fsycl -fsycl-device-lib=libm-fp64 %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out +// RUN: %ACC_RUN_PLACEHOLDER %t.out #include #include diff --git a/sycl/test/devicelib/cmath_test.cpp b/sycl/test/devicelib/cmath_test.cpp index 67d360190a0a2..6ff06f612c06d 100644 --- a/sycl/test/devicelib/cmath_test.cpp +++ b/sycl/test/devicelib/cmath_test.cpp @@ -1,8 +1,7 @@ -// REQUIRES: cpu, linux // RUN: %clangxx -fsycl %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out - +// RUN: %ACC_RUN_PLACEHOLDER %t.out #include #include #include diff --git a/sycl/test/devicelib/math_fp64_test.cpp b/sycl/test/devicelib/math_fp64_test.cpp index 4c91feba5a45b..7f17fe63b3d01 100644 --- a/sycl/test/devicelib/math_fp64_test.cpp +++ b/sycl/test/devicelib/math_fp64_test.cpp @@ -1,7 +1,7 @@ -// REQUIRES: cpu, linux // RUN: %clangxx -fsycl -fsycl-device-lib=libm-fp64 %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out +// RUN: %ACC_RUN_PLACEHOLDER %t.out #include "math_utils.hpp" #include diff --git a/sycl/test/devicelib/math_fp64_windows_test.cpp b/sycl/test/devicelib/math_fp64_windows_test.cpp deleted file mode 100644 index 8850598c350b6..0000000000000 --- a/sycl/test/devicelib/math_fp64_windows_test.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// REQUIRES: cpu, windows -// RUN: %clangxx -fsycl -fsycl-device-lib=libm-fp64 %s -o %t.out -// RUN: env SYCL_DEVICE_TYPE=HOST %t.out -// RUN: %CPU_RUN_PLACEHOLDER %t.out -#include "math_utils.hpp" -#include -#include -#include - -namespace s = cl::sycl; -constexpr s::access::mode sycl_read = s::access::mode::read; -constexpr s::access::mode sycl_write = s::access::mode::write; - -#define TEST_NUM 41 - -double ref_val[TEST_NUM] = { - 1, 0, 0, 0, 0, 0, 0, 1, 1, 0.5, - 0, 2, 0, 0, 1, 0, 2, 0, 0, 0, - 0, 0, 1, 0, 1, 2, 0, 1, 2, 5, - 0, 0, 0, 0, 0.5, 0.5, NAN, NAN, 1, 2, 0}; - -double refIptr = 1; - -void device_math_test(s::queue &deviceQueue) { - s::range<1> numOfItems{TEST_NUM}; - double result[TEST_NUM] = {-1}; - - // Variable exponent is an integer value to store the exponent in frexp function - int exponent = -1; - - // Variable iptr stores the integral part of float point in modf function - double iptr = -1; - - // Variable quo stores the sign and some bits of x/y in remquo function - int quo = -1; - - // Varaible enm stores the enum value retured by MSVC function - short enm[2] = {10, 10}; - { - s::buffer buffer1(result, numOfItems); - s::buffer buffer2(&exponent, s::range<1>{1}); - s::buffer buffer3(&iptr, s::range<1>{1}); - s::buffer buffer4(&quo, s::range<1>{1}); - s::buffer buffer5(enm, s::range<1>{2}); - deviceQueue.submit([&](cl::sycl::handler &cgh) { - auto res_access = buffer1.template get_access(cgh); - auto exp_access = buffer2.template get_access(cgh); - auto iptr_access = buffer3.template get_access(cgh); - auto quo_access = buffer4.template get_access(cgh); - auto enm_access = buffer5.template get_access(cgh); - cgh.single_task([=]() { - int i = 0; - res_access[i++] = cos(0.0); - res_access[i++] = sin(0.0); - res_access[i++] = log(1.0); - res_access[i++] = acos(1.0); - res_access[i++] = asin(0.0); - res_access[i++] = atan(0.0); - res_access[i++] = atan2(0.0, 1.0); - res_access[i++] = cosh(0.0); - res_access[i++] = exp(0.0); - res_access[i++] = fmod(1.5, 1.0); - res_access[i++] = frexp(0.0, &exp_access[0]); - res_access[i++] = ldexp(1.0, 1); - res_access[i++] = log10(1.0); - res_access[i++] = modf(1.0, &iptr_access[0]); - res_access[i++] = pow(1.0, 1.0); - res_access[i++] = sinh(0.0); - res_access[i++] = sqrt(4.0); - res_access[i++] = tan(0.0); - res_access[i++] = tanh(0.0); - res_access[i++] = acosh(1.0); - res_access[i++] = asinh(0.0); - res_access[i++] = atanh(0.0); - res_access[i++] = cbrt(1.0); - res_access[i++] = erf(0.0); - res_access[i++] = erfc(0.0); - res_access[i++] = exp2(1.0); - res_access[i++] = expm1(0.0); - res_access[i++] = fdim(1.0, 0.0); - res_access[i++] = fma(1.0, 1.0, 1.0); - res_access[i++] = hypot(3.0, 4.0); - res_access[i++] = ilogb(1.0); - res_access[i++] = log1p(0.0); - res_access[i++] = log2(1.0); - res_access[i++] = logb(1.0); - res_access[i++] = remainder(0.5, 1.0); - res_access[i++] = remquo(0.5, 1.0, &quo_access[0]); - double a = NAN; - res_access[i++] = tgamma(a); - res_access[i++] = lgamma(a); - enm_access[0] = _Dtest(&a); - a = 0.0; - enm_access[1] = _Exp(&a, 1.0, 0); - res_access[i++] = a; - res_access[i++] = _Cosh(0.0, 2.0); - res_access[i++] = _Sinh(0.0, 1.0); - }); - }); - } - - // Compare result with reference - for (int i = 0; i < TEST_NUM; ++i) { - assert(approx_equal_fp(result[i], ref_val[i])); - } - - // Test modf integral part - assert(approx_equal_fp(iptr, refIptr)); - - // Test frexp exponent - assert(exponent == 0); - - // Test remquo sign - assert(quo == 0); - - // Test enum value returned by _Dtest - assert(enm[0] == _NANCODE); - - // Test enum value returned by _Exp - assert(enm[1] == _FINITE); -} - -int main() { - s::queue deviceQueue; - if (deviceQueue.get_device().has_extension("cl_khr_fp64")) { - device_math_test(deviceQueue); - std::cout << "Pass" << std::endl; - } - return 0; -} diff --git a/sycl/test/devicelib/math_test.cpp b/sycl/test/devicelib/math_test.cpp index 7d8021bf34e94..d28b86fdc1e50 100644 --- a/sycl/test/devicelib/math_test.cpp +++ b/sycl/test/devicelib/math_test.cpp @@ -1,7 +1,7 @@ -// REQUIRES: cpu, linux // RUN: %clangxx -fsycl %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out +// RUN: %ACC_RUN_PLACEHOLDER %t.out #include "math_utils.hpp" #include diff --git a/sycl/test/devicelib/math_windows_test.cpp b/sycl/test/devicelib/math_windows_test.cpp deleted file mode 100644 index 8665eed1ea61b..0000000000000 --- a/sycl/test/devicelib/math_windows_test.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// REQUIRES: cpu, windows -// RUN: %clangxx -fsycl %s -o %t.out -// RUN: env SYCL_DEVICE_TYPE=HOST %t.out -// RUN: %CPU_RUN_PLACEHOLDER %t.out -#include "math_utils.hpp" -#include -#include -#include - -namespace s = cl::sycl; -constexpr s::access::mode sycl_read = s::access::mode::read; -constexpr s::access::mode sycl_write = s::access::mode::write; - -#define TEST_NUM 39 - -float ref_val[TEST_NUM] = { - 1, 0, 0, 0, 0, 0, 0, 1, 1, 0.5, - 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, - 1, 0, 1, 2, 0, 1, 2, 5, 0, 0, - 0, 0, 0.5, 0.5, NAN, NAN, 1, 2, 0}; - -float refIptr = 1; - -void device_math_test(s::queue &deviceQueue) { - s::range<1> numOfItems{TEST_NUM}; - float result[TEST_NUM] = {-1}; - - // Variable iptr stores the integral part of float point in modf function - float iptr = -1; - - // Variable quo stores the sign and some bits of x/y in remquo function - int quo = -1; - - // Varaible enm stores the enum value retured by MSVC function - short enm[2] = {10, 10}; - - { - s::buffer buffer1(result, numOfItems); - s::buffer buffer2(&iptr, s::range<1>{1}); - s::buffer buffer3(&quo, s::range<1>{1}); - s::buffer buffer4(enm, s::range<1>{2}); - deviceQueue.submit([&](cl::sycl::handler &cgh) { - auto res_access = buffer1.template get_access(cgh); - auto iptr_access = buffer2.template get_access(cgh); - auto quo_access = buffer3.template get_access(cgh); - auto enm_access = buffer4.template get_access(cgh); - cgh.single_task([=]() { - int i = 0; - res_access[i++] = cosf(0.0f); - res_access[i++] = sinf(0.0f); - res_access[i++] = logf(1.0f); - res_access[i++] = acosf(1.0f); - res_access[i++] = asinf(0.0f); - res_access[i++] = atanf(0.0f); - res_access[i++] = atan2f(0.0f, 1.0f); - res_access[i++] = coshf(0.0f); - res_access[i++] = expf(0.0f); - res_access[i++] = fmodf(1.5f, 1.0f); - res_access[i++] = log10f(1.0f); - res_access[i++] = modff(1.0f, &iptr_access[0]); - res_access[i++] = powf(1.0f, 1.0f); - res_access[i++] = sinhf(0.0f); - res_access[i++] = sqrtf(4.0f); - res_access[i++] = tanf(0.0f); - res_access[i++] = tanhf(0.0f); - res_access[i++] = acoshf(1.0f); - res_access[i++] = asinhf(0.0f); - res_access[i++] = atanhf(0.0f); - res_access[i++] = cbrtf(1.0f); - res_access[i++] = erff(0.0f); - res_access[i++] = erfcf(0.0f); - res_access[i++] = exp2f(1.0f); - res_access[i++] = expm1f(0.0f); - res_access[i++] = fdimf(1.0f, 0.0f); - res_access[i++] = fmaf(1.0f, 1.0f, 1.0f); - res_access[i++] = hypotf(3.0f, 4.0f); - res_access[i++] = ilogbf(1.0f); - res_access[i++] = log1pf(0.0f); - res_access[i++] = log2f(1.0f); - res_access[i++] = logbf(1.0f); - res_access[i++] = remainderf(0.5f, 1.0f); - res_access[i++] = remquof(0.5f, 1.0f, &quo_access[0]); - float a = NAN; - res_access[i++] = tgammaf(a); - res_access[i++] = lgammaf(a); - enm_access[0] = _FDtest(&a); - a = 0.0f; - enm_access[1] = _FExp(&a, 1.0f, 0); - res_access[i++] = a; - res_access[i++] = _FCosh(0.0f, 2.0f); - res_access[i++] = _FSinh(0.0f, 1.0f); - }); - }); - } - - // Compare result with reference - for (int i = 0; i < TEST_NUM; ++i) { - assert(approx_equal_fp(result[i], ref_val[i])); - } - - // Test modf integral part - assert(approx_equal_fp(iptr, refIptr)); - - // Test remquo sign - assert(quo == 0); - - // Test enum value returned by _FDtest - assert(enm[0] == _NANCODE); - - // Test enum value returned by _FExp - assert(enm[1] == _FINITE); -} - -int main() { - s::queue deviceQueue; - device_math_test(deviceQueue); - std::cout << "Pass" << std::endl; - return 0; -} From 7a3631076b6bf035f579c541dd5183908287b66e Mon Sep 17 00:00:00 2001 From: gejin Date: Wed, 9 Sep 2020 23:18:08 +0800 Subject: [PATCH 12/14] fix double issue in float test for MSVC Signed-off-by: gejin --- sycl/test/devicelib/cmath_test.cpp | 78 ++++++--- sycl/test/devicelib/math_utils.hpp | 5 + .../devicelib/std_complex_math_fp64_test.cpp | 9 +- sycl/test/devicelib/std_complex_math_test.cpp | 162 +++++++++--------- 4 files changed, 143 insertions(+), 111 deletions(-) diff --git a/sycl/test/devicelib/cmath_test.cpp b/sycl/test/devicelib/cmath_test.cpp index 6ff06f612c06d..e07ac0f55003e 100644 --- a/sycl/test/devicelib/cmath_test.cpp +++ b/sycl/test/devicelib/cmath_test.cpp @@ -2,33 +2,28 @@ // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out + +#include "math_utils.hpp" #include #include #include -#include "math_utils.hpp" namespace s = cl::sycl; constexpr s::access::mode sycl_read = s::access::mode::read; constexpr s::access::mode sycl_write = s::access::mode::write; -#define TEST_NUM 38 +#define TEST_NUM 36 -float ref[TEST_NUM] = { -1, 0, 0, 0, 0, 0, 0, 1, 1, 0.5, -0, 2, 0, 0, 1, 0, 2, 0, 0, 0, -0, 0, 1, 0, 1, 2, 0, 1, 2, 5, -0, 0, 0, 0, 0.5, 0.5, NAN, NAN,}; +float ref[TEST_NUM] = {1, 0, 0, 0, 0, 0, 0, 1, 1, 0.5, 0, 0, + 1, 0, 2, 0, 0, 0, 0, 0, 1, 0, 1, 2, + 0, 1, 2, 5, 0, 0, 0, 0, 0.5, 0.5, NAN, NAN}; float refIptr = 1; -template -void device_cmath_test(s::queue &deviceQueue) { +template void device_cmath_test_1(s::queue &deviceQueue) { s::range<1> numOfItems{TEST_NUM}; T result[TEST_NUM] = {-1}; - // Variable exponent is an integer value to store the exponent in frexp function - int exponent = -1; - // Variable iptr stores the integral part of float point in modf function T iptr = -1; @@ -36,15 +31,13 @@ void device_cmath_test(s::queue &deviceQueue) { int quo = -1; { s::buffer buffer1(result, numOfItems); - s::buffer buffer2(&exponent, s::range<1>{1}); - s::buffer buffer3(&iptr, s::range<1>{1}); - s::buffer buffer4(&quo, s::range<1>{1}); + s::buffer buffer2(&iptr, s::range<1>{1}); + s::buffer buffer3(&quo, s::range<1>{1}); deviceQueue.submit([&](cl::sycl::handler &cgh) { auto res_access = buffer1.template get_access(cgh); - auto exp_access = buffer2.template get_access(cgh); - auto iptr_access = buffer3.template get_access(cgh); - auto quo_access = buffer4.template get_access(cgh); - cgh.single_task([=]() { + auto iptr_access = buffer2.template get_access(cgh); + auto quo_access = buffer3.template get_access(cgh); + cgh.single_task([=]() { int i = 0; res_access[i++] = std::cos(0.0f); res_access[i++] = std::sin(0.0f); @@ -56,8 +49,6 @@ void device_cmath_test(s::queue &deviceQueue) { res_access[i++] = std::cosh(0.0f); res_access[i++] = std::exp(0.0f); res_access[i++] = std::fmod(1.5f, 1.0f); - res_access[i++] = std::frexp(0.0f, &exp_access[0]); - res_access[i++] = std::ldexp(1.0f, 1); res_access[i++] = std::log10(1.0f); res_access[i++] = std::modf(1.0f, &iptr_access[0]); res_access[i++] = std::pow(1.0f, 1.0f); @@ -97,16 +88,53 @@ void device_cmath_test(s::queue &deviceQueue) { // Test modf integral part assert(approx_equal_fp(iptr, refIptr)); - // Test frexp exponent - assert(exponent == 0); - // Test remquo sign assert(quo == 0); } +// MSVC implements std::ldexp and std::frexp by invoking the +// 'double' version of corresponding C math functions(ldexp and frexp). Those +// 2 functions can only work on Windows with fp64 extension support from +// underlying device. +#ifndef _WIN32 +template void device_cmath_test_2(s::queue &deviceQueue) { + s::range<1> numOfItems{2}; + T result[2] = {-1}; + T ref[2] = {0, 2}; + // Variable exponent is an integer value to store the exponent in frexp + // function + int exponent = -1; + + { + s::buffer buffer1(result, numOfItems); + s::buffer buffer2(&exponent, s::range<1>{1}); + deviceQueue.submit([&](cl::sycl::handler &cgh) { + auto res_access = buffer1.template get_access(cgh); + auto exp_access = buffer2.template get_access(cgh); + cgh.single_task([=]() { + int i = 0; + res_access[i++] = std::frexp(0.0f, &exp_access[0]); + res_access[i++] = std::ldexp(1.0f, 1); + }); + }); + } + + // Compare result with reference + for (int i = 0; i < 2; ++i) { + assert(approx_equal_fp(result[i], ref[i])); + } + + // Test frexp exponent + assert(exponent == 0); +} +#endif + int main() { s::queue deviceQueue; - device_cmath_test(deviceQueue); + device_cmath_test_1(deviceQueue); +#ifndef _WIN32 + device_cmath_test_2(deviceQueue); +#endif std::cout << "Pass" << std::endl; return 0; } diff --git a/sycl/test/devicelib/math_utils.hpp b/sycl/test/devicelib/math_utils.hpp index eb4f5cae07007..0e4c045fe208e 100644 --- a/sycl/test/devicelib/math_utils.hpp +++ b/sycl/test/devicelib/math_utils.hpp @@ -1,6 +1,11 @@ #ifndef MATH_UTILS #include #include +// _USE_MATH_DEFINES must be defined in order to use math constants in MSVC +#ifdef _WIN32 +#define _USE_MATH_DEFINES 1 +#include +#endif // Since it is not proper to compare float point using operator ==, this // function measures whether the result of cmath function from kernel is diff --git a/sycl/test/devicelib/std_complex_math_fp64_test.cpp b/sycl/test/devicelib/std_complex_math_fp64_test.cpp index b8c2df0da8cd0..fd609db28b6f7 100644 --- a/sycl/test/devicelib/std_complex_math_fp64_test.cpp +++ b/sycl/test/devicelib/std_complex_math_fp64_test.cpp @@ -1,7 +1,7 @@ -// REQUIRES: cpu, linux // RUN: %clangxx -fsycl -fsycl-device-lib=libm-fp64 %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out +// RUN: %ACC_RUN_PLACEHOLDER %t.out #include #include @@ -15,8 +15,7 @@ namespace s = cl::sycl; constexpr s::access::mode sycl_read = s::access::mode::read; constexpr s::access::mode sycl_write = s::access::mode::write; -template -bool approx_equal_cmplx(complex x, complex y) { +template bool approx_equal_cmplx(complex x, complex y) { return approx_equal_fp(x.real(), y.real()) && approx_equal_fp(x.imag(), y.imag()); } @@ -84,8 +83,8 @@ std::array, TestArraySize1> ref1_results = { complex(M_PI_2, 0.), complex(M_PI_2, 0.549306144334055)}; -std::array ref2_results = {0., 25., 169., INFINITY, 0., - 5., 13., INFINITY, 0., M_PI_2}; +std::array ref2_results = { + 0., 25., 169., INFINITY, 0., 5., 13., INFINITY, 0., M_PI_2}; void device_complex_test(s::queue &deviceQueue) { s::range<1> numOfItems1{TestArraySize1}; diff --git a/sycl/test/devicelib/std_complex_math_test.cpp b/sycl/test/devicelib/std_complex_math_test.cpp index b4ce745109d81..74f63bcf60387 100644 --- a/sycl/test/devicelib/std_complex_math_test.cpp +++ b/sycl/test/devicelib/std_complex_math_test.cpp @@ -1,7 +1,7 @@ -// REQUIRES: cpu, linux // RUN: %clangxx -fsycl %s -o %t.out // RUN: env SYCL_DEVICE_TYPE=HOST %t.out // RUN: %CPU_RUN_PLACEHOLDER %t.out +// RUN: %ACC_RUN_PLACEHOLDER %t.out #include #include @@ -15,79 +15,53 @@ namespace s = cl::sycl; constexpr s::access::mode sycl_read = s::access::mode::read; constexpr s::access::mode sycl_write = s::access::mode::write; -template -bool approx_equal_cmplx(complex x, complex y) { +template bool approx_equal_cmplx(complex x, complex y) { return approx_equal_fp(x.real(), y.real()) && approx_equal_fp(x.imag(), y.imag()); } -static constexpr auto TestArraySize1 = 57; +static constexpr auto TestArraySize1 = 41; static constexpr auto TestArraySize2 = 10; +static constexpr auto TestArraySize3 = 16; std::array, TestArraySize1> ref1_results = { - complex(-1.f, 1.f), - complex(1.f, 3.f), - complex(-2.f, 10.f), - complex(-8.f, 31.f), - complex(1.f, 1.f), - complex(2.f, 1.f), - complex(2.f, 2.f), - complex(3.f, 4.f), - complex(2.f, 1.f), - complex(0.f, 1.f), - complex(2.f, 0.f), - complex(0.f, 0.f), - complex(0.f, 1.f), - complex(1.f, 1.f), - complex(2.f, 0.f), - complex(2.f, 3.f), - complex(1.f, 0.f), - complex(0.f, 1.f), - complex(-1.f, 0.f), - complex(0.f, M_E), - complex(0.f, 0.f), - complex(0.f, M_PI_2), - complex(0.f, M_PI), - complex(1.f, M_PI_2), - complex(0.f, 0.f), - complex(1.f, 0.f), - complex(1.f, 0.f), - complex(-1.f, 0.f), - complex(-INFINITY, 0.f), - complex(1.f, 0.f), - complex(10.f, 0.f), - complex(100.f, 0.f), - complex(200.f, 0.f), - complex(1.f, 2.f), - complex(INFINITY, 0.f), - complex(INFINITY, 0.f), - complex(0.f, 1.f), - complex(M_PI_2, 0.f), - complex(0.f, 0.f), - complex(1.f, 0.f), - complex(INFINITY, 0.f), - complex(0.f, 0.f), - complex(1.f, 0.f), - complex(0.f, 0.f), - complex(INFINITY, M_PI_2), - complex(INFINITY, 0.f), - complex(0.f, M_PI_2), - complex(INFINITY, M_PI_2), - complex(INFINITY, 0.f), - complex(0.f, 0.f), - complex(0.f, M_PI_2), - - complex(1.f, -4.f), - complex(18.f, -7.f), - complex(1.557408f, 0.f), - complex(0.f, 0.761594f), - complex(M_PI_2, 0.f), + complex(-1.f, 1.f), complex(1.f, 3.f), + complex(-2.f, 10.f), complex(-8.f, 31.f), + complex(1.f, 1.f), complex(2.f, 1.f), + complex(2.f, 2.f), complex(3.f, 4.f), + complex(2.f, 1.f), complex(0.f, 1.f), + complex(2.f, 0.f), complex(0.f, 0.f), + complex(1.f, 0.f), complex(0.f, 1.f), + complex(-1.f, 0.f), complex(0.f, M_E), + complex(0.f, 0.f), complex(0.f, M_PI_2), + complex(0.f, M_PI), complex(1.f, M_PI_2), + complex(0.f, 0.f), complex(1.f, 0.f), + complex(1.f, 0.f), complex(-1.f, 0.f), + complex(-INFINITY, 0.f), complex(1.f, 0.f), + complex(10.f, 0.f), complex(100.f, 0.f), + complex(200.f, 0.f), complex(1.f, 2.f), + complex(INFINITY, 0.f), complex(INFINITY, 0.f), + complex(0.f, 1.f), complex(0.f, 0.f), + complex(1.f, 0.f), complex(INFINITY, 0.f), + complex(0.f, 0.f), complex(0.f, M_PI_2), + complex(1.f, -4.f), complex(18.f, -7.f), complex(M_PI_2, 0.549306f)}; -std::array ref2_results = {0.f, 25.f, 169.f, INFINITY, 0.f, - 5.f, 13.f, INFINITY, 0.f, M_PI_2}; +std::array ref2_results = { + 0.f, 25.f, 169.f, INFINITY, 0.f, 5.f, 13.f, INFINITY, 0.f, M_PI_2}; + +std::array, TestArraySize3> ref3_results = { + complex(0.f, 1.f), complex(1.f, 1.f), + complex(2.f, 0.f), complex(2.f, 3.f), + complex(M_PI_2, 0.f), complex(0.f, 0.f), + complex(1.f, 0.f), complex(0.f, 0.f), + complex(INFINITY, M_PI_2), complex(INFINITY, 0.f), + complex(0.f, M_PI_2), complex(INFINITY, M_PI_2), + complex(INFINITY, 0.f), complex(1.557408f, 0.f), + complex(0.f, 0.761594f), complex(M_PI_2, 0.f), -void device_complex_test(s::queue &deviceQueue) { +}; +void device_complex_test_1(s::queue &deviceQueue) { s::range<1> numOfItems1{TestArraySize1}; s::range<1> numOfItems2{TestArraySize2}; std::array, TestArraySize1> result1; @@ -124,10 +98,6 @@ void device_complex_test(s::queue &deviceQueue) { complex(0.f, 10.f) / complex(0.f, 5.f); buf_out1_access[index++] = complex(0.f, 0.f) / complex(1.f, 0.f); - buf_out1_access[index++] = std::sqrt(complex(-1.f, 0.f)); - buf_out1_access[index++] = std::sqrt(complex(0.f, 2.f)); - buf_out1_access[index++] = std::sqrt(complex(4.f, 0.f)); - buf_out1_access[index++] = std::sqrt(complex(-5.f, 12.f)); buf_out1_access[index++] = std::exp(complex(0.f, 0.f)); buf_out1_access[index++] = std::exp(complex(0.f, M_PI_2)); buf_out1_access[index++] = std::exp(complex(0.f, M_PI)); @@ -149,25 +119,13 @@ void device_complex_test(s::queue &deviceQueue) { buf_out1_access[index++] = std::proj(complex(INFINITY, -1.f)); buf_out1_access[index++] = std::proj(complex(0.f, -INFINITY)); buf_out1_access[index++] = std::pow(complex(-1.f, 0.f), 0.5f); - buf_out1_access[index++] = std::acos(complex(0.f, 0.f)); buf_out1_access[index++] = std::sinh(complex(0.f, 0.f)); buf_out1_access[index++] = std::cosh(complex(0.f, 0.f)); buf_out1_access[index++] = std::cosh(complex(INFINITY, 0.f)); - buf_out1_access[index++] = std::tanh(complex(0.f, 0.f)); - buf_out1_access[index++] = std::tanh(complex(INFINITY, 1.f)); - buf_out1_access[index++] = std::asinh(complex(0.f, 0.f)); - buf_out1_access[index++] = std::asinh(complex(1.f, INFINITY)); - buf_out1_access[index++] = std::asinh(complex(INFINITY, 1.f)); - buf_out1_access[index++] = std::acosh(complex(0.f, 0.f)); - buf_out1_access[index++] = std::acosh(complex(1.f, INFINITY)); - buf_out1_access[index++] = std::acosh(complex(INFINITY, 1.f)); buf_out1_access[index++] = std::atanh(complex(0.f, 0.f)); buf_out1_access[index++] = std::atanh(complex(1.f, INFINITY)); buf_out1_access[index++] = std::conj(complex(1.f, 4.f)); buf_out1_access[index++] = std::conj(complex(18.f, 7.f)); - buf_out1_access[index++] = std::tan(complex(1.f, 0.f)); - buf_out1_access[index++] = std::tan(complex(0.f, 1.f)); - buf_out1_access[index++] = std::asin(complex(1.f, 0.f)); buf_out1_access[index++] = std::atan(complex(0.f, 2.f)); index = 0; @@ -193,8 +151,50 @@ void device_complex_test(s::queue &deviceQueue) { } } +// The MSVC implementation of some complex math functions depends on +// some 'double' C math functions such as ldexp, those complex math +// functions can only work on Windows with fp64 extension support from +// underlying device. +#ifndef _WIN32 +void device_complex_test_2(s::queue &deviceQueue) { + s::range<1> numOfItems1{TestArraySize3}; + std::array, TestArraySize3> result3; + { + s::buffer, 1> buffer1(result3.data(), numOfItems1); + deviceQueue.submit([&](s::handler &cgh) { + auto buf_out1_access = buffer1.get_access(cgh); + cgh.single_task([=]() { + int index = 0; + buf_out1_access[index++] = std::sqrt(complex(-1.f, 0.f)); + buf_out1_access[index++] = std::sqrt(complex(0.f, 2.f)); + buf_out1_access[index++] = std::sqrt(complex(4.f, 0.f)); + buf_out1_access[index++] = std::sqrt(complex(-5.f, 12.f)); + buf_out1_access[index++] = std::acos(complex(0.f, 0.f)); + buf_out1_access[index++] = std::tanh(complex(0.f, 0.f)); + buf_out1_access[index++] = std::tanh(complex(INFINITY, 1.f)); + buf_out1_access[index++] = std::asinh(complex(0.f, 0.f)); + buf_out1_access[index++] = std::asinh(complex(1.f, INFINITY)); + buf_out1_access[index++] = std::asinh(complex(INFINITY, 1.f)); + buf_out1_access[index++] = std::acosh(complex(0.f, 0.f)); + buf_out1_access[index++] = std::acosh(complex(1.f, INFINITY)); + buf_out1_access[index++] = std::acosh(complex(INFINITY, 1.f)); + buf_out1_access[index++] = std::tan(complex(1.f, 0.f)); + buf_out1_access[index++] = std::tan(complex(0.f, 1.f)); + buf_out1_access[index++] = std::asin(complex(1.f, 0.f)); + }); + }); + } + + for (size_t idx = 0; idx < TestArraySize3; ++idx) { + assert(approx_equal_cmplx(result3[idx], ref3_results[idx])); + } +} +#endif int main() { s::queue deviceQueue; - device_complex_test(deviceQueue); + device_complex_test_1(deviceQueue); +#ifndef _WIN32 + device_complex_test_2(deviceQueue); +#endif std::cout << "Pass" << std::endl; } From 5aeb56d8f219dc6241052cca0424da688b8de7f0 Mon Sep 17 00:00:00 2001 From: gejin Date: Wed, 9 Sep 2020 23:46:24 +0800 Subject: [PATCH 13/14] remove ldexp/frexp in math test to avoid Windows failure Signed-off-by: gejin --- sycl/test/devicelib/math_test.cpp | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/sycl/test/devicelib/math_test.cpp b/sycl/test/devicelib/math_test.cpp index d28b86fdc1e50..38d9a8f081bd9 100644 --- a/sycl/test/devicelib/math_test.cpp +++ b/sycl/test/devicelib/math_test.cpp @@ -12,13 +12,11 @@ namespace s = cl::sycl; constexpr s::access::mode sycl_read = s::access::mode::read; constexpr s::access::mode sycl_write = s::access::mode::write; -#define TEST_NUM 38 +#define TEST_NUM 36 -float ref_val[TEST_NUM] = { - 1, 0, 0, 0, 0, 0, 0, 1, 1, 0.5, - 0, 2, 0, 0, 1, 0, 2, 0, 0, 0, - 0, 0, 1, 0, 1, 2, 0, 1, 2, 5, - 0, 0, 0, 0, 0.5, 0.5, NAN, NAN}; +float ref_val[TEST_NUM] = {1, 0, 0, 0, 0, 0, 0, 1, 1, 0.5, 0, 0, + 1, 0, 2, 0, 0, 0, 0, 0, 1, 0, 1, 2, + 0, 1, 2, 5, 0, 0, 0, 0, 0.5, 0.5, NAN, NAN}; float refIptr = 1; @@ -26,9 +24,6 @@ void device_math_test(s::queue &deviceQueue) { s::range<1> numOfItems{TEST_NUM}; float result[TEST_NUM] = {-1}; - // Variable exponent is an integer value to store the exponent in frexp function - int exponent = -1; - // Variable iptr stores the integral part of float point in modf function float iptr = -1; @@ -36,14 +31,12 @@ void device_math_test(s::queue &deviceQueue) { int quo = -1; { s::buffer buffer1(result, numOfItems); - s::buffer buffer2(&exponent, s::range<1>{1}); - s::buffer buffer3(&iptr, s::range<1>{1}); - s::buffer buffer4(&quo, s::range<1>{1}); + s::buffer buffer2(&iptr, s::range<1>{1}); + s::buffer buffer3(&quo, s::range<1>{1}); deviceQueue.submit([&](cl::sycl::handler &cgh) { auto res_access = buffer1.template get_access(cgh); - auto exp_access = buffer2.template get_access(cgh); - auto iptr_access = buffer3.template get_access(cgh); - auto quo_access = buffer4.template get_access(cgh); + auto iptr_access = buffer2.template get_access(cgh); + auto quo_access = buffer3.template get_access(cgh); cgh.single_task([=]() { int i = 0; res_access[i++] = cosf(0.0f); @@ -56,8 +49,6 @@ void device_math_test(s::queue &deviceQueue) { res_access[i++] = coshf(0.0f); res_access[i++] = expf(0.0f); res_access[i++] = fmodf(1.5f, 1.0f); - res_access[i++] = frexpf(0.0f, &exp_access[0]); - res_access[i++] = ldexpf(1.0f, 1); res_access[i++] = log10f(1.0f); res_access[i++] = modff(1.0f, &iptr_access[0]); res_access[i++] = powf(1.0f, 1.0f); @@ -97,9 +88,6 @@ void device_math_test(s::queue &deviceQueue) { // Test modf integral part assert(approx_equal_fp(iptr, refIptr)); - // Test frexp exponent - assert(exponent == 0); - // Test remquo sign assert(quo == 0); } From 9d7dba8fc58e9f94dc4a01f3bfbd8f81ed19398f Mon Sep 17 00:00:00 2001 From: gejin Date: Thu, 10 Sep 2020 08:34:07 +0800 Subject: [PATCH 14/14] Disable fallback devicelibs in one place Signed-off-by: gejin --- .../program_manager/program_manager.cpp | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index a306b4cb9cad7..89d23d65937be 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -374,9 +374,9 @@ RT::PiProgram ProgramManager::getBuiltPIProgram(OSModuleHandle M, // FIXME: disable the fallback device libraries online link as not all // backend supports spv online link. Need to enable it when all backends // support spv online link. - /* if (Img.getFormat() == PI_DEVICE_BINARY_TYPE_SPIRV && + if (Img.getFormat() == PI_DEVICE_BINARY_TYPE_SPIRV && !SYCLConfig::get()) - DeviceLibReqMask = getDeviceLibReqMask(Img); */ + DeviceLibReqMask = getDeviceLibReqMask(Img); ProgramPtr BuiltProgram = build(std::move(ProgramManaged), ContextImpl, Img.getCompileOptions(), @@ -780,16 +780,12 @@ ProgramManager::ProgramPtr ProgramManager::build( LinkOpts = LinkOptions.c_str(); } - // The Level Zero driver support for online linking currently has bugs, but - // we think the DPC++ runtime support is ready. This environment variable - // gates the runtime support for online linking, so we can try enabling if a - // new driver is released before the next DPC++ release. - static bool EnableLevelZeroLink = std::getenv("SYCL_ENABLE_LEVEL_ZERO_LINK"); - if (!EnableLevelZeroLink) { - if (Context->getPlugin().getBackend() == backend::level_zero) { - LinkDeviceLibs = false; - } - } + // TODO: Because online linking isn't implemented yet on Level Zero, the + // compiler always links against the fallback device libraries. Once + // online linking is supported on all backends, we should remove the line + // below and also change the compiler, so it no longer links the fallback + // code unconditionally. + LinkDeviceLibs = false; // TODO: this is a temporary workaround for GPU tests for ESIMD compiler. // We do not link with other device libraries, because it may fail