Skip to content

Commit 47e9ed2

Browse files
committed
[SYCL] Check that apps using sycl also use dynamic C++ RT even without -fsycl
With -fsycl switch the dynamic runtime is used. The patches (intel#2478, intel#2480, intel#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 <[email protected]>
1 parent 9a734f6 commit 47e9ed2

23 files changed

+75
-71
lines changed

sycl/include/CL/sycl/stl.hpp

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,52 @@
2222
__SYCL_INLINE_NAMESPACE(cl) {
2323
namespace sycl {
2424

25-
template < class T, class Alloc = std::allocator<T> >
26-
using vector_class = std::vector<T, Alloc>;
25+
#if defined(_WIN32) && !defined(__SYCL_DEVICE_ONLY__)
26+
namespace detail {
27+
// SYCL library is designed such a way that STL objects cross DLL boundary,
28+
// which is not guaranteed to work and considered not safe in general.
29+
// Only using same dynamic C++ runtime library for sycl[d].dll and for
30+
// the application using sycl[d].dll is guaranteed to work properly.
31+
inline constexpr bool isMSVCDynamicCXXRuntime() {
32+
// The options /MD and /MDd that make the code to use dynamic runtime also
33+
// define the _DLL macro.
34+
#ifdef _DLL
35+
return true;
36+
#else
37+
return false;
38+
#endif
39+
}
40+
static_assert(isMSVCDynamicCXXRuntime(),
41+
"SYCL library is designed to work with dynamic C++ runtime, "
42+
"please use /MD or /MDd switches.");
43+
} // namespace detail
44+
#endif // defined(_WIN32) && !defined(__SYCL_DEVICE_ONLY__)
2745

28-
using string_class = std::string;
46+
template <class T, class Alloc = std::allocator<T>>
47+
using vector_class = std::vector<T, Alloc>;
2948

30-
template <class Sig>
31-
using function_class = std::function<Sig>;
49+
using string_class = std::string;
3250

33-
using mutex_class = std::mutex;
51+
template <class Sig> using function_class = std::function<Sig>;
3452

35-
template <class T, class Deleter = std::default_delete<T>>
36-
using unique_ptr_class = std::unique_ptr<T, Deleter>;
53+
using mutex_class = std::mutex;
3754

38-
template <class T>
39-
using shared_ptr_class = std::shared_ptr<T>;
55+
template <class T, class Deleter = std::default_delete<T>>
56+
using unique_ptr_class = std::unique_ptr<T, Deleter>;
4057

41-
template <class T>
42-
using weak_ptr_class = std::weak_ptr<T>;
58+
template <class T> using shared_ptr_class = std::shared_ptr<T>;
4359

44-
template <class T>
45-
using hash_class = std::hash<T>;
60+
template <class T> using weak_ptr_class = std::weak_ptr<T>;
4661

47-
using exception_ptr_class = std::exception_ptr;
62+
template <class T> using hash_class = std::hash<T>;
63+
64+
using exception_ptr_class = std::exception_ptr;
65+
66+
template <typename T, typename... ArgsT>
67+
unique_ptr_class<T> make_unique_ptr(ArgsT &&... Args) {
68+
return unique_ptr_class<T>(new T(std::forward<ArgsT>(Args)...));
69+
}
4870

49-
template <typename T, typename... ArgsT>
50-
unique_ptr_class<T> make_unique_ptr(ArgsT &&... Args) {
51-
return unique_ptr_class<T>(new T(std::forward<ArgsT>(Args)...));
52-
}
5371
} // sycl
5472
} // cl
5573

sycl/test/basic_tests/aspects.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx %s -o %t.out -I %sycl_include -lsycl
1+
// RUN: %clangxx -fsycl %s -o %t.out
22
// RUN: %t.out
33

44
//==--------------- aspects.cpp - SYCL device test ------------------------==//

sycl/test/basic_tests/buffer/buffer_ctad.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
1+
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
22
// expected-no-diagnostics
33

44
#include <CL/sycl.hpp>

sycl/test/basic_tests/context.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
// RUN: %clangxx %s -o %t.out -lsycl -I %sycl_include
1+
// RUN: %clangxx -fsycl %s -o %t.out
22
// RUN: %RUN_ON_HOST %t.out
33

4-
//==--------------- context.cpp - SYCL context test ------------------------==//
5-
//
6-
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
7-
// See https://llvm.org/LICENSE.txt for license information.
8-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9-
//
10-
//===----------------------------------------------------------------------===//
4+
// This test performs basic check of the SYCL context class.
115

126
#include <sycl/sycl.hpp>
137
#include <iostream>

sycl/test/basic_tests/device.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
// RUN: %clangxx %s -o %t.out -I %sycl_include -lsycl
1+
// RUN: %clangxx -fsycl %s -o %t.out
22
// RUN: %RUN_ON_HOST %t.out
33

4-
//==--------------- device.cpp - SYCL device test --------------------------==//
5-
//
6-
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
7-
// See https://llvm.org/LICENSE.txt for license information.
8-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9-
//
10-
//===----------------------------------------------------------------------===//
4+
// This test performs basic check of the SYCL device class.
115

126
#include <CL/sycl.hpp>
137
#include <cassert>

sycl/test/basic_tests/id_ctad.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
1+
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
22
// expected-no-diagnostics
33
//==--------------- id_ctad.cpp - SYCL id CTAD test ----------------------==//
44
//

sycl/test/basic_tests/implicit_conversion_error.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clangxx -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
2-
//==-- implicit_conversion_error.cpp - Unintended implicit conversion check --==//
1+
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
2+
//=- implicit_conversion_error.cpp - Unintended implicit conversion check -=//
33
//
44
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
55
// See https://llvm.org/LICENSE.txt for license information.

sycl/test/basic_tests/marray/marray.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// RUN: %clangxx %s -o %t.out -lsycl -I %sycl_include
2-
// RUN: %t.out
1+
// RUN: %clangxx -fsycl %s -o %t.out
2+
// RUN: %RUN_ON_HOST %t.out
3+
34
//==--------------- marray.cpp - SYCL marray test --------------------------==//
45
//
56
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.

sycl/test/basic_tests/property_list.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
// RUN: %clangxx %s -o %t.out -lsycl -I%sycl_include
1+
// RUN: %clangxx -fsycl %s -o %t.out
22
// RUN: %RUN_ON_HOST %t.out
33
//
44
// CHECK: PASSED
5-
//==--------------- property_list.cpp - SYCL property list test ------------==//
6-
//
7-
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
8-
// See https://llvm.org/LICENSE.txt for license information.
9-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
10-
//
11-
//===----------------------------------------------------------------------===//
5+
6+
// This test performs basic check of the SYCL property_list class.
7+
128
#include <CL/sycl.hpp>
139
#include <iostream>
1410

sycl/test/basic_tests/range_ctad.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
1+
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
22
// expected-no-diagnostics
33
//==--------------- range_ctad.cpp - SYCL range CTAD test ----------------------==//
44
//

sycl/test/basic_tests/range_error.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning -fsyntax-only
1+
// RUN: %clangxx -fsycl -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning -fsyntax-only
22
//==--------------- range_error.cpp - SYCL range error test ----------------==//
33
//
44
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.

sycl/test/basic_tests/reduction_known_identity.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
1+
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
22
// expected-no-diagnostics
33

44
// This test performs basic checks of has_known_identity and known_identity
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s -c -o %t.out
2-
// RUN: %clangxx -std=c++14 -fsyntax-only -Xclang -verify -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out
3-
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out
4-
// RUN: %clangxx -std=c++20 -fsyntax-only -Xclang -verify -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out
2+
// RUN: %clangxx -fsycl -std=c++14 -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out
3+
// RUN: %clangxx -fsycl -std=c++17 -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out
4+
// RUN: %clangxx -fsycl -std=c++20 -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s -o -c %t.out
55
// expected-no-diagnostics
66

77
#include <CL/sycl.hpp>

sycl/test/basic_tests/valid_kernel_args.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
//===----------------------------------------------------------------------===//
88

99
// The test checks that the types can be used to pass kernel parameters by value
10-
// RUN: %clangxx -fsyntax-only %s -I %sycl_include -Wno-sycl-strict -Xclang -verify-ignore-unexpected=note,warning
10+
// RUN: %clangxx -fsycl -fsyntax-only %s -Wno-sycl-strict -Xclang -verify-ignore-unexpected=note,warning
1111

1212
// Check that the test can be compiled with device compiler as well.
13-
// RUN: %clangxx -fsycl-device-only -fsyntax-only %s -I %sycl_include -Wno-sycl-strict
13+
// RUN: %clangxx -fsycl-device-only -fsyntax-only %s -Wno-sycl-strict
1414

1515
#include <CL/sycl.hpp>
1616

sycl/test/basic_tests/vectors/ctad.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -std=c++17 -I %sycl_include -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
1+
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
22
// expected-no-diagnostics
33
//==--------------- ctad.cpp - SYCL vector CTAD test --------------------==//
44
//

sycl/test/basic_tests/vectors/vectors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx %s -o %t.out -lsycl -I %sycl_include
1+
// RUN: %clangxx -fsycl %s -o %t.out
22
// RUN: %t.out
33
//==--------------- vectors.cpp - SYCL vectors test ------------------------==//
44
//

sycl/test/esimd/vadd.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// TODO ESIMD enable host device under -fsycl
2-
// RUN: %clangxx -I %sycl_include %s -o %t.out -lsycl
1+
// RUN: %clangxx -fsycl %s -o %t.out
32
// RUN: %RUN_ON_HOST %t.out
43

54
#include <CL/sycl.hpp>

sycl/test/multi_ptr/ctad.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
1+
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
22
// expected-no-diagnostics
33
//==--------------- ctad.cpp - SYCL multi_ptr CTAD test --------------------==//
44
//

sycl/test/regression/macro_conflict.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -fsyntax-only -I %sycl_include -Xclang -verify %s -o %t.out -Xclang -verify-ignore-unexpected=note,warning
1+
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -o %t.out -Xclang -verify-ignore-unexpected=note,warning
22
// expected-no-diagnostics
33
//
44
//===----------------------------------------------------------------------===//

sycl/test/regression/sub-group-store-const-ref.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
1+
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
22
// expected-no-diagnostics
33
//
44
//==-- sub-group-store-const-ref.cpp ---------------------------------------==//

sycl/test/regression/unable-to-redeclare-device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -fsyntax-only -Xclang -verify -DCL_TARGET_OPENCL_VERSION=220 %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
1+
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify -DCL_TARGET_OPENCL_VERSION=220 %s -Xclang -verify-ignore-unexpected=note,warning
22
// expected-no-diagnostics
33
//
44
//==-- unable-to-redeclare-device.cpp --------------------------------------==//

sycl/test/regression/vec-to-half.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang -O0 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
1+
// RUN: %clang -fsycl -O0 -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
22
// expected-no-diagnostics
33

44
#include <CL/sycl.hpp>

sycl/test/separate-compile/test.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
//
44
// >> ---- compile src1
55
// >> device compilation...
6-
// 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
6+
// RUN: %clangxx -fsycl-device-only -Xclang -fsycl-int-header=sycl_ihdr_a.h %s -c -o a_kernel.bc -Wno-sycl-strict
77
// >> host compilation...
8-
// RUN: %clangxx -include sycl_ihdr_a.h -g -c %s -o a.o -I %sycl_include -Wno-sycl-strict
8+
// Driver automatically adds -D_DLL and -D_MT on Windows with -fsycl.
9+
// Add those defines required for Windows and harmless for Linux.
10+
// RUN: %clangxx -D_DLL -D_MT -include sycl_ihdr_a.h -g -c %s -o a.o -I %sycl_include -Wno-sycl-strict
911
//
1012
// >> ---- compile src2
1113
// >> device compilation...
12-
// 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
14+
// 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
1315
// >> host compilation...
14-
// RUN: %clangxx -DB_CPP=1 -include sycl_ihdr_b.h -g -c %s -o b.o -I %sycl_include -Wno-sycl-strict
16+
// 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
1517
//
1618
// >> ---- bundle .o with .spv
1719
// >> run bundler

0 commit comments

Comments
 (0)