LLVM OpenMP* Runtime Library
src
kmp_platform.h
1
/*
2
* kmp_platform.h -- header for determining operating system and architecture
3
*/
4
5
//===----------------------------------------------------------------------===//
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
//===----------------------------------------------------------------------===//
12
13
#ifndef KMP_PLATFORM_H
14
#define KMP_PLATFORM_H
15
16
/* ---------------------- Operating system recognition ------------------- */
17
18
#define KMP_OS_LINUX 0
19
#define KMP_OS_DRAGONFLY 0
20
#define KMP_OS_FREEBSD 0
21
#define KMP_OS_KFREEBSD 0
22
#define KMP_OS_NETBSD 0
23
#define KMP_OS_OPENBSD 0
24
#define KMP_OS_DARWIN 0
25
#define KMP_OS_WINDOWS 0
26
#define KMP_OS_CNK 0
27
#define KMP_OS_HURD 0
28
#define KMP_OS_UNIX 0
/* disjunction of KMP_OS_LINUX, KMP_OS_DARWIN etc. */
29
30
#ifdef _WIN32
31
#undef KMP_OS_WINDOWS
32
#define KMP_OS_WINDOWS 1
33
#endif
34
35
#if (defined __APPLE__ && defined __MACH__)
36
#undef KMP_OS_DARWIN
37
#define KMP_OS_DARWIN 1
38
#endif
39
40
// in some ppc64 linux installations, only the second condition is met
41
#if (defined __linux)
42
#undef KMP_OS_LINUX
43
#define KMP_OS_LINUX 1
44
#elif (defined __linux__)
45
#undef KMP_OS_LINUX
46
#define KMP_OS_LINUX 1
47
#else
48
#endif
49
50
#if (defined __DragonFly__)
51
#undef KMP_OS_DRAGONFLY
52
#define KMP_OS_DRAGONFLY 1
53
#endif
54
55
#if (defined __FreeBSD__)
56
#undef KMP_OS_FREEBSD
57
#define KMP_OS_FREEBSD 1
58
#endif
59
60
#if (defined __FreeBSD_kernel__)
61
#undef KMP_OS_KFREEBSD
62
#define KMP_OS_KFREEBSD 1
63
#endif
64
65
#if (defined __NetBSD__)
66
#undef KMP_OS_NETBSD
67
#define KMP_OS_NETBSD 1
68
#endif
69
70
#if (defined __OpenBSD__)
71
#undef KMP_OS_OPENBSD
72
#define KMP_OS_OPENBSD 1
73
#endif
74
75
#if (defined __bgq__)
76
#undef KMP_OS_CNK
77
#define KMP_OS_CNK 1
78
#endif
79
80
#if (defined __GNU__)
81
#undef KMP_OS_HURD
82
#define KMP_OS_HURD 1
83
#endif
84
85
#if (1 != \
86
KMP_OS_LINUX + KMP_OS_DRAGONFLY + KMP_OS_FREEBSD + KMP_OS_NETBSD + \
87
KMP_OS_OPENBSD + KMP_OS_DARWIN + KMP_OS_WINDOWS + KMP_OS_HURD + KMP_OS_KFREEBSD)
88
#error Unknown OS
89
#endif
90
91
#if KMP_OS_LINUX || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD || \
92
KMP_OS_OPENBSD || KMP_OS_DARWIN || KMP_OS_HURD || KMP_OS_KFREEBSD
93
#undef KMP_OS_UNIX
94
#define KMP_OS_UNIX 1
95
#endif
96
97
/* ---------------------- Architecture recognition ------------------- */
98
99
#define KMP_ARCH_X86 0
100
#define KMP_ARCH_X86_64 0
101
#define KMP_ARCH_AARCH64 0
102
#define KMP_ARCH_PPC64_BE 0
103
#define KMP_ARCH_PPC64_LE 0
104
#define KMP_ARCH_PPC64 (KMP_ARCH_PPC64_LE || KMP_ARCH_PPC64_BE)
105
#define KMP_ARCH_MIPS 0
106
#define KMP_ARCH_MIPS64 0
107
108
#if KMP_OS_WINDOWS
109
#if defined(_M_AMD64) || defined(__x86_64)
110
#undef KMP_ARCH_X86_64
111
#define KMP_ARCH_X86_64 1
112
#else
113
#undef KMP_ARCH_X86
114
#define KMP_ARCH_X86 1
115
#endif
116
#endif
117
118
#if KMP_OS_UNIX
119
#if defined __x86_64
120
#undef KMP_ARCH_X86_64
121
#define KMP_ARCH_X86_64 1
122
#elif defined __i386
123
#undef KMP_ARCH_X86
124
#define KMP_ARCH_X86 1
125
#elif defined __powerpc64__
126
#if defined __LITTLE_ENDIAN__
127
#undef KMP_ARCH_PPC64_LE
128
#define KMP_ARCH_PPC64_LE 1
129
#else
130
#undef KMP_ARCH_PPC64_BE
131
#define KMP_ARCH_PPC64_BE 1
132
#endif
133
#elif defined __aarch64__
134
#undef KMP_ARCH_AARCH64
135
#define KMP_ARCH_AARCH64 1
136
#elif defined __mips__
137
#if defined __mips64
138
#undef KMP_ARCH_MIPS64
139
#define KMP_ARCH_MIPS64 1
140
#else
141
#undef KMP_ARCH_MIPS
142
#define KMP_ARCH_MIPS 1
143
#endif
144
#endif
145
#endif
146
147
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7R__) || \
148
defined(__ARM_ARCH_7A__)
149
#define KMP_ARCH_ARMV7 1
150
#endif
151
152
#if defined(KMP_ARCH_ARMV7) || defined(__ARM_ARCH_6__) || \
153
defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || \
154
defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6T2__) || \
155
defined(__ARM_ARCH_6ZK__)
156
#define KMP_ARCH_ARMV6 1
157
#endif
158
159
#if defined(KMP_ARCH_ARMV6) || defined(__ARM_ARCH_5T__) || \
160
defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) || \
161
defined(__ARM_ARCH_5TEJ__)
162
#define KMP_ARCH_ARMV5 1
163
#endif
164
165
#if defined(KMP_ARCH_ARMV5) || defined(__ARM_ARCH_4__) || \
166
defined(__ARM_ARCH_4T__)
167
#define KMP_ARCH_ARMV4 1
168
#endif
169
170
#if defined(KMP_ARCH_ARMV4) || defined(__ARM_ARCH_3__) || \
171
defined(__ARM_ARCH_3M__)
172
#define KMP_ARCH_ARMV3 1
173
#endif
174
175
#if defined(KMP_ARCH_ARMV3) || defined(__ARM_ARCH_2__)
176
#define KMP_ARCH_ARMV2 1
177
#endif
178
179
#if defined(KMP_ARCH_ARMV2)
180
#define KMP_ARCH_ARM 1
181
#endif
182
183
#if defined(__MIC__) || defined(__MIC2__)
184
#define KMP_MIC 1
185
#if __MIC2__ || __KNC__
186
#define KMP_MIC1 0
187
#define KMP_MIC2 1
188
#else
189
#define KMP_MIC1 1
190
#define KMP_MIC2 0
191
#endif
192
#else
193
#define KMP_MIC 0
194
#define KMP_MIC1 0
195
#define KMP_MIC2 0
196
#endif
197
198
/* Specify 32 bit architectures here */
199
#define KMP_32_BIT_ARCH (KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_MIPS)
200
201
// Platforms which support Intel(R) Many Integrated Core Architecture
202
#define KMP_MIC_SUPPORTED \
203
((KMP_ARCH_X86 || KMP_ARCH_X86_64) && (KMP_OS_LINUX || KMP_OS_WINDOWS))
204
205
// TODO: Fixme - This is clever, but really fugly
206
#if (1 != \
207
KMP_ARCH_X86 + KMP_ARCH_X86_64 + KMP_ARCH_ARM + KMP_ARCH_PPC64 + \
208
KMP_ARCH_AARCH64 + KMP_ARCH_MIPS + KMP_ARCH_MIPS64)
209
#error Unknown or unsupported architecture
210
#endif
211
212
#endif // KMP_PLATFORM_H
Generated by
1.8.13