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 __SYCL_DISABLE_NAMESPACE_INLINE__
12
#define __SYCL_INLINE_NAMESPACE(X) inline namespace X
13
#else
14
#define __SYCL_INLINE_NAMESPACE(X) namespace X
15
#endif // __SYCL_DISABLE_NAMESPACE_INLINE__
16
17
#ifndef __has_attribute
18
#define __has_attribute(x) 0
19
#endif
20
21
#ifndef __has_builtin
22
#define __has_builtin(x) 0
23
#endif // __has_builtin
24
25
#ifndef __SYCL_ALWAYS_INLINE
26
#if __has_attribute(always_inline)
27
#define __SYCL_ALWAYS_INLINE __attribute__((always_inline))
28
#else
29
#define __SYCL_ALWAYS_INLINE
30
#endif
31
#endif // __SYCL_ALWAYS_INLINE
32
33
#ifndef SYCL_EXTERNAL
34
#define SYCL_EXTERNAL
35
#endif
36
37
#ifndef __SYCL_ID_QUERIES_FIT_IN_INT__
38
#define __SYCL_ID_QUERIES_FIT_IN_INT__ 0
39
#endif
40
41
#ifndef __SYCL_DEPRECATED
42
// The deprecated attribute is not supported in some situations(e.g. namespace)
43
// in C++14 mode
44
#if !defined(SYCL2020_DISABLE_DEPRECATION_WARNINGS) && __cplusplus >= 201703L
45
#define __SYCL_DEPRECATED(message) [[deprecated(message)]]
46
#else // SYCL_DISABLE_DEPRECATION_WARNINGS
47
#define __SYCL_DEPRECATED(message)
48
#endif // SYCL_DISABLE_DEPRECATION_WARNINGS
49
#endif // __SYCL_DEPRECATED
50
51
#ifndef __SYCL2020_DEPRECATED
52
#if SYCL_LANGUAGE_VERSION >= 202001 && \
53
!defined(SYCL2020_DISABLE_DEPRECATION_WARNINGS)
54
#define __SYCL2020_DEPRECATED(message) __SYCL_DEPRECATED(message)
55
#else
56
#define __SYCL2020_DEPRECATED(message)
57
#endif
58
#endif // __SYCL2020_DEPRECATED
59
60
#ifndef __SYCL_INLINE_CONSTEXPR
61
// inline constexpr is a C++17 feature
62
#if __cplusplus >= 201703L
63
#define __SYCL_INLINE_CONSTEXPR inline constexpr
64
#else
65
#define __SYCL_INLINE_CONSTEXPR static constexpr
66
#endif
67
#endif // __SYCL_INLINE_CONSTEXPR
68
69
#ifndef __SYCL_HAS_CPP_ATTRIBUTE
70
#if defined(__cplusplus) && defined(__has_cpp_attribute)
71
#define __SYCL_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
72
#else
73
#define __SYCL_HAS_CPP_ATTRIBUTE(x) 0
74
#endif
75
#endif
76
77
#ifndef __SYCL_FALLTHROUGH
78
#if defined(__cplusplus) && __cplusplus >= 201703L && \
79
__SYCL_HAS_CPP_ATTRIBUTE(fallthrough)
80
#define __SYCL_FALLTHROUGH [[fallthrough]]
81
#elif __SYCL_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
82
#define __SYCL_FALLTHROUGH [[gnu::fallthrough]]
83
#elif __has_attribute(fallthrough)
84
#define __SYCL_FALLTHROUGH __attribute__((fallthrough))
85
#elif __SYCL_HAS_CPP_ATTRIBUTE(clang::fallthrough)
86
#define __SYCL_FALLTHROUGH [[clang::fallthrough]]
87
#else
88
#define __SYCL_FALLTHROUGH
89
#endif
90
#endif // __SYCL_FALLTHROUGH
91
92
// Stringify an argument to pass it in _Pragma directive below.
93
#ifndef __SYCL_STRINGIFY
94
#define __SYCL_STRINGIFY(x) #x
95
#endif // __SYCL_STRINGIFY
96
97
// define __SYCL_WARNING convenience macro to report compiler warnings
98
#if defined(__GNUC__)
99
#define __SYCL_WARNING(msg) _Pragma(__SYCL_STRINGIFY(GCC warning msg))
100
#elif defined(_MSC_VER) && !defined(__clang__)
101
#define __SYCL_QUOTE1(x) #x
102
#define __SYCL_QUOTE(x) __SYCL_QUOTE1(x)
103
#define __SYCL_SRC_LOC __FILE__ ":" __SYCL_QUOTE(__LINE__)
104
#define __SYCL_WARNING(msg) __pragma(message(__SYCL_SRC_LOC " warning: " msg))
105
#else // clang et. al.
106
// clang emits "warning:" in the message pragma output
107
#define __SYCL_WARNING(msg) __pragma(message(msg))
108
#endif // __GNUC__
109
110
// Define __SYCL_UNROLL to add pragma/attribute unroll to a loop.
111
#ifndef __SYCL_UNROLL
112
#if defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER)
113
#define __SYCL_UNROLL(x) _Pragma(__SYCL_STRINGIFY(unroll x))
114
#elif defined(__clang__)
115
#define __SYCL_UNROLL(x) _Pragma(__SYCL_STRINGIFY(unroll x))
116
#elif (defined(__GNUC__) && __GNUC__ >= 8) || \
117
(defined(__GNUG__) && __GNUG__ >= 8)
118
#define __SYCL_UNROLL(x) _Pragma(__SYCL_STRINGIFY(GCC unroll x))
119
#else
120
#define __SYCL_UNROLL(x)
121
#endif // compiler switch
122
#endif // __SYCL_UNROLL
123
124
#if !defined(SYCL_DISABLE_CPP_VERSION_CHECK_WARNING) && __cplusplus < 201703L
125
126
#if defined(_MSC_VER) && !defined(__clang__)
127
__SYCL_WARNING
(
"DPCPP does not support C++ version earlier than C++17. Some "
128
"features might not be available."
)
129
#else
130
// This is the only way to emit a warning from system headers using clang, it
131
// cannot be wrapped by a macro(__pragma warning doesn't work in system
132
// headers). The solution is borrowed from libcxx.
133
#warning: DPCPP does not support C++ version earlier than C++17. Some features might not be available.
134
#endif
135
136
#endif
__SYCL_WARNING
#define __SYCL_WARNING(msg)
Definition:
defines_elementary.hpp:107
include
CL
sycl
detail
defines_elementary.hpp
Generated by
1.8.17