FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
base_header.hpp
Go to the documentation of this file.
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
16// Include FEAT configuration header.
17#ifndef FEAT_NO_CONFIG
18# include <feat_config.hpp>
19#endif
20
21// Make sure the DOXYGEN macro is not defined at compile-time;
22// it is reserved for doxygen's preprocessor.
23#ifdef DOXYGEN
24# error The DOXYGEN macro must not be defined at compile-time
25#else
26# define DOXY(x)
27#endif
28
30// Activate DEBUG macro if the build system tells us to do so.
31#if defined(FEAT_DEBUG_MODE) && !defined(DEBUG)
32# define DEBUG 1
33#endif
34
35// macro used by compiler detection headers to build compiler version string
36#ifndef FEAT_STRINGIFY
37#define FEAT_STRINGIFY_HELPER(x) #x
38#define FEAT_STRINGIFY(x) FEAT_STRINGIFY_HELPER(x)
39#endif
40
41// macro used for macro concatenation
42#ifndef FEAT_CONCAT
43#define FEAT_CONCAT_HELPER(x,y) x##y
44#define FEAT_CONCAT(x,y) FEAT_CONCAT_HELPER(x,y)
45#endif
46
48
49// include compiler detection headers
50#include <kernel/util/compiler_intel_oneapi.hpp> // Intel(R) OneAPI C/C++ compiler // Needs to be included before classic intel and llvm and gnu compilers
51#include <kernel/util/compiler_intel.hpp> // Intel(R) C/C++ compiler
52#include <kernel/util/compiler_clang.hpp> // Clang/LLVM Compiler.
53#include <kernel/util/compiler_cray.hpp> // Cray C++ Compiler.
54#include <kernel/util/compiler_microsoft.hpp> // Microsoft(R) (Visual) C/C++ compiler
55// The GNU compiler must be the last one in this list, because other compilers (e.g. Intel and Clang)
56// also define the __GNUC__ macro used to identify the GNU C/C++ compiler, thus leading to incorrect
57// compiler detection.
58#include <kernel/util/compiler_gnu.hpp> // GNU C/C++ compiler
59#include <type_traits>
60
61// hide the following block from doxygen
63
64// If the compiler does not support a 'noinline' specifier, we'll define it as an empty macro.
65#ifndef NOINLINE
66#define NOINLINE
67#endif
68
69// If the compiler does not support a 'force-inline' specifier, we'll define it as a simple inline.
70#ifndef FORCE_INLINE
71#define FORCE_INLINE inline
72#endif
73
74// If the compiler does not support a loop vectorization specifier, we'll define it as an empty macro.
75#ifndef FEAT_PRAGMA_IVDEP
76#define FEAT_PRAGMA_IVDEP
77#endif
78
79// If the compiler does not support disabling/restoring warnings, we'll define the corresponding
80// macros as empty.
81#ifndef FEAT_DISABLE_WARNINGS
82#define FEAT_DISABLE_WARNINGS
83#endif
84#ifndef FEAT_RESTORE_WARNINGS
85#define FEAT_RESTORE_WARNINGS
86#endif
87
88// Unless the compiler detection header explicitly defined 'FEAT_PRAGMA_OMP', we define it as an OpenMP
89// pragma here, if the FEAT_HAVE_OMP define is set, otherwise we will define it as an empty macro.
90#ifndef FEAT_PRAGMA_OMP
91#ifdef FEAT_HAVE_OMP
92#define FEAT_PRAGMA_OMP_HELPER(x) _Pragma(#x)
93#define FEAT_PRAGMA_OMP(x) FEAT_PRAGMA_OMP_HELPER(omp x)
94#else
95#define FEAT_PRAGMA_OMP(x)
96#endif
97#endif
98
99// If we use the quadmath library, we can use this macro to define 128-bit floating point constants.
100#ifdef FEAT_HAVE_QUADMATH
101# define FEAT_F128C(x) x##Q
102#else
103# define FEAT_F128C(x) x
104#endif
105
107// end of block hidden from doxygen
108
109// include integer definition header from C/C++ standard library
110#include <cstdint>
111
115namespace FEAT
116{
118 static constexpr int version_major = 3;
120 static constexpr int version_minor = 2026;
122 static constexpr int version_patch = 11;
123
127#ifdef FEAT_INDEX_U32
128 typedef std::uint32_t Index;
129#else
130 typedef std::uint64_t Index;
131#endif
132
136 typedef double Real;
137
141 template <typename E>
142 constexpr auto to_underlying(E e) noexcept
143 {
144 return static_cast<std::underlying_type_t<E>>(e);
145 }
146
147#ifdef FEAT_ASYNC_OPERATIONS
148 static constexpr bool async_operations = true;
149#else
156 static constexpr bool async_operations = false;
157#endif
158} // namespace FEAT
159
160// define macros for nvcc
161// generally these macros have to be prepended to any function or method that could be (implicitly) used by a cuda kernel
162// since we do not always compile with nvcc directly (only cuda kernels themselves), we have to define the nvcc macros so
163// we do not get a compilation error
164#ifdef __NVCC__
167#define CUDA_HOST __host__
169#define CUDA_DEVICE __device__
171#define CUDA_HOST_DEVICE __host__ __device__
172#if defined(CUDART_VERSION) && (CUDART_VERSION >= 11020)
173 #define CUDA_ASYNC_SUPPORTED true
174#endif
175#else
176#define CUDA_HOST
177#define CUDA_DEVICE
178#define CUDA_HOST_DEVICE
179#endif
Compiler detection header for Clang C++ compiler.
Compiler detection header for Cray C++ compiler.
Compiler detection header for GNU C++ compiler.
Compiler detection header for Intel C++ compiler.
Compiler detection header for Microsoft Visual C++ compiler.
FEAT namespace.
Definition: adjactor.hpp:12
static constexpr bool async_operations
Controls if asynchronous operations should be used by default.
double Real
Real data type.
static constexpr int version_major
FEAT major version number.
static constexpr int version_patch
FEAT patch version number (month)
static constexpr int version_minor
FEAT minor version number (year)
constexpr auto to_underlying(E e) noexcept
Cast enum to underlying type.
std::uint64_t Index
Index data type.