MAIA
bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
compiler_config.h
Go to the documentation of this file.
1
// Copyright (C) 2024 The m-AIA AUTHORS
2
//
3
// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
4
//
5
// SPDX-License-Identifier: LGPL-3.0-only
6
7
#ifndef MAIA_COMPILER_H_
8
#define MAIA_COMPILER_H_
12
14
#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__) && !defined(__NVCOMPILER) \
15
&& !defined(__PGI) && !defined(_CRAYC) && !defined(_SX) && !defined(__INTEL_LLVM_COMPILER)
16
#define MAIA_GCC_COMPILER
17
#elif defined(__clang__)
18
#define MAIA_CLANG_COMPILER
19
#elif defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER)
20
#define MAIA_INTEL_COMPILER
21
#elif defined(__IBMCPP__)
22
#define MAIA_IBM_COMPILER
23
#elif defined(__NVCOMPILER)
24
#define MAIA_NVHPC_COMPILER
25
#define MAIA_PGI_COMPILER
26
#elif defined(__PGI)
27
#define MAIA_PGI_COMPILER
28
#elif defined(_CRAYC)
29
#define MAIA_CRAY_COMPILER
30
#elif defined(_MSC_VER)
31
#define MAIA_MS_COMPILER
32
#elif defined(_SX)
33
#define MAIA_SX_COMPILER
34
#else
35
#error Unsupported compiler
36
#endif
37
40
#if defined(MAIA_GCC_COMPILER) || defined(MAIA_CLANG_COMPILER) || defined(MAIA_INTEL_COMPILER) \
41
|| defined(MAIA_NVHPC_COMPILER) || defined(MAIA_PGI_COMPILER)
42
#define FUN_ __PRETTY_FUNCTION__
43
#elif defined(MAIA_IBM_COMPILER)
44
#define FUN_ __FUNCTION__
45
#elif defined(MAIA_CRAY_COMPILER) || defined(MAIA_SX_COMPILER)
46
#define FUN_ __func__
47
#elif defined(MAIA_MS_COMPILER)
48
#define FUN_ __FUNCDNAME__
49
#else
50
#error Function name macro is NECESSARY and undefined for current compiler.
51
#endif
52
54
#if defined(USE_RESTRICT) \
55
&& (defined(MAIA_SX_COMPILER) || defined(MAIA_GCC_COMPILER) || defined(MAIA_CLANG_COMPILER) \
56
|| defined(MAIA_INTEL_COMPILER) || defined(MAIA_MS_COMPILER) || defined(MAIA_NVHPC_COMPILER) \
57
|| defined(MAIA_PGI_COMPILER))
58
#define RESTRICT __restrict
59
#elif defined(USE_RESTRICT) && defined(MAIA_IBM_COMPILER)
60
#error RESTRICT not implemented for the ibm compiler
61
#elif defined(USE_RESTRICT) && defined(MAIA_CRAY_COMPILER)
62
#error RESTRICT not implemented for the cray compiler
63
#elif defined(USE_RESTRICT)
64
#error RESTRICT is defined but compiler is unknown
65
#else
66
#define RESTRICT
67
#endif
68
69
70
// use default c++11 attribute specifier sequence
71
#if defined(COMPILER_ATTRIBUTES)
72
#define ATTRIBUTES1(a) [[a]]
73
#define ATTRIBUTES2(a, b) [[a, b]]
74
#define ATTRIBUTES3(a, b, c) [[a, b, c]]
75
#define ATTRIBUTES4(a, b, c, d) [[a, b, c, d]]
78
#define ATTRIBUTE_NORETURN noreturn
80
#define ATTRIBUTE_CARRIES_DEPENDENCY carries_dependency
81
#endif
82
84
#if defined(COMPILER_ATTRIBUTES) \
85
&& (defined(MAIA_GCC_COMPILER) || defined(MAIA_CLANG_COMPILER) || defined(MAIA_INTEL_COMPILER) \
86
|| defined(MAIA_NVHPC_COMPILER) || defined(MAIA_PGI_COMPILER))
88
#define ATTRIBUTE_FLATTEN gnu::flatten
91
#define ATTRIBUTE_ALWAYS_INLINE gnu::always_inline
94
#define ATTRIBUTE_HOT gnu::hot
96
#define ATTRIBUTE_PURE gnu::pure
98
//#define ATTRIBUTE_NO_AUTOVEC gnu::optimize("no-tree-vectorize")
99
#define ATTRIBUTE_NO_AUTOVEC
100
// todo labels:totest this should now be also supported in GCC and Clang
101
#elif defined(MAIA_MS_COMPILER)
103
#define ATTRIBUTE_FLATTEN
106
#define ATTRIBUTE_ALWAYS_INLINE
109
#define ATTRIBUTE_HOT hot
111
#define ATTRIBUTE_PURE
113
#define ATTRIBUTE_NO_AUTOVEC
114
#elif defined(COMPILER_ATTRIBUTES) && defined(MAIA_IBM_COMPILER)
115
#pragma message("WARNING: ATTRIBUTES are not implemented for the ibm compiler"
)
116
#define ATTRIBUTES1(a)
117
#define ATTRIBUTES2(a, b)
118
#define ATTRIBUTES3(a, b, c)
119
#define ATTRIBUTES4(a, b, c, d)
120
#define ATTRIBUTE_FLATTEN
121
#define ATTRIBUTE_NORETURN
122
#define ATTRIBUTE_ALWAYS_INLINE
123
#define ATTRIBUTE_HOT
124
#define ATTRIBUTE_PURE
126
#define ATTRIBUTE_NO_AUTOVEC
127
#elif defined(COMPILER_ATTRIBUTES) && defined(MAIA_CRAY_COMPILER)
128
#pragma message("WARNING: ATTRIBUTES are not implemented for the cray compiler"
)
129
#define ATTRIBUTES1(a)
130
#define ATTRIBUTES2(a, b)
131
#define ATTRIBUTES3(a, b, c)
132
#define ATTRIBUTES4(a, b, c, d)
133
#define ATTRIBUTE_FLATTEN
134
#define ATTRIBUTE_NORETURN
135
#define ATTRIBUTE_ALWAYS_INLINE
136
#define ATTRIBUTE_HOT
137
#define ATTRIBUTE_PURE
139
#define ATTRIBUTE_NO_AUTOVEC
140
#elif defined(MAIA_IBM_COMPILER)
141
// This is a fix for the IBM compiler until it supports the 'message' pragma
142
#define ATTRIBUTES1(a)
143
#define ATTRIBUTES2(a, b)
144
#define ATTRIBUTES3(a, b, c)
145
#define ATTRIBUTES4(a, b, c, d)
146
#define ATTRIBUTE_FLATTEN
147
#define ATTRIBUTE_NORETURN
148
#define ATTRIBUTE_ALWAYS_INLINE
149
#define ATTRIBUTE_HOT
150
#define ATTRIBUTE_PURE
152
#define ATTRIBUTE_NO_AUTOVEC
153
#else
154
#pragma message("WARNING: ATTRIBUTES are disabled"
)
155
#define ATTRIBUTES1(a)
156
#define ATTRIBUTES2(a, b)
157
#define ATTRIBUTES3(a, b, c)
158
#define ATTRIBUTES4(a, b, c, d)
159
#define ATTRIBUTE_FLATTEN
160
#define ATTRIBUTE_NORETURN
161
#define ATTRIBUTE_ALWAYS_INLINE
162
#define ATTRIBUTE_HOT
163
#define ATTRIBUTE_PURE
165
#define ATTRIBUTE_NO_AUTOVEC
166
#endif
167
168
// todo labels:toenhance,totest allignas is now fully supported by both GCC and CLANG. Change and test!!!
169
#if defined(USE_ALIGNMENT) && (defined(MAIA_GCC_COMPILER) || defined(MAIA_CLANG_COMPILER))
170
#define ALIGNED_F(a) static_cast<const MFloat*>(__builtin_assume_aligned((a), sizeof(MFloat)))
171
#define ALIGNED_I(a) static_cast<const MInt*>(__builtin_assume_aligned((a), sizeof(MInt)))
172
#define ALIGNED_L(a) static_cast<const MLong*>(__builtin_assume_aligned((a), sizeof(MLong)))
173
#define ALIGNED_MF(a) static_cast<MFloat*>(__builtin_assume_aligned((a), sizeof(MFloat)))
174
#define ALIGNED_MI(a) static_cast<MInt*>(__builtin_assume_aligned((a), sizeof(MInt)))
175
#define ALIGNED_ML(a) static_cast<MLong*>(__builtin_assume_aligned((a), sizeof(MLong)))
176
#elif defined(USE_ALIGNMENT) && defined(MAIA_MS_COMPILER)
177
#define ALIGNED_F(a) alignas(sizeof(MFloat)) a
178
#define ALIGNED_I(a) alignas(sizeof(MInt)) a
179
#define ALIGNED_L(a) alignas(sizeof(MLong)) a
180
#define ALIGNED_MF(a) alignas(sizeof(MFloat)) a
181
#define ALIGNED_MI(a) alignas(sizeof(MInt)) a
182
#define ALIGNED_ML(a) alignas(sizeof(MLong)) a
183
#elif defined(USE_ALIGNMENT) && defined(MAIA_INTEL_COMPILER)
184
#error ALIGNMENT not implemented for intel compiler
185
#elif defined(USE_ALIGNMENT) && defined(MAIA_IBM_COMPILER)
186
#error ALIGNMENT not implemented for ibm compiler
187
#elif defined(USE_ALIGNMENT) && defined(MAIA_PGI_COMPILER)
188
#error ALIGNMENT not implemented for pgi compiler
189
#elif defined(USE_ALIGNMENT) && defined(MAIA_NVHPC_COMPILER)
190
#error ALIGNMENT not implemented for nvhpc compiler
191
#elif defined(USE_ALIGNMENT) && defined(MAIA_CRAY_COMPILER)
192
#error ALIGNMENT not implemented for cray compiler
193
#elif defined(USE_ALIGNMENT) && defined(MAIA_SX_COMPILER)
194
#error ALIGNMENT not implemented for NEC SX compiler
195
#elif defined(USE_ALIGNMENT)
196
#error ALIGNMENT is defined but compiler is unknown
197
#else
198
#define ALIGNED_F(a) (a)
199
#define ALIGNED_I(a) (a)
200
#define ALIGNED_F(a) (a)
201
#define ALIGNED_MF(a) (a)
202
#define ALIGNED_MI(a) (a)
203
#define ALIGNED_MF(a) (a)
204
205
206
#endif
207
208
#if defined(MAIA_MS_COMPILER)
209
#define M_PI 3.14159265359
210
#define NOMINMAX
211
#define MAIA_DISABLE_DG
// unsure but not needed
212
#define MAIA_DISABLE_LB
// problems with postprocessing solver
213
#endif
214
215
// Enable certain settings to ensure Windows compatibility
216
#if defined(_WIN64)
217
#define MAIA_WINDOWS
218
#define WITH_HDF5
219
#endif
220
221
// Replace 'IF_CONSTEXPR' by 'if constexpr' after switching to C++17
222
#if __cplusplus >= 201703
223
#define IF_CONSTEXPR if constexpr
224
#else
225
#define IF_CONSTEXPR if
226
#endif
227
228
// TODO labels:gpu This is a work around label used at certain location to
229
// handle nvhpc's bug of static constexpr
230
#if defined(MAIA_NVHPC_COMPILER) && defined(MAIA_PSTL)
231
#define WAR_NVHPC_PSTL
232
#endif
233
234
#endif
// MAIA_COMPILER_H_
home
gitlab-runner
scratch
builds
oxpnswJ6
1
aia
m-AIA
m-AIA
src
compiler_config.h
Generated on Sun Jun 16 2024 23:43:58 for MAIA by
1.9.5