GEOS
coreComponents
common
GeosxMacros.hpp
Go to the documentation of this file.
1
/*
2
* ------------------------------------------------------------------------------------------------------------
3
* SPDX-License-Identifier: LGPL-2.1-only
4
*
5
* Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6
* Copyright (c) 2018-2024 TotalEnergies
7
* Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8
* Copyright (c) 2023-2024 Chevron
9
* Copyright (c) 2019- GEOS/GEOSX Contributors
10
* All rights reserved
11
*
12
* See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13
* ------------------------------------------------------------------------------------------------------------
14
*/
15
22
#include "
common/GeosxConfig.hpp
"
23
#include "LvArray/src/Macros.hpp"
24
25
#ifndef GEOS_COMMON_GEOSXMACROS_HPP_
26
#define GEOS_COMMON_GEOSXMACROS_HPP_
27
36
37
#if defined(GEOS_USE_DEVICE)
38
#define GEOS_HOST __host__
39
#define GEOS_DEVICE __device__
40
#define GEOS_HOST_DEVICE __host__ __device__
41
#define GEOS_FORCE_INLINE __forceinline__
42
#define PRAGMA_UNROLL _Pragma("unroll"
)
43
#else
45
#define GEOS_HOST
47
#define GEOS_DEVICE
49
#define GEOS_HOST_DEVICE
51
#define GEOS_FORCE_INLINE inline
53
#define PRAGMA_UNROLL
54
#endif
55
56
#if defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)
58
#define GEOS_DEVICE_COMPILE
59
#endif
60
62
70
72
#define GEOS_UNUSED_PARAM( X )
73
79
template
<
typename
... ARGS >
80
GEOS_HOST_DEVICE
inline
constexpr
81
void
i_g_n_o_r_e
( ARGS
const
& ... ) {}
82
84
#define GEOS_UNUSED_VAR( ... ) i_g_n_o_r_e( __VA_ARGS__ )
85
87
#define GEOS_DEBUG_VAR( ... ) GEOS_UNUSED_VAR( __VA_ARGS__ )
88
90
91
#if defined(GEOS_USE_OPENMP)
93
#define PRAGMA_OMP( clause ) _Pragma( clause )
94
// #define PRAGMA_OMP( clause ) _Pragma( STRINGIZE( omp clause ) )
95
#else
97
#define PRAGMA_OMP( clause )
98
#endif
99
101
#define GEOS_RESTRICT LVARRAY_RESTRICT
102
104
#define GEOS_RESTRICT_THIS LVARRAY_RESTRICT_THIS
105
107
#define GEOS_DECLTYPE_AUTO_RETURN decltype( auto )
108
110
#define GEOS_CONCAT_IMPL( A, B ) A ## B
111
113
#define GEOS_CONCAT( A, B ) GEOS_CONCAT_IMPL( A, B )
114
119
#if __cplusplus >= 201703L
120
#define GEOS_MAYBE_UNUSED [[maybe_unused]]
121
#else
122
// If not C++17 or later, check the compiler.
123
#ifdef _MSC_VER
124
// Microsoft Visual Studio
125
#define GEOS_MAYBE_UNUSED __pragma(warning(suppress: 4100))
126
#elif defined(__GNUC__) || defined(__clang__)
127
// GCC or Clang
128
#define GEOS_MAYBE_UNUSED __attribute__((unused))
129
#else
130
// If the compiler is unknown, we can't suppress the warning,
131
// so we define GEOS_MAYBE_UNUSED as an empty macro.
132
#define GEOS_MAYBE_UNUSED
133
#endif
134
#endif
135
142
144
#define GEOS_DETAIL_MORE_THAN_ONE_ARG_VALUE( _00, _01, _02, _03, _04, _05, _06, _07, \
145
_08, _09, _10, _11, _12, _13, _14, _15, \
146
_INDEX, ... ) _INDEX
147
152
#define GEOS_DETAIL_MORE_THAN_ONE_ARG( ... ) \
153
GEOS_DETAIL_MORE_THAN_ONE_ARG_VALUE( __VA_ARGS__, \
154
true, true, true, true, true, true, true, true, \
155
true, true, true, true, true, true, true, false, false )
156
158
160
#define GEOS_DETAIL_FIRST_ARG_false( FIRST ) FIRST
161
#define GEOS_DETAIL_FIRST_ARG_true( FIRST, ... ) FIRST
162
#define GEOS_DETAIL_FIRST_ARG_FUNC( COND ) GEOS_DETAIL_FIRST_ARG_ ## COND
163
#define GEOS_DETAIL_FIRST_ARG_DISPATCH( COND, ... ) GEOS_DETAIL_FIRST_ARG_FUNC( COND )(__VA_ARGS__)
164
166
#define GEOS_DETAIL_REST_ARGS_false( FIRST )
167
#define GEOS_DETAIL_REST_ARGS_true( FIRST, ... ) __VA_ARGS__
168
#define GEOS_DETAIL_REST_ARGS_FUNC( COND ) GEOS_DETAIL_REST_ARGS_ ## COND
169
#define GEOS_DETAIL_REST_ARGS_DISPATCH( COND, ... ) GEOS_DETAIL_REST_ARGS_FUNC( COND )(__VA_ARGS__)
170
172
#define GEOS_DETAIL_REST_PREP_ARGS_false( FIRST )
173
#define GEOS_DETAIL_REST_PREP_ARGS_true( FIRST, ... ) , __VA_ARGS__
174
#define GEOS_DETAIL_REST_PREP_ARGS_FUNC( COND ) GEOS_DETAIL_REST_PREP_ARGS_ ## COND
175
#define GEOS_DETAIL_REST_PREP_ARGS_DISPATCH( COND, ... ) GEOS_DETAIL_REST_PREP_ARGS_FUNC( COND )(__VA_ARGS__)
176
178
183
#define GEOS_DETAIL_FIRST_ARG( ... ) GEOS_DETAIL_FIRST_ARG_DISPATCH( GEOS_DETAIL_MORE_THAN_ONE_ARG( __VA_ARGS__ ), \
184
__VA_ARGS__ )
185
190
#define GEOS_DETAIL_REST_ARGS( ... ) GEOS_DETAIL_REST_ARGS_DISPATCH( GEOS_DETAIL_MORE_THAN_ONE_ARG( __VA_ARGS__ ), \
191
__VA_ARGS__ )
192
198
#define GEOS_DETAIL_REST_PREP_ARGS( ... ) GEOS_DETAIL_REST_PREP_ARGS_DISPATCH( GEOS_DETAIL_MORE_THAN_ONE_ARG( __VA_ARGS__ ), \
199
__VA_ARGS__ )
200
202
203
#endif
// GEOS_COMMON_GEOSXMACROS_HPP_
GeosxConfig.hpp
GEOS_HOST_DEVICE
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition:
GeosxMacros.hpp:49
i_g_n_o_r_e
constexpr void i_g_n_o_r_e(ARGS const &...)
Used to silence unused variable warnings, cuda doesn't respect casting to void.
Definition:
GeosxMacros.hpp:81
Generated by
1.9.1