From 47e9ed258c0563bc308d66a8b0ff4462eaa083d2 Mon Sep 17 00:00:00 2001 From: Vyacheslav N Klochkov Date: Sun, 20 Sep 2020 22:28:34 -0700 Subject: [PATCH 1/3] [SYCL] Check that apps using sycl also use dynamic C++ RT even without -fsycl With -fsycl switch the dynamic runtime is used. The patches (#2478, #2480, #2497 implemented that with -fsycl. This patch adds check that dynamic runtime is used when -fsycl is not used. That is done by a static_assert in sycl/stl.hpp. Also, lots of LIT tests had to be changed to comply with the new requirement (apps must use dynamic C++ RT with use SYCL). Signed-off-by: Vyacheslav N Klochkov --- sycl/include/CL/sycl/stl.hpp | 56 ++++++++++++------- sycl/test/basic_tests/aspects.cpp | 2 +- sycl/test/basic_tests/buffer/buffer_ctad.cpp | 2 +- sycl/test/basic_tests/context.cpp | 10 +--- sycl/test/basic_tests/device.cpp | 10 +--- sycl/test/basic_tests/id_ctad.cpp | 2 +- .../basic_tests/implicit_conversion_error.cpp | 4 +- sycl/test/basic_tests/marray/marray.cpp | 5 +- sycl/test/basic_tests/property_list.cpp | 12 ++-- sycl/test/basic_tests/range_ctad.cpp | 2 +- sycl/test/basic_tests/range_error.cpp | 2 +- .../basic_tests/reduction_known_identity.cpp | 2 +- sycl/test/basic_tests/stdcpp_compat.cpp | 6 +- sycl/test/basic_tests/valid_kernel_args.cpp | 4 +- sycl/test/basic_tests/vectors/ctad.cpp | 2 +- sycl/test/basic_tests/vectors/vectors.cpp | 2 +- sycl/test/esimd/vadd.cpp | 3 +- sycl/test/multi_ptr/ctad.cpp | 2 +- sycl/test/regression/macro_conflict.cpp | 2 +- .../regression/sub-group-store-const-ref.cpp | 2 +- .../regression/unable-to-redeclare-device.cpp | 2 +- sycl/test/regression/vec-to-half.cpp | 2 +- sycl/test/separate-compile/test.cpp | 10 ++-- 23 files changed, 75 insertions(+), 71 deletions(-) diff --git a/sycl/include/CL/sycl/stl.hpp b/sycl/include/CL/sycl/stl.hpp index f57fc0674c8fe..2ef20732c7f3e 100644 --- a/sycl/include/CL/sycl/stl.hpp +++ b/sycl/include/CL/sycl/stl.hpp @@ -22,34 +22,52 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { - template < class T, class Alloc = std::allocator > - using vector_class = std::vector; +#if defined(_WIN32) && !defined(__SYCL_DEVICE_ONLY__) +namespace detail { +// SYCL library is designed such a way that STL objects cross DLL boundary, +// which is not guaranteed to work and considered not safe in general. +// Only using same dynamic C++ runtime library for sycl[d].dll and for +// the application using sycl[d].dll is guaranteed to work properly. +inline constexpr bool isMSVCDynamicCXXRuntime() { +// The options /MD and /MDd that make the code to use dynamic runtime also +// define the _DLL macro. +#ifdef _DLL + return true; +#else + return false; +#endif +} +static_assert(isMSVCDynamicCXXRuntime(), + "SYCL library is designed to work with dynamic C++ runtime, " + "please use /MD or /MDd switches."); +} // namespace detail +#endif // defined(_WIN32) && !defined(__SYCL_DEVICE_ONLY__) - using string_class = std::string; +template > +using vector_class = std::vector; - template - using function_class = std::function; +using string_class = std::string; - using mutex_class = std::mutex; +template using function_class = std::function; - template > - using unique_ptr_class = std::unique_ptr; +using mutex_class = std::mutex; - template - using shared_ptr_class = std::shared_ptr; +template > +using unique_ptr_class = std::unique_ptr; - template - using weak_ptr_class = std::weak_ptr; +template using shared_ptr_class = std::shared_ptr; - template - using hash_class = std::hash; +template using weak_ptr_class = std::weak_ptr; - using exception_ptr_class = std::exception_ptr; +template using hash_class = std::hash; + +using exception_ptr_class = std::exception_ptr; + +template +unique_ptr_class make_unique_ptr(ArgsT &&... Args) { + return unique_ptr_class(new T(std::forward(Args)...)); +} - template - unique_ptr_class make_unique_ptr(ArgsT &&... Args) { - return unique_ptr_class(new T(std::forward(Args)...)); - } } // sycl } // cl diff --git a/sycl/test/basic_tests/aspects.cpp b/sycl/test/basic_tests/aspects.cpp index f68e234660715..d69f7a9800516 100644 --- a/sycl/test/basic_tests/aspects.cpp +++ b/sycl/test/basic_tests/aspects.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx %s -o %t.out -I %sycl_include -lsycl +// RUN: %clangxx -fsycl %s -o %t.out // RUN: %t.out //==--------------- aspects.cpp - SYCL device test ------------------------==// diff --git a/sycl/test/basic_tests/buffer/buffer_ctad.cpp b/sycl/test/basic_tests/buffer/buffer_ctad.cpp index 07a8afd27318b..858ee6fe21edb 100644 --- a/sycl/test/basic_tests/buffer/buffer_ctad.cpp +++ b/sycl/test/basic_tests/buffer/buffer_ctad.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning +// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning // expected-no-diagnostics #include diff --git a/sycl/test/basic_tests/context.cpp b/sycl/test/basic_tests/context.cpp index e08ffb10a069c..fab5335460f23 100644 --- a/sycl/test/basic_tests/context.cpp +++ b/sycl/test/basic_tests/context.cpp @@ -1,13 +1,7 @@ -// RUN: %clangxx %s -o %t.out -lsycl -I %sycl_include +// RUN: %clangxx -fsycl %s -o %t.out // RUN: %RUN_ON_HOST %t.out -//==--------------- context.cpp - SYCL context test ------------------------==// -// -// 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 -// -//===----------------------------------------------------------------------===// +// This test performs basic check of the SYCL context class. #include #include diff --git a/sycl/test/basic_tests/device.cpp b/sycl/test/basic_tests/device.cpp index 0b84d40de236a..06c9f4f343a09 100644 --- a/sycl/test/basic_tests/device.cpp +++ b/sycl/test/basic_tests/device.cpp @@ -1,13 +1,7 @@ -// RUN: %clangxx %s -o %t.out -I %sycl_include -lsycl +// RUN: %clangxx -fsycl %s -o %t.out // RUN: %RUN_ON_HOST %t.out -//==--------------- device.cpp - SYCL device test --------------------------==// -// -// 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 -// -//===----------------------------------------------------------------------===// +// This test performs basic check of the SYCL device class. #include #include diff --git a/sycl/test/basic_tests/id_ctad.cpp b/sycl/test/basic_tests/id_ctad.cpp index 00d45c9a94dec..431ab68876afb 100644 --- a/sycl/test/basic_tests/id_ctad.cpp +++ b/sycl/test/basic_tests/id_ctad.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning +// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning // expected-no-diagnostics //==--------------- id_ctad.cpp - SYCL id CTAD test ----------------------==// // diff --git a/sycl/test/basic_tests/implicit_conversion_error.cpp b/sycl/test/basic_tests/implicit_conversion_error.cpp index 8adb3d3bdbc6a..6b4b389c45f70 100644 --- a/sycl/test/basic_tests/implicit_conversion_error.cpp +++ b/sycl/test/basic_tests/implicit_conversion_error.cpp @@ -1,5 +1,5 @@ -// RUN: %clangxx -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning -//==-- implicit_conversion_error.cpp - Unintended implicit conversion check --==// +// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning +//=- implicit_conversion_error.cpp - Unintended implicit conversion check -=// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/sycl/test/basic_tests/marray/marray.cpp b/sycl/test/basic_tests/marray/marray.cpp index dcbabe6a29e1f..148b6958691fc 100755 --- a/sycl/test/basic_tests/marray/marray.cpp +++ b/sycl/test/basic_tests/marray/marray.cpp @@ -1,5 +1,6 @@ -// RUN: %clangxx %s -o %t.out -lsycl -I %sycl_include -// RUN: %t.out +// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %RUN_ON_HOST %t.out + //==--------------- marray.cpp - SYCL marray test --------------------------==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. diff --git a/sycl/test/basic_tests/property_list.cpp b/sycl/test/basic_tests/property_list.cpp index 2dc390a521734..5ebf7e19ae9bd 100644 --- a/sycl/test/basic_tests/property_list.cpp +++ b/sycl/test/basic_tests/property_list.cpp @@ -1,14 +1,10 @@ -// RUN: %clangxx %s -o %t.out -lsycl -I%sycl_include +// RUN: %clangxx -fsycl %s -o %t.out // RUN: %RUN_ON_HOST %t.out // // CHECK: PASSED -//==--------------- property_list.cpp - SYCL property list test ------------==// -// -// 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 -// -//===----------------------------------------------------------------------===// + +// This test performs basic check of the SYCL property_list class. + #include #include diff --git a/sycl/test/basic_tests/range_ctad.cpp b/sycl/test/basic_tests/range_ctad.cpp index ea1ad8ec12fea..10698524da86d 100644 --- a/sycl/test/basic_tests/range_ctad.cpp +++ b/sycl/test/basic_tests/range_ctad.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning +// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning // expected-no-diagnostics //==--------------- range_ctad.cpp - SYCL range CTAD test ----------------------==// // diff --git a/sycl/test/basic_tests/range_error.cpp b/sycl/test/basic_tests/range_error.cpp index d536f0d6547e7..c11d2242119c4 100644 --- a/sycl/test/basic_tests/range_error.cpp +++ b/sycl/test/basic_tests/range_error.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning -fsyntax-only +// RUN: %clangxx -fsycl -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning -fsyntax-only //==--------------- range_error.cpp - SYCL range error test ----------------==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. diff --git a/sycl/test/basic_tests/reduction_known_identity.cpp b/sycl/test/basic_tests/reduction_known_identity.cpp index 7fd2ecbf58d11..b954a48316a81 100644 --- a/sycl/test/basic_tests/reduction_known_identity.cpp +++ b/sycl/test/basic_tests/reduction_known_identity.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning +// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning // expected-no-diagnostics // This test performs basic checks of has_known_identity and known_identity diff --git a/sycl/test/basic_tests/stdcpp_compat.cpp b/sycl/test/basic_tests/stdcpp_compat.cpp index 33852c8bfcff5..7d5fa73443e77 100644 --- a/sycl/test/basic_tests/stdcpp_compat.cpp +++ b/sycl/test/basic_tests/stdcpp_compat.cpp @@ -1,7 +1,7 @@ // RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s -c -o %t.out -// RUN: %clangxx -std=c++14 -fsyntax-only -Xclang -verify -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out -// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out -// RUN: %clangxx -std=c++20 -fsyntax-only -Xclang -verify -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out +// RUN: %clangxx -fsycl -std=c++14 -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out +// RUN: %clangxx -fsycl -std=c++17 -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out +// RUN: %clangxx -fsycl -std=c++20 -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out // expected-no-diagnostics #include diff --git a/sycl/test/basic_tests/valid_kernel_args.cpp b/sycl/test/basic_tests/valid_kernel_args.cpp index d915895d0f283..e6bc307ddd0e7 100644 --- a/sycl/test/basic_tests/valid_kernel_args.cpp +++ b/sycl/test/basic_tests/valid_kernel_args.cpp @@ -7,10 +7,10 @@ //===----------------------------------------------------------------------===// // The test checks that the types can be used to pass kernel parameters by value -// RUN: %clangxx -fsyntax-only %s -I %sycl_include -Wno-sycl-strict -Xclang -verify-ignore-unexpected=note,warning +// RUN: %clangxx -fsycl -fsyntax-only %s -Wno-sycl-strict -Xclang -verify-ignore-unexpected=note,warning // Check that the test can be compiled with device compiler as well. -// RUN: %clangxx -fsycl-device-only -fsyntax-only %s -I %sycl_include -Wno-sycl-strict +// RUN: %clangxx -fsycl-device-only -fsyntax-only %s -Wno-sycl-strict #include diff --git a/sycl/test/basic_tests/vectors/ctad.cpp b/sycl/test/basic_tests/vectors/ctad.cpp index 5503102c25bc1..d80c4da9088da 100644 --- a/sycl/test/basic_tests/vectors/ctad.cpp +++ b/sycl/test/basic_tests/vectors/ctad.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -std=c++17 -I %sycl_include -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning +// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning // expected-no-diagnostics //==--------------- ctad.cpp - SYCL vector CTAD test --------------------==// // diff --git a/sycl/test/basic_tests/vectors/vectors.cpp b/sycl/test/basic_tests/vectors/vectors.cpp index a3175f366d107..f48d7bab35109 100644 --- a/sycl/test/basic_tests/vectors/vectors.cpp +++ b/sycl/test/basic_tests/vectors/vectors.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx %s -o %t.out -lsycl -I %sycl_include +// RUN: %clangxx -fsycl %s -o %t.out // RUN: %t.out //==--------------- vectors.cpp - SYCL vectors test ------------------------==// // diff --git a/sycl/test/esimd/vadd.cpp b/sycl/test/esimd/vadd.cpp index 68208337d2eb2..c0845ed9ebc81 100644 --- a/sycl/test/esimd/vadd.cpp +++ b/sycl/test/esimd/vadd.cpp @@ -1,5 +1,4 @@ -// TODO ESIMD enable host device under -fsycl -// RUN: %clangxx -I %sycl_include %s -o %t.out -lsycl +// RUN: %clangxx -fsycl %s -o %t.out // RUN: %RUN_ON_HOST %t.out #include diff --git a/sycl/test/multi_ptr/ctad.cpp b/sycl/test/multi_ptr/ctad.cpp index 733bc60f8e572..d66b3fbfc5adc 100644 --- a/sycl/test/multi_ptr/ctad.cpp +++ b/sycl/test/multi_ptr/ctad.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning +// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning // expected-no-diagnostics //==--------------- ctad.cpp - SYCL multi_ptr CTAD test --------------------==// // diff --git a/sycl/test/regression/macro_conflict.cpp b/sycl/test/regression/macro_conflict.cpp index e7f595b78af99..233d84bce725d 100644 --- a/sycl/test/regression/macro_conflict.cpp +++ b/sycl/test/regression/macro_conflict.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsyntax-only -I %sycl_include -Xclang -verify %s -o %t.out -Xclang -verify-ignore-unexpected=note,warning +// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -o %t.out -Xclang -verify-ignore-unexpected=note,warning // expected-no-diagnostics // //===----------------------------------------------------------------------===// diff --git a/sycl/test/regression/sub-group-store-const-ref.cpp b/sycl/test/regression/sub-group-store-const-ref.cpp index 5c79e5e6758f6..438fc86c95fd1 100644 --- a/sycl/test/regression/sub-group-store-const-ref.cpp +++ b/sycl/test/regression/sub-group-store-const-ref.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning +// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning // expected-no-diagnostics // //==-- sub-group-store-const-ref.cpp ---------------------------------------==// diff --git a/sycl/test/regression/unable-to-redeclare-device.cpp b/sycl/test/regression/unable-to-redeclare-device.cpp index 5d16e50b877cf..1dd68535a7597 100644 --- a/sycl/test/regression/unable-to-redeclare-device.cpp +++ b/sycl/test/regression/unable-to-redeclare-device.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -fsyntax-only -Xclang -verify -DCL_TARGET_OPENCL_VERSION=220 %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning +// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify -DCL_TARGET_OPENCL_VERSION=220 %s -Xclang -verify-ignore-unexpected=note,warning // expected-no-diagnostics // //==-- unable-to-redeclare-device.cpp --------------------------------------==// diff --git a/sycl/test/regression/vec-to-half.cpp b/sycl/test/regression/vec-to-half.cpp index 7ca77a0714226..86aded1cd54c7 100644 --- a/sycl/test/regression/vec-to-half.cpp +++ b/sycl/test/regression/vec-to-half.cpp @@ -1,4 +1,4 @@ -// RUN: %clang -O0 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning +// RUN: %clang -fsycl -O0 -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning // expected-no-diagnostics #include diff --git a/sycl/test/separate-compile/test.cpp b/sycl/test/separate-compile/test.cpp index a97c7e4c8ae88..a6e7a91169ca9 100644 --- a/sycl/test/separate-compile/test.cpp +++ b/sycl/test/separate-compile/test.cpp @@ -3,15 +3,17 @@ // // >> ---- compile src1 // >> device compilation... -// RUN: %clangxx -fsycl-device-only -Xclang -fsycl-int-header=sycl_ihdr_a.h %s -c -o a_kernel.bc -I %sycl_include -Wno-sycl-strict +// RUN: %clangxx -fsycl-device-only -Xclang -fsycl-int-header=sycl_ihdr_a.h %s -c -o a_kernel.bc -Wno-sycl-strict // >> host compilation... -// RUN: %clangxx -include sycl_ihdr_a.h -g -c %s -o a.o -I %sycl_include -Wno-sycl-strict +// Driver automatically adds -D_DLL and -D_MT on Windows with -fsycl. +// Add those defines required for Windows and harmless for Linux. +// RUN: %clangxx -D_DLL -D_MT -include sycl_ihdr_a.h -g -c %s -o a.o -I %sycl_include -Wno-sycl-strict // // >> ---- compile src2 // >> device compilation... -// RUN: %clangxx -DB_CPP=1 -fsycl-device-only -Xclang -fsycl-int-header=sycl_ihdr_b.h %s -c -o b_kernel.bc -I %sycl_include -Wno-sycl-strict +// RUN: %clangxx -DB_CPP=1 -fsycl-device-only -Xclang -fsycl-int-header=sycl_ihdr_b.h %s -c -o b_kernel.bc -Wno-sycl-strict // >> host compilation... -// RUN: %clangxx -DB_CPP=1 -include sycl_ihdr_b.h -g -c %s -o b.o -I %sycl_include -Wno-sycl-strict +// RUN: %clangxx -DB_CPP=1 -D_DLL -D_MT -include sycl_ihdr_b.h -g -c %s -o b.o -I %sycl_include -Wno-sycl-strict // // >> ---- bundle .o with .spv // >> run bundler From 852c3f4a3f0afa9069d9750172f83f5eb6d52b01 Mon Sep 17 00:00:00 2001 From: Vyacheslav N Klochkov Date: Mon, 29 Mar 2021 09:31:38 -0700 Subject: [PATCH 2/3] Remove 'inline' keyword per reviewer's request, fix one LIT test Signed-off-by: Vyacheslav N Klochkov --- sycl/include/CL/sycl/stl.hpp | 2 +- sycl/test/on-device/extensions/intel-ext-device.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sycl/include/CL/sycl/stl.hpp b/sycl/include/CL/sycl/stl.hpp index 2ef20732c7f3e..a5bf5dd1a4ba7 100644 --- a/sycl/include/CL/sycl/stl.hpp +++ b/sycl/include/CL/sycl/stl.hpp @@ -28,7 +28,7 @@ namespace detail { // which is not guaranteed to work and considered not safe in general. // Only using same dynamic C++ runtime library for sycl[d].dll and for // the application using sycl[d].dll is guaranteed to work properly. -inline constexpr bool isMSVCDynamicCXXRuntime() { +constexpr bool isMSVCDynamicCXXRuntime() { // The options /MD and /MDd that make the code to use dynamic runtime also // define the _DLL macro. #ifdef _DLL diff --git a/sycl/test/on-device/extensions/intel-ext-device.cpp b/sycl/test/on-device/extensions/intel-ext-device.cpp index 7ef3771f068ea..64ec80126725a 100644 --- a/sycl/test/on-device/extensions/intel-ext-device.cpp +++ b/sycl/test/on-device/extensions/intel-ext-device.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx %s -o %t.out -I %sycl_include -lsycl +// RUN: %clangxx -fsycl %s -o %t.out // RUN: env SYCL_DEVICE_FILTER=level_zero:gpu %t.out // RUN: env SYCL_DEVICE_FILTER=opencl:gpu %t.out // From 31f880af530c0050bf6f743b1524eb44ce12cbf4 Mon Sep 17 00:00:00 2001 From: Vyacheslav N Klochkov Date: Tue, 30 Mar 2021 22:03:27 -0700 Subject: [PATCH 3/3] Turned the static_assert() into a warning/message Signed-off-by: Vyacheslav N Klochkov --- sycl/include/CL/sycl/stl.hpp | 37 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/sycl/include/CL/sycl/stl.hpp b/sycl/include/CL/sycl/stl.hpp index a5bf5dd1a4ba7..6a9b0b844d838 100644 --- a/sycl/include/CL/sycl/stl.hpp +++ b/sycl/include/CL/sycl/stl.hpp @@ -22,26 +22,28 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { -#if defined(_WIN32) && !defined(__SYCL_DEVICE_ONLY__) -namespace detail { +#if defined(_WIN32) && !defined(_DLL) && !defined(__SYCL_DEVICE_ONLY__) // SYCL library is designed such a way that STL objects cross DLL boundary, -// which is not guaranteed to work and considered not safe in general. -// Only using same dynamic C++ runtime library for sycl[d].dll and for -// the application using sycl[d].dll is guaranteed to work properly. -constexpr bool isMSVCDynamicCXXRuntime() { +// which is guaranteed to work properly only when the application uses the same +// C++ runtime that SYCL library uses. +// The appplications using sycl.dll must be linked with dynamic/release C++ MSVC +// runtime, i.e. be compiled with /MD switch. Similarly, the applications using +// sycld.dll must be linked with dynamic/debug C++ runtime and be compiled with +// /MDd switch. +// Compiler automatically adds /MD or /MDd when -fsycl switch is used. // The options /MD and /MDd that make the code to use dynamic runtime also // define the _DLL macro. -#ifdef _DLL - return true; +#if defined(_MSC_VER) +#pragma message( \ + "SYCL library is designed to work safely with dynamic C++ runtime." \ + "Please use /MD switch with sycl.dll, /MDd switch with sycld.dll, " \ + "or -fsycl switch to set C++ runtime automatically.") #else - return false; +#warning "SYCL library is designed to work safely with dynamic C++ runtime."\ + "Please use /MD switch with sycl.dll, /MDd switch with sycld.dll, "\ + "or -fsycl switch to set C++ runtime automatically." #endif -} -static_assert(isMSVCDynamicCXXRuntime(), - "SYCL library is designed to work with dynamic C++ runtime, " - "please use /MD or /MDd switches."); -} // namespace detail -#endif // defined(_WIN32) && !defined(__SYCL_DEVICE_ONLY__) +#endif // defined(_WIN32) && !defined(_DLL) && !defined(__SYCL_DEVICE_ONLY__) template > using vector_class = std::vector; @@ -68,6 +70,5 @@ unique_ptr_class make_unique_ptr(ArgsT &&... Args) { return unique_ptr_class(new T(std::forward(Args)...)); } -} // sycl -} // cl - +} // namespace sycl +} // __SYCL_INLINE_NAMESPACE(cl)