|
22 | 22 | __SYCL_INLINE_NAMESPACE(cl) {
|
23 | 23 | namespace sycl {
|
24 | 24 |
|
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__) |
27 | 45 |
|
28 |
| - using string_class = std::string; |
| 46 | +template <class T, class Alloc = std::allocator<T>> |
| 47 | +using vector_class = std::vector<T, Alloc>; |
29 | 48 |
|
30 |
| - template <class Sig> |
31 |
| - using function_class = std::function<Sig>; |
| 49 | +using string_class = std::string; |
32 | 50 |
|
33 |
| - using mutex_class = std::mutex; |
| 51 | +template <class Sig> using function_class = std::function<Sig>; |
34 | 52 |
|
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; |
37 | 54 |
|
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>; |
40 | 57 |
|
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>; |
43 | 59 |
|
44 |
| - template <class T> |
45 |
| - using hash_class = std::hash<T>; |
| 60 | +template <class T> using weak_ptr_class = std::weak_ptr<T>; |
46 | 61 |
|
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 | +} |
48 | 70 |
|
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 |
| - } |
53 | 71 | } // sycl
|
54 | 72 | } // cl
|
55 | 73 |
|
0 commit comments