diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index cebbb27609297..5ad9145fc59f2 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3561,6 +3561,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 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 exclusion of " + "device libraries from device binary linkage. 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 5681a8beb363a..b3c775a356859 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 "clang/Driver/Driver.h" #include "InputInfo.h" #include "ToolChains/AIX.h" @@ -2715,6 +2714,16 @@ static SmallVector getLinkerArgs(Compilation &C, return LibArgs; } +static bool IsSYCLDeviceLibObj(std::string ObjFilePath, bool isMSVCEnv) { + StringRef ObjFileName = llvm::sys::path::filename(ObjFilePath); + StringRef ObjSuffix = isMSVCEnv ? ".obj" : ".o"; + bool Ret = + (ObjFileName.startswith("libsycl-") && ObjFileName.endswith(ObjSuffix)) + ? 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. @@ -3790,7 +3799,13 @@ 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, C.getDefaultToolChain() + .getTriple() + .isWindowsMSVCEnvironment())) FPGAObjectInputs.push_back(IA); } // When creating FPGA device fat objects, all host objects are @@ -3854,6 +3869,92 @@ class OffloadingActionBuilder final { SYCLDeviceActions.clear(); } + void addSYCLDeviceLibs(const ToolChain *TC, ActionList &DeviceLinkObjects, + bool isSpirvAOT, bool isMSVCEnv) { + enum SYCLDeviceLibType { + sycl_devicelib_wrapper, + sycl_devicelib_fallback + }; + struct DeviceLibOptInfo { + StringRef devicelib_name; + StringRef devicelib_option; + }; + + bool NoDeviceLibs = false; + // Currently, libc, libm-fp32 will be linked in by default. In order + // to use libm-fp64, -fsycl-device-lib=libm-fp64/all should be used. + 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; + } + } + } + + SmallString<128> LibLoc(TC->getDriver().Dir); + llvm::sys::path::append(LibLoc, "/../lib"); + StringRef LibSuffix = isMSVCEnv ? ".obj" : ".o"; + SmallVector sycl_device_wrapper_libs = { + {"libsycl-crt", "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", "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 DeviceLibOptInfo &Lib : sycl_libs) { + if (!devicelib_link_info[Lib.devicelib_option]) + continue; + SmallString<128> LibName(LibLoc); + llvm::sys::path::append(LibName, Lib.devicelib_name); + llvm::sys::path::replace_extension(LibName, LibSuffix); + if (llvm::sys::fs::exists(LibName)) { + 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."); @@ -3933,6 +4034,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) @@ -3940,6 +4046,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: @@ -3994,7 +4109,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 @@ -4006,10 +4120,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/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=' diff --git a/clang/test/Driver/sycl-offload-intelfpga.cpp b/clang/test/Driver/sycl-offload-intelfpga.cpp index 71d5c2bc76051..12826682d4478 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/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 87db2f5fdc15a..1c41c844333a4 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 aeea104e524bd..3bf790d87a6ce 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]]" @@ -785,7 +785,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) @@ -824,9 +824,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" @@ -858,9 +858,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 diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index c597b70669af6..89d23d65937be 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -371,6 +371,9 @@ 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; + // 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); @@ -777,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 diff --git a/sycl/test/devicelib/assert-aot.cpp b/sycl/test/devicelib/assert-aot.cpp index f360836f40e5d..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-crt.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 5f6de9a82cdfd..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/libsycl-crt.obj -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 1aaf21192f3b8..1afa4169bab73 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-crt.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 @@ -76,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-aot.cpp b/sycl/test/devicelib/cmath-aot.cpp index e58a87d9f51bc..4eee5f65b221b 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-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 %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-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/cmath_fp64_test.cpp b/sycl/test/devicelib/cmath_fp64_test.cpp index 30954e0eff59f..d1f42613c6c5f 100644 --- a/sycl/test/devicelib/cmath_fp64_test.cpp +++ b/sycl/test/devicelib/cmath_fp64_test.cpp @@ -1,9 +1,8 @@ -// 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 -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 #include diff --git a/sycl/test/devicelib/cmath_test.cpp b/sycl/test/devicelib/cmath_test.cpp index bb2e37345d6fc..e07ac0f55003e 100644 --- a/sycl/test/devicelib/cmath_test.cpp +++ b/sycl/test/devicelib/cmath_test.cpp @@ -1,36 +1,29 @@ -// 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 + +#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; @@ -38,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); @@ -58,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); @@ -99,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/complex-fpga.cpp b/sycl/test/devicelib/complex-fpga.cpp new file mode 100644 index 0000000000000..aa01ee0a98de0 --- /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 +// +//===------------------------------------------------------------------------===// +// UNSUPPORTED: windows +// 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..7f17fe63b3d01 100644 --- a/sycl/test/devicelib/math_fp64_test.cpp +++ b/sycl/test/devicelib/math_fp64_test.cpp @@ -1,9 +1,8 @@ -// 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 -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 #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 15c3aca33ba8e..0000000000000 --- a/sycl/test/devicelib/math_fp64_windows_test.cpp +++ /dev/null @@ -1,132 +0,0 @@ -// REQUIRES: cpu, windows -// RUN: %clangxx -fsycl -c %s -o %t.o -// RUN: %clangxx -fsycl %t.o %sycl_libs_dir/libsycl-cmath-fp64.obj -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 -#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_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..38d9a8f081bd9 100644 --- a/sycl/test/devicelib/math_test.cpp +++ b/sycl/test/devicelib/math_test.cpp @@ -1,9 +1,8 @@ -// 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 + #include "math_utils.hpp" #include #include @@ -13,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; @@ -27,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; @@ -37,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); @@ -57,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); @@ -98,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); } 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/math_windows_test.cpp b/sycl/test/devicelib/math_windows_test.cpp deleted file mode 100644 index fd5f2920cb949..0000000000000 --- a/sycl/test/devicelib/math_windows_test.cpp +++ /dev/null @@ -1,121 +0,0 @@ -// REQUIRES: cpu, windows -// RUN: %clangxx -fsycl -c %s -o %t.o -// RUN: %clangxx -fsycl %t.o %sycl_libs_dir/libsycl-cmath.obj -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 -#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; -} diff --git a/sycl/test/devicelib/std_complex_math_fp64_test.cpp b/sycl/test/devicelib/std_complex_math_fp64_test.cpp index 40eeadfd04321..fd609db28b6f7 100644 --- a/sycl/test/devicelib/std_complex_math_fp64_test.cpp +++ b/sycl/test/devicelib/std_complex_math_fp64_test.cpp @@ -1,6 +1,4 @@ -// 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 -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 @@ -17,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()); } @@ -86,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 b2578076243ff..74f63bcf60387 100644 --- a/sycl/test/devicelib/std_complex_math_test.cpp +++ b/sycl/test/devicelib/std_complex_math_test.cpp @@ -1,6 +1,4 @@ -// 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 @@ -17,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; @@ -126,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)); @@ -151,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; @@ -195,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; } 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