From 1da37d3c0a2e1c4f181b8b200e7872e15f2ffce9 Mon Sep 17 00:00:00 2001 From: gejin Date: Fri, 4 Jun 2021 10:50:08 +0800 Subject: [PATCH 1/4] enable memcpy in libdevice Signed-off-by: gejin --- clang/lib/Driver/Driver.cpp | 1 + libdevice/cmake/modules/SYCLLibdevice.cmake | 22 +++++++++++++++++++ libdevice/crt_wrapper.cpp | 4 ++++ libdevice/fallback-cstring.cpp | 15 +++++++++++++ libdevice/wrapper.h | 3 ++- .../sycl-post-link/SYCLDeviceLibReqMask.cpp | 2 ++ .../sycl-post-link/SYCLDeviceLibReqMask.h | 3 ++- sycl/include/CL/sycl/builtins.hpp | 2 ++ .../program_manager/program_manager.cpp | 7 +++++- .../program_manager/program_manager.hpp | 3 ++- 10 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 libdevice/fallback-cstring.cpp diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 68685d82c5503..0c88517b4d3e5 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -4184,6 +4184,7 @@ class OffloadingActionBuilder final { // default too. SmallVector sycl_device_fallback_libs = { {"libsycl-fallback-cassert", "libc"}, + {"libsycl-fallback-cstring", "libc"}, {"libsycl-fallback-complex", "libm-fp32"}, {"libsycl-fallback-complex-fp64", "libm-fp64"}, {"libsycl-fallback-cmath", "libm-fp32"}, diff --git a/libdevice/cmake/modules/SYCLLibdevice.cmake b/libdevice/cmake/modules/SYCLLibdevice.cmake index dbb75e31104e0..483d46a6b0aa4 100644 --- a/libdevice/cmake/modules/SYCLLibdevice.cmake +++ b/libdevice/cmake/modules/SYCLLibdevice.cmake @@ -86,6 +86,15 @@ add_custom_command(OUTPUT ${spv_binary_dir}/libsycl-fallback-cassert.spv DEPENDS wrapper.h device.h clang spirv_vars.h llvm-spirv VERBATIM) +add_custom_command(OUTPUT ${spv_binary_dir}/libsycl-fallback-cstring.spv + COMMAND ${clang} -S -fsycl-device-only -fno-sycl-use-bitcode + ${compile_opts} + ${CMAKE_CURRENT_SOURCE_DIR}/fallback-cstring.cpp + -o ${spv_binary_dir}/libsycl-fallback-cstring.spv + MAIN_DEPENDENCY fallback-cstring.cpp + DEPENDS wrapper.h device.h clang spirv_vars.h llvm-spirv + VERBATIM) + add_custom_command(OUTPUT ${obj_binary_dir}/libsycl-fallback-cassert.${lib-suffix} COMMAND ${clang} -fsycl -c ${compile_opts} ${sycl_targets_opt} @@ -95,6 +104,15 @@ add_custom_command(OUTPUT ${obj_binary_dir}/libsycl-fallback-cassert.${lib-suffi DEPENDS wrapper.h device.h clang spirv_vars.h clang-offload-bundler VERBATIM) +add_custom_command(OUTPUT ${obj_binary_dir}/libsycl-fallback-cstring.${lib-suffix} + COMMAND ${clang} -fsycl -c + ${compile_opts} ${sycl_targets_opt} + ${CMAKE_CURRENT_SOURCE_DIR}/fallback-cstring.cpp + -o ${obj_binary_dir}/libsycl-fallback-cstring.${lib-suffix} + MAIN_DEPENDENCY fallback-cstring.cpp + DEPENDS wrapper.h device.h clang spirv_vars.h clang-offload-bundler + VERBATIM) + add_custom_command(OUTPUT ${spv_binary_dir}/libsycl-fallback-complex.spv COMMAND ${clang} -S -fsycl-device-only -fno-sycl-use-bitcode ${compile_opts} @@ -210,6 +228,7 @@ add_custom_target(libsycldevice-obj DEPENDS ) add_custom_target(libsycldevice-spv DEPENDS ${spv_binary_dir}/libsycl-fallback-cassert.spv + ${spv_binary_dir}/libsycl-fallback-cstring.spv ${spv_binary_dir}/libsycl-fallback-complex.spv ${spv_binary_dir}/libsycl-fallback-complex-fp64.spv ${spv_binary_dir}/libsycl-fallback-cmath.spv @@ -217,6 +236,7 @@ add_custom_target(libsycldevice-spv DEPENDS ) add_custom_target(libsycldevice-fallback-obj DEPENDS ${obj_binary_dir}/libsycl-fallback-cassert.${lib-suffix} + ${obj_binary_dir}/libsycl-fallback-cstring.${lib-suffix} ${obj_binary_dir}/libsycl-fallback-complex.${lib-suffix} ${obj_binary_dir}/libsycl-fallback-complex-fp64.${lib-suffix} ${obj_binary_dir}/libsycl-fallback-cmath.${lib-suffix} @@ -239,6 +259,7 @@ set(install_dest_lib lib${LLVM_LIBDIR_SUFFIX}) install(FILES ${devicelib-obj-file} ${obj_binary_dir}/libsycl-fallback-cassert.${lib-suffix} + ${obj_binary_dir}/libsycl-fallback-cstring.${lib-suffix} ${devicelib-obj-complex} ${obj_binary_dir}/libsycl-fallback-complex.${lib-suffix} ${devicelib-obj-complex-fp64} @@ -252,6 +273,7 @@ install(FILES ${devicelib-obj-file} COMPONENT libsycldevice) install(FILES ${spv_binary_dir}/libsycl-fallback-cassert.spv + ${spv_binary_dir}/libsycl-fallback-cstring.spv ${spv_binary_dir}/libsycl-fallback-complex.spv ${spv_binary_dir}/libsycl-fallback-complex-fp64.spv ${spv_binary_dir}/libsycl-fallback-cmath.spv diff --git a/libdevice/crt_wrapper.cpp b/libdevice/crt_wrapper.cpp index b3d03e3409c7d..230d6dc2d9754 100644 --- a/libdevice/crt_wrapper.cpp +++ b/libdevice/crt_wrapper.cpp @@ -9,6 +9,10 @@ #include "wrapper.h" #ifdef __SPIR__ +DEVICE_EXTERN_C +void *memcpy(void *dest, const void *src, size_t n) { + return __devicelib_memcpy(dest, src, n); +} #if defined(_WIN32) // Truncates a wide (16 or 32 bit) string (wstr) into an ASCII string (str). // Any non-ASCII characters are replaced by question mark '?'. diff --git a/libdevice/fallback-cstring.cpp b/libdevice/fallback-cstring.cpp new file mode 100644 index 0000000000000..8c7bb66c7f192 --- /dev/null +++ b/libdevice/fallback-cstring.cpp @@ -0,0 +1,15 @@ +//==--- fallback-cassert.cpp - device agnostic implementation of C assert --==// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "wrapper.h" + +#ifdef __SPIR__ +void *__devicelib_memcpy(void *dest, const void *src, size_t n) { + return __builtin_memcpy(dest, src, n); +} +#endif // __SPIR__ diff --git a/libdevice/wrapper.h b/libdevice/wrapper.h index 2116d1e55a226..cd143c08bc395 100644 --- a/libdevice/wrapper.h +++ b/libdevice/wrapper.h @@ -18,7 +18,8 @@ // We need the following header to ensure the definition of all spirv variables // required by the wrapper libraries. #include "spirv_vars.h" - +DEVICE_EXTERN_C +void *__devicelib_memcpy(void *dest, const void *src, size_t n); DEVICE_EXTERN_C void __devicelib_assert_fail(const char *expr, const char *file, int32_t line, const char *func, uint64_t gid0, uint64_t gid1, diff --git a/llvm/tools/sycl-post-link/SYCLDeviceLibReqMask.cpp b/llvm/tools/sycl-post-link/SYCLDeviceLibReqMask.cpp index ea182b36d6d4b..80f197ff8d022 100644 --- a/llvm/tools/sycl-post-link/SYCLDeviceLibReqMask.cpp +++ b/llvm/tools/sycl-post-link/SYCLDeviceLibReqMask.cpp @@ -158,6 +158,7 @@ SYCLDeviceLibFuncMap SDLMap = { {"__devicelib_csqrt", DeviceLibExt::cl_intel_devicelib_complex_fp64}, {"__devicelib_ctan", DeviceLibExt::cl_intel_devicelib_complex_fp64}, {"__devicelib_ctanh", DeviceLibExt::cl_intel_devicelib_complex_fp64}, + {"__devicelib_memcpy", DeviceLibExt::cl_intel_devicelib_cstring}, }; // Each fallback device library corresponds to one bit in "require mask" which @@ -169,6 +170,7 @@ SYCLDeviceLibFuncMap SDLMap = { // fallback-cmath-fp64: 0x4 // fallback-complex: 0x8 // fallback-complex-fp64: 0x10 +// fallback-cstring: 0x20 uint32_t getDeviceLibBits(const std::string &FuncName) { auto DeviceLibFuncIter = SDLMap.find(FuncName); return ((DeviceLibFuncIter == SDLMap.end()) diff --git a/llvm/tools/sycl-post-link/SYCLDeviceLibReqMask.h b/llvm/tools/sycl-post-link/SYCLDeviceLibReqMask.h index 065ca8cdf1aa3..9cd07905883f0 100644 --- a/llvm/tools/sycl-post-link/SYCLDeviceLibReqMask.h +++ b/llvm/tools/sycl-post-link/SYCLDeviceLibReqMask.h @@ -28,7 +28,8 @@ enum class DeviceLibExt : std::uint32_t { cl_intel_devicelib_math, cl_intel_devicelib_math_fp64, cl_intel_devicelib_complex, - cl_intel_devicelib_complex_fp64 + cl_intel_devicelib_complex_fp64, + cl_intel_devicelib_cstring, }; using SYCLDeviceLibFuncMap = std::unordered_map; diff --git a/sycl/include/CL/sycl/builtins.hpp b/sycl/include/CL/sycl/builtins.hpp index 7780341c9af03..8abab93fd1ea6 100644 --- a/sycl/include/CL/sycl/builtins.hpp +++ b/sycl/include/CL/sycl/builtins.hpp @@ -1630,6 +1630,8 @@ extern SYCL_EXTERNAL double atanh(double x); extern SYCL_EXTERNAL double frexp(double x, int *exp); extern SYCL_EXTERNAL double ldexp(double x, int exp); extern SYCL_EXTERNAL double hypot(double x, double y); + +extern SYCL_EXTERNAL void *memcpy(void *dest, const void *src, size_t n); } #ifdef __GLIBC__ extern "C" { diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index ac45509944d83..74fb07d0f356b 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -633,6 +633,8 @@ static const char *getDeviceLibFilename(DeviceLibExt Extension) { return "libsycl-fallback-complex.spv"; case DeviceLibExt::cl_intel_devicelib_complex_fp64: return "libsycl-fallback-complex-fp64.spv"; + case DeviceLibExt::cl_intel_devicelib_cstring: + return "libsycl-fallback-cstring.spv"; } throw compile_program_error("Unhandled (new?) device library extension", PI_INVALID_OPERATION); @@ -650,6 +652,8 @@ static const char *getDeviceLibExtensionStr(DeviceLibExt Extension) { return "cl_intel_devicelib_complex"; case DeviceLibExt::cl_intel_devicelib_complex_fp64: return "cl_intel_devicelib_complex_fp64"; + case DeviceLibExt::cl_intel_devicelib_cstring: + return "cl_intel_devicelib_cstring"; } throw compile_program_error("Unhandled (new?) device library extension", PI_INVALID_OPERATION); @@ -815,7 +819,8 @@ static std::vector getDeviceLibPrograms( {DeviceLibExt::cl_intel_devicelib_math, false}, {DeviceLibExt::cl_intel_devicelib_math_fp64, false}, {DeviceLibExt::cl_intel_devicelib_complex, false}, - {DeviceLibExt::cl_intel_devicelib_complex_fp64, false}}; + {DeviceLibExt::cl_intel_devicelib_complex_fp64, false}, + {DeviceLibExt::cl_intel_devicelib_cstring, false}}; // Disable all devicelib extensions requiring fp64 support if at least // one underlying device doesn't support cl_khr_fp64. diff --git a/sycl/source/detail/program_manager/program_manager.hpp b/sycl/source/detail/program_manager/program_manager.hpp index 7a706700c9a2d..3c68be4f17079 100644 --- a/sycl/source/detail/program_manager/program_manager.hpp +++ b/sycl/source/detail/program_manager/program_manager.hpp @@ -53,7 +53,8 @@ enum class DeviceLibExt : std::uint32_t { cl_intel_devicelib_math, cl_intel_devicelib_math_fp64, cl_intel_devicelib_complex, - cl_intel_devicelib_complex_fp64 + cl_intel_devicelib_complex_fp64, + cl_intel_devicelib_cstring }; // Provides single loading and building OpenCL programs with unique contexts From 43263e8e4cef621ff82bc429059a357144b4ad78 Mon Sep 17 00:00:00 2001 From: gejin Date: Fri, 4 Jun 2021 13:48:01 +0800 Subject: [PATCH 2/4] fix lit test Signed-off-by: gejin --- clang/lib/Driver/ToolChains/SYCL.cpp | 1 + clang/test/Driver/sycl-device-lib-win.cpp | 5 ++++- clang/test/Driver/sycl-device-lib.cpp | 4 ++++ libdevice/fallback-cstring.cpp | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp index 8bc8bf94c501f..44d266498b27b 100644 --- a/clang/lib/Driver/ToolChains/SYCL.cpp +++ b/clang/lib/Driver/ToolChains/SYCL.cpp @@ -133,6 +133,7 @@ static llvm::SmallVector SYCLDeviceLibList{ "complex", "complex-fp64", "fallback-cassert", + "fallback-cstring", "fallback-cmath", "fallback-cmath-fp64", "fallback-complex", diff --git a/clang/test/Driver/sycl-device-lib-win.cpp b/clang/test/Driver/sycl-device-lib-win.cpp index 6ef0d435037cf..052ea61f13b49 100644 --- a/clang/test/Driver/sycl-device-lib-win.cpp +++ b/clang/test/Driver/sycl-device-lib-win.cpp @@ -21,6 +21,7 @@ // SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-cmath.obj" "-outputs={{.*}}libsycl-cmath-{{.*}}.o" "-unbundle" // SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-cmath-fp64.obj" "-outputs={{.*}}libsycl-cmath-fp64-{{.*}}.o" "-unbundle" // SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cassert.obj" "-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-cstring.obj" "-outputs={{.*}}libsycl-fallback-cstring-{{.*}}.o" "-unbundle" // SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-complex.obj" "-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-complex-fp64.obj" "-outputs={{.*}}libsycl-fallback-complex-fp64-{{.*}}.o" "-unbundle" // SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cmath.obj" "-outputs={{.*}}libsycl-fallback-cmath-{{.*}}.o" "-unbundle" @@ -44,6 +45,7 @@ // SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-cmath.obj" "-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.obj" "-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.obj" "-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-cstring.obj" "-outputs={{.*}}libsycl-fallback-cstring-{{.*}}.o" "-unbundle" // SYCL_DEVICE_LIB_UNBUNDLE_WITH_FP64-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-complex.obj" "-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.obj" "-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.obj" "-outputs={{.*}}libsycl-fallback-cmath-{{.*}}.o" "-unbundle" @@ -69,7 +71,7 @@ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBM // SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBM: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-crt.obj" "-outputs={{.*}}libsycl-crt-{{.*}}.o" "-unbundle" // SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBM-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cassert.obj" "-outputs={{.*}}libsycl-fallback-cassert-{{.*}}.o" "-unbundle" - +// SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBM-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cstring.obj" "-outputs={{.*}}libsycl-fallback-cstring-{{.*}}.o" "-unbundle" /// ########################################################################### /// test behavior of disabling all device libraries @@ -109,6 +111,7 @@ // SYCL_LLVM_LINK_DEVICE_LIB-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-cmath.obj" "-outputs={{.*}}libsycl-cmath-{{.*}}.o" "-unbundle" // SYCL_LLVM_LINK_DEVICE_LIB-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-cmath-fp64.obj" "-outputs={{.*}}libsycl-cmath-fp64-{{.*}}.o" "-unbundle" // SYCL_LLVM_LINK_DEVICE_LIB-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cassert.obj" "-outputs={{.*}}libsycl-fallback-cassert-{{.*}}.o" "-unbundle" +// SYCL_LLVM_LINK_DEVICE_LIB-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cstring.obj" "-outputs={{.*}}libsycl-fallback-cstring-{{.*}}.o" "-unbundle" // SYCL_LLVM_LINK_DEVICE_LIB-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-complex.obj" "-outputs={{.*}}libsycl-fallback-complex-{{.*}}.o" "-unbundle" // SYCL_LLVM_LINK_DEVICE_LIB-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-complex-fp64.obj" "-outputs={{.*}}libsycl-fallback-complex-fp64-{{.*}}.o" "-unbundle" // SYCL_LLVM_LINK_DEVICE_LIB-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cmath.obj" "-outputs={{.*}}libsycl-fallback-cmath-{{.*}}.o" "-unbundle" diff --git a/clang/test/Driver/sycl-device-lib.cpp b/clang/test/Driver/sycl-device-lib.cpp index 5d66e337bd832..6a11ef58775bc 100644 --- a/clang/test/Driver/sycl-device-lib.cpp +++ b/clang/test/Driver/sycl-device-lib.cpp @@ -21,6 +21,7 @@ // 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-cmath-fp64.o" "-outputs={{.*}}libsycl-cmath-fp64-{{.*}}.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-cstring.o" "-outputs={{.*}}libsycl-fallback-cstring-{{.*}}.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-complex-fp64.o" "-outputs={{.*}}libsycl-fallback-complex-fp64-{{.*}}.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" @@ -44,6 +45,7 @@ // 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-cstring.o" "-outputs={{.*}}libsycl-fallback-cstring-{{.*}}.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" @@ -69,6 +71,7 @@ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBM // SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBM: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-crt.o" "-outputs={{.*}}libsycl-crt-{{.*}}.o" "-unbundle" // SYCL_DEVICE_LIB_UNBUNDLE_NO_LIBM-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_NO_LIBM-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cstring.o" "-outputs={{.*}}libsycl-fallback-cstring-{{.*}}.o" "-unbundle" /// ########################################################################### @@ -109,6 +112,7 @@ // SYCL_LLVM_LINK_DEVICE_LIB-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-cmath.o" "-outputs={{.*}}libsycl-cmath-{{.*}}.o" "-unbundle" // SYCL_LLVM_LINK_DEVICE_LIB-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-cmath-fp64.o" "-outputs={{.*}}libsycl-cmath-fp64-{{.*}}.o" "-unbundle" // SYCL_LLVM_LINK_DEVICE_LIB-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cassert.o" "-outputs={{.*}}libsycl-fallback-cassert-{{.*}}.o" "-unbundle" +// SYCL_LLVM_LINK_DEVICE_LIB-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cstring.o" "-outputs={{.*}}libsycl-fallback-cstring-{{.*}}.o" "-unbundle" // SYCL_LLVM_LINK_DEVICE_LIB-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-complex.o" "-outputs={{.*}}libsycl-fallback-complex-{{.*}}.o" "-unbundle" // SYCL_LLVM_LINK_DEVICE_LIB-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_LLVM_LINK_DEVICE_LIB-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice" "-inputs={{.*}}libsycl-fallback-cmath.o" "-outputs={{.*}}libsycl-fallback-cmath-{{.*}}.o" "-unbundle" diff --git a/libdevice/fallback-cstring.cpp b/libdevice/fallback-cstring.cpp index 8c7bb66c7f192..2c54b3f63fe83 100644 --- a/libdevice/fallback-cstring.cpp +++ b/libdevice/fallback-cstring.cpp @@ -1,4 +1,4 @@ -//==--- fallback-cassert.cpp - device agnostic implementation of C assert --==// +//==-- fallback-cstring.cpp - fallback implementation of C string functions--=// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. From b19e5a7bdbbbc6a1db2971c85a2eb5852448b8aa Mon Sep 17 00:00:00 2001 From: gejin Date: Fri, 4 Jun 2021 15:32:25 +0800 Subject: [PATCH 3/4] add fake binary for cstring fallback devicelib Signed-off-by: gejin --- .../Driver/Inputs/SYCL-windows/lib/libsycl-fallback-cstring.obj | 0 clang/test/Driver/Inputs/SYCL/lib/libsycl-fallback-cstring.o | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-fallback-cstring.obj create mode 100644 clang/test/Driver/Inputs/SYCL/lib/libsycl-fallback-cstring.o diff --git a/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-fallback-cstring.obj b/clang/test/Driver/Inputs/SYCL-windows/lib/libsycl-fallback-cstring.obj new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/clang/test/Driver/Inputs/SYCL/lib/libsycl-fallback-cstring.o b/clang/test/Driver/Inputs/SYCL/lib/libsycl-fallback-cstring.o new file mode 100644 index 0000000000000..e69de29bb2d1d From c7a52c1fef6336aad7de58e86129655da5a9832e Mon Sep 17 00:00:00 2001 From: gejin Date: Wed, 16 Jun 2021 09:53:01 +0800 Subject: [PATCH 4/4] remove redundant -S Signed-off-by: gejin --- libdevice/cmake/modules/SYCLLibdevice.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libdevice/cmake/modules/SYCLLibdevice.cmake b/libdevice/cmake/modules/SYCLLibdevice.cmake index 483d46a6b0aa4..d4166cece929f 100644 --- a/libdevice/cmake/modules/SYCLLibdevice.cmake +++ b/libdevice/cmake/modules/SYCLLibdevice.cmake @@ -78,7 +78,7 @@ add_custom_command(OUTPUT ${devicelib-obj-cmath-fp64} VERBATIM) add_custom_command(OUTPUT ${spv_binary_dir}/libsycl-fallback-cassert.spv - COMMAND ${clang} -S -fsycl-device-only -fno-sycl-use-bitcode + COMMAND ${clang} -fsycl-device-only -fno-sycl-use-bitcode ${compile_opts} ${CMAKE_CURRENT_SOURCE_DIR}/fallback-cassert.cpp -o ${spv_binary_dir}/libsycl-fallback-cassert.spv @@ -87,7 +87,7 @@ add_custom_command(OUTPUT ${spv_binary_dir}/libsycl-fallback-cassert.spv VERBATIM) add_custom_command(OUTPUT ${spv_binary_dir}/libsycl-fallback-cstring.spv - COMMAND ${clang} -S -fsycl-device-only -fno-sycl-use-bitcode + COMMAND ${clang} -fsycl-device-only -fno-sycl-use-bitcode ${compile_opts} ${CMAKE_CURRENT_SOURCE_DIR}/fallback-cstring.cpp -o ${spv_binary_dir}/libsycl-fallback-cstring.spv @@ -114,7 +114,7 @@ add_custom_command(OUTPUT ${obj_binary_dir}/libsycl-fallback-cstring.${lib-suffi VERBATIM) add_custom_command(OUTPUT ${spv_binary_dir}/libsycl-fallback-complex.spv - COMMAND ${clang} -S -fsycl-device-only -fno-sycl-use-bitcode + COMMAND ${clang} -fsycl-device-only -fno-sycl-use-bitcode ${compile_opts} ${CMAKE_CURRENT_SOURCE_DIR}/fallback-complex.cpp -o ${spv_binary_dir}/libsycl-fallback-complex.spv @@ -132,7 +132,7 @@ add_custom_command(OUTPUT ${obj_binary_dir}/libsycl-fallback-complex.${lib-suffi VERBATIM) add_custom_command(OUTPUT ${spv_binary_dir}/libsycl-fallback-complex-fp64.spv - COMMAND ${clang} -S -fsycl-device-only -fno-sycl-use-bitcode + COMMAND ${clang} -fsycl-device-only -fno-sycl-use-bitcode ${compile_opts} ${CMAKE_CURRENT_SOURCE_DIR}/fallback-complex-fp64.cpp -o ${spv_binary_dir}/libsycl-fallback-complex-fp64.spv @@ -150,7 +150,7 @@ add_custom_command(OUTPUT ${obj_binary_dir}/libsycl-fallback-complex-fp64.${lib- VERBATIM) add_custom_command(OUTPUT ${spv_binary_dir}/libsycl-fallback-cmath.spv - COMMAND ${clang} -S -fsycl-device-only -fno-sycl-use-bitcode + COMMAND ${clang} -fsycl-device-only -fno-sycl-use-bitcode ${compile_opts} ${CMAKE_CURRENT_SOURCE_DIR}/fallback-cmath.cpp -o ${spv_binary_dir}/libsycl-fallback-cmath.spv @@ -168,7 +168,7 @@ add_custom_command(OUTPUT ${obj_binary_dir}/libsycl-fallback-cmath.${lib-suffix} VERBATIM) add_custom_command(OUTPUT ${spv_binary_dir}/libsycl-fallback-cmath-fp64.spv - COMMAND ${clang} -S -fsycl-device-only -fno-sycl-use-bitcode + COMMAND ${clang} -fsycl-device-only -fno-sycl-use-bitcode ${compile_opts} ${CMAKE_CURRENT_SOURCE_DIR}/fallback-cmath-fp64.cpp -o ${spv_binary_dir}/libsycl-fallback-cmath-fp64.spv