DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
Macros.hpp
Go to the documentation of this file.
1#pragma once
2/// @file Macros.hpp
3/// @brief Project-wide preprocessor flags, branch-hint macros, and version/build
4/// metadata strings. Included first by @ref Defines.hpp.
5
6#include <string>
7
8// #define EIGEN_USE_BLAS
9// #define EIGEN_USE_LAPACKE_STRICT
10
11/// @brief Enable Eigen's C++14 variable templates extension.
12#define EIGEN_HAS_CXX14_VARIABLE_TEMPLATES 1
13
14/// @brief Disable Eigen's own OpenMP parallelisation. DNDSR controls
15/// threading explicitly through OpenMP parallel regions in the solvers.
16#define EIGEN_DONT_PARALLELIZE 1
17
18/// @brief Runtime-inspectable summary of which optional Eigen backends are compiled in.
19static const std::string DNDS_Macros_State = std::string("DNDS_Macros ")
20#ifdef EIGEN_USE_BLAS
21 + " EIGEN_USE_BLAS "
22#endif
23#ifdef EIGEN_USE_LAPACKE_STRICT
24 + " EIGEN_USE_LAPACKE_STRICT "
25#endif
26 ;
27
28#if defined(__GNUC__) || defined(__clang__)
29// GCC and Clang support __builtin_expect
30/// @brief Branch-prediction hint: mark `x` as the likely branch. Maps to
31/// `__builtin_expect(x, 1)` on GCC/Clang; no-op elsewhere.
32# define DNDS_likely(x) (__builtin_expect((x), 1))
33/// @brief Branch-prediction hint: mark `x` as the unlikely branch. Maps to
34/// `__builtin_expect(x, 0)` on GCC/Clang; no-op elsewhere.
35# define DNDS_unlikely(x) (__builtin_expect((x), 0))
36#elif defined(_MSC_VER)
37// MSVC does not support __builtin_expect
38# define DNDS_likely(x) (x)
39# define DNDS_unlikely(x) (x)
40#else
41// For other compilers, default to no-op
42# define DNDS_likely(x) (x)
43# define DNDS_unlikely(x) (x)
44#endif
45
46// experimental macros
47
48#include "Experimentals.hpp"
49
50/// @brief Runtime-inspectable build configuration summary: NDEBUG / NINSERT / experimental flags.
51static const std::string DNDS_Defines_state =
52 std::string("DNDS_Defines ") + DNDS_Macros_State + DNDS_Experimentals_State
53#ifdef NDEBUG
54 + " NDEBUG "
55#else
56 + " (no NDEBUG) "
57#endif
58#ifdef NINSERT
59 + " NINSERT "
60#else
61 + " (no NINSERT) "
62#endif
63 ;
64
65#ifndef DNDS_CURRENT_COMMIT_HASH
66/// @brief Fallback when the build system did not inject the git hash.
67# define DNDS_CURRENT_COMMIT_HASH UNKNOWN
68#endif
69
70#ifndef DNDS_VERSION_STRING
71/// @brief Fallback when the build system did not inject the version string.
72# define DNDS_VERSION_STRING "unknown"
73#endif
74
75/// @brief Stringize a macro value after a round of expansion. `DNDS_MACRO_TO_STRING(FOO)` yields the textual value of `FOO`.
76#define DNDS_MACRO_TO_STRING(V) __DNDS_str(V)
77#define __DNDS_str(V) #V
78
79#if defined(__DNDS_REALLY_COMPILING__)
80/// @brief Pick between "real compilation" and "IntelliSense preview" tokens.
81/// @details IDEs that parse the project with `__DNDS_REALLY_COMPILING__` undefined
82/// substitute the `intellisense` branch, letting us hide heavy template paths
83/// from the editor's code model while keeping the `real` branch in actual builds.
84# define DNDS_SWITCH_INTELLISENSE(real, intellisense) real
85#else
86# define DNDS_SWITCH_INTELLISENSE(real, intellisense) intellisense
87#endif
88
89// warning pragmas
90
91#include "Warnings.hpp"
Compile-time feature flags for experimental / research code paths.
Cross-compiler macros for saving / restoring / disabling warnings.