DPC++ Runtime
Runtime libraries for oneAPI DPC++
defines_elementary.hpp
Go to the documentation of this file.
1 //==--- defines_elementary.hpp ---- Preprocessor directives (simplified) ---==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #pragma once
10 
11 #ifndef __has_attribute
12 #define __has_attribute(x) 0
13 #endif
14 
15 #ifndef __has_builtin
16 #define __has_builtin(x) 0
17 #endif // __has_builtin
18 
19 #ifndef __SYCL_ALWAYS_INLINE
20 #if __has_attribute(always_inline)
21 #define __SYCL_ALWAYS_INLINE __attribute__((always_inline))
22 #else
23 #define __SYCL_ALWAYS_INLINE
24 #endif
25 #endif // __SYCL_ALWAYS_INLINE
26 
27 #ifdef SYCL_EXTERNAL
28 #define __DPCPP_SYCL_EXTERNAL SYCL_EXTERNAL
29 #else
30 #ifdef __SYCL_DEVICE_ONLY__
31 #define __DPCPP_SYCL_EXTERNAL __attribute__((sycl_device))
32 #else
33 #define __DPCPP_SYCL_EXTERNAL
34 #define SYCL_EXTERNAL
35 #endif
36 #endif
37 
38 #ifndef __SYCL_ID_QUERIES_FIT_IN_INT__
39 #define __SYCL_ID_QUERIES_FIT_IN_INT__ 0
40 #endif
41 
42 #ifndef __SYCL_DEPRECATED
43 #if !defined(SYCL2020_DISABLE_DEPRECATION_WARNINGS)
44 #define __SYCL_DEPRECATED(message) [[deprecated(message)]]
45 #else // SYCL_DISABLE_DEPRECATION_WARNINGS
46 #define __SYCL_DEPRECATED(message)
47 #endif // SYCL_DISABLE_DEPRECATION_WARNINGS
48 #endif // __SYCL_DEPRECATED
49 
50 #ifndef __SYCL2020_DEPRECATED
51 #if SYCL_LANGUAGE_VERSION >= 202001 && \
52  !defined(SYCL2020_DISABLE_DEPRECATION_WARNINGS)
53 #define __SYCL2020_DEPRECATED(message) __SYCL_DEPRECATED(message)
54 #else
55 #define __SYCL2020_DEPRECATED(message)
56 #endif
57 #endif // __SYCL2020_DEPRECATED
58 
59 #ifndef __SYCL_WARN_IMAGE_ASPECT
60 #if !defined(SYCL_DISABLE_IMAGE_ASPECT_WARNING) && __has_attribute(diagnose_if)
61 #define __SYCL_WARN_IMAGE_ASPECT(aspect_param) \
62  __attribute__((diagnose_if( \
63  aspect_param == aspect::image, \
64  "SYCL 2020 images are not supported on any devices. Consider using " \
65  "‘aspect::ext_intel_legacy_image’ instead. Disable this warning with " \
66  "by defining SYCL_DISABLE_IMAGE_ASPECT_WARNING.", \
67  "warning")))
68 #else
69 #define __SYCL_WARN_IMAGE_ASPECT(aspect)
70 #endif
71 #endif // __SYCL_WARN_IMAGE_ASPECT
72 
73 #ifndef __SYCL_HAS_CPP_ATTRIBUTE
74 #if defined(__cplusplus) && defined(__has_cpp_attribute)
75 #define __SYCL_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
76 #else
77 #define __SYCL_HAS_CPP_ATTRIBUTE(x) 0
78 #endif
79 #endif
80 
81 static_assert(__cplusplus >= 201703L,
82  "DPCPP does not support C++ version earlier than C++17.");
83 
84 #if defined(_WIN32) && !defined(_DLL) && !defined(__SYCL_DEVICE_ONLY__)
85 // SYCL library is designed such a way that STL objects cross DLL boundary,
86 // which is guaranteed to work properly only when the application uses the same
87 // C++ runtime that SYCL library uses.
88 // The appplications using sycl.dll must be linked with dynamic/release C++ MSVC
89 // runtime, i.e. be compiled with /MD switch. Similarly, the applications using
90 // sycld.dll must be linked with dynamic/debug C++ runtime and be compiled with
91 // /MDd switch.
92 // Compiler automatically adds /MD or /MDd when -fsycl switch is used.
93 // The options /MD and /MDd that make the code to use dynamic runtime also
94 // define the _DLL macro.
95 #if defined(_MSC_VER)
96 #pragma message( \
97  "SYCL library is designed to work safely with dynamic C++ runtime." \
98  "Please use /MD switch with sycl.dll, /MDd switch with sycld.dll, " \
99  "or -fsycl switch to set C++ runtime automatically.")
100 #else
101 #warning "SYCL library is designed to work safely with dynamic C++ runtime."\
102  "Please use /MD switch with sycl.dll, /MDd switch with sycld.dll, "\
103  "or -fsycl switch to set C++ runtime automatically."
104 #endif
105 #endif // defined(_WIN32) && !defined(_DLL) && !defined(__SYCL_DEVICE_ONLY__)