Loading [MathJax]/extensions/tex2jax.js
MAIA bb96820c
Multiphysics at AIA
|
Loading...
Searching...
No Matches
Go to the documentation of this file.
7#ifndef MAIA_COMPILER_H_
8#define MAIA_COMPILER_H_
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
27#define MAIA_PGI_COMPILER
29#define MAIA_CRAY_COMPILER
30#elif defined(_MSC_VER)
31#define MAIA_MS_COMPILER
33#define MAIA_SX_COMPILER
35#error Unsupported compiler
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)
47#elif defined(MAIA_MS_COMPILER)
48#define FUN_ __FUNCDNAME__
50#error Function name macro is NECESSARY and undefined for current compiler.
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
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
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
99#define ATTRIBUTE_NO_AUTOVEC
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
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
137#define ATTRIBUTE_PURE
139#define ATTRIBUTE_NO_AUTOVEC
140#elif defined(MAIA_IBM_COMPILER)
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
150#define ATTRIBUTE_PURE
152#define ATTRIBUTE_NO_AUTOVEC
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
163#define ATTRIBUTE_PURE
165#define ATTRIBUTE_NO_AUTOVEC
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
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)
208#if defined(MAIA_MS_COMPILER)
209#define M_PI 3.14159265359
211#define MAIA_DISABLE_DG
212#define MAIA_DISABLE_LB
222#if __cplusplus >= 201703
223#define IF_CONSTEXPR if constexpr
225#define IF_CONSTEXPR if
230#if defined(MAIA_NVHPC_COMPILER) && defined(MAIA_PSTL)
231#define WAR_NVHPC_PSTL