Celeritas
0.5.0-56+6b053cd
|
Language and compiler abstraction macro definitions. More...
#include "corecel/Config.hh"
Macros | |
#define | CELER_FUNCTION |
Decorate a function that works on both host and device, with and without NVCC. More... | |
#define | CELER_FORCEINLINE inline |
#define | CELER_COMPILER_UNKNOWN 0 |
Detection for the current compiler isn't supported yet. | |
#define | CELER_COMPILER_CLANG 1 |
Compiling with clang, or a clang-based compiler defining clang (hipcc) | |
#define | CELER_COMPILER CELER_COMPILER_UNKNOWN |
Compare to on of the CELER_COMPILER_<compiler> macros to check which compiler is in use. More... | |
#define | CELER_FORCEINLINE_FUNCTION CELER_FUNCTION CELER_FORCEINLINE |
Like CELER_FUNCTION but forces inlining. More... | |
#define | CELER_CONSTEXPR_FUNCTION constexpr CELER_FORCEINLINE_FUNCTION |
Decorate a function that works on both host and device, with and without NVCC, can be evaluated at compile time, and should be forcibly inlined. | |
#define | CELER_UNLIKELY(COND) (COND) |
Mark the result of this condition to be "unlikely". More... | |
#define | CELER_UNREACHABLE |
Mark a point in code as being impossible to reach in normal execution. More... | |
#define | CELER_USE_DEVICE 0 |
True if HIP or CUDA are enabled, false otherwise. | |
#define | CELER_DEVICE_SOURCE 0 |
Defined and true if building a HIP or CUDA source file. More... | |
#define | CELER_DEVICE_COMPILE 0 |
Defined and true if building device code in HIP or CUDA. More... | |
#define | CELER_DEVICE_PREFIX(TOK) DEVICE_UNAVAILABLE |
Add a prefix "hip" or "cuda" to a code token. | |
#define | CELER_TRY_HANDLE(STATEMENT, HANDLE_EXCEPTION) |
"Try" to execute the statement, and "handle" all thrown errors by calling the given function-like error handler with a std::exception_ptr object. More... | |
#define | CELER_TRY_HANDLE_CONTEXT( STATEMENT, HANDLE_EXCEPTION, CONTEXT_EXCEPTION) |
Try the given statement, and if it fails, chain it into the given exception. More... | |
#define | CELER_DEFAULT_COPY_MOVE(CLS) |
Explicitly declare defaulted copy and move constructors and assignment operators. More... | |
#define | CELER_DELETE_COPY_MOVE(CLS) |
Explicitly declare deleted copy and move constructors and assignment operators. More... | |
#define | CELER_DEFAULT_MOVE_DELETE_COPY(CLS) |
Explicitly declare defaulted copy and move constructors and assignment operators. More... | |
#define | CELER_DISCARD(CODE) static_cast<void>(sizeof(CODE)); |
The argument is an unevaluated operand which will generate no code but force the expression to be used. More... | |
Language and compiler abstraction macro definitions.
The Macros file defines cross-platform (CUDA, C++, HIP) macros that expand to attributes depending on the compiler and build configuration.
#define CELER_COMPILER CELER_COMPILER_UNKNOWN |
Compare to on of the CELER_COMPILER_<compiler> macros to check which compiler is in use.
TODO: add and test more compilers as needed.
#define CELER_DEFAULT_COPY_MOVE | ( | CLS | ) |
Explicitly declare defaulted copy and move constructors and assignment operators.
Use this if the destructor is declared explicitly, or as part of the "protected" section of an interface class to prevent assignment between incompatible classes.
#define CELER_DEFAULT_MOVE_DELETE_COPY | ( | CLS | ) |
Explicitly declare defaulted copy and move constructors and assignment operators.
Use this if the destructor is declared explicitly.
#define CELER_DELETE_COPY_MOVE | ( | CLS | ) |
Explicitly declare deleted copy and move constructors and assignment operators.
Use this for scoped RAII classes.
#define CELER_DEVICE_COMPILE 0 |
Defined and true if building device code in HIP or CUDA.
This is a generic replacement for CUDA_ARCH
.
#define CELER_DEVICE_SOURCE 0 |
Defined and true if building a HIP or CUDA source file.
This is a generic replacement for CUDACC
.
#define CELER_DISCARD | ( | CODE | ) | static_cast<void>(sizeof(CODE)); |
The argument is an unevaluated operand which will generate no code but force the expression to be used.
This is used in place of the
attribute, which actually generates warnings in older versions of GCC.
#define CELER_FORCEINLINE_FUNCTION CELER_FUNCTION CELER_FORCEINLINE |
Like CELER_FUNCTION but forces inlining.
Compiler optimizers usually can tell what needs optimizing, but this function can provide speedups (and smaller sampling profiles) when inlining optimizations are not enabled. It should be used sparingly.
#define CELER_FUNCTION |
Decorate a function that works on both host and device, with and without NVCC.
The name of this function and its siblings is based on the Kokkos naming scheme.
#define CELER_TRY_HANDLE | ( | STATEMENT, | |
HANDLE_EXCEPTION | |||
) |
"Try" to execute the statement, and "handle" all thrown errors by calling the given function-like error handler with a std::exception_ptr
object.
<exception>
header (but since the HANDLE_EXCEPTION
needs to take an exception pointer, it's got to be included anyway). #define CELER_TRY_HANDLE_CONTEXT | ( | STATEMENT, | |
HANDLE_EXCEPTION, | |||
CONTEXT_EXCEPTION | |||
) |
Try the given statement, and if it fails, chain it into the given exception.
The given CONTEXT_EXCEPTION
must be an expression that yields an rvalue to a std::exception
subclass that isn't final
. The resulting chained exception will be passed into HANDLE_EXCEPTION
for processing.
#define CELER_UNLIKELY | ( | COND | ) | (COND) |
Mark the result of this condition to be "unlikely".
This asks the compiler to move the section of code to a "cold" part of the instructions, improving instruction locality. It should be used primarily for error checking conditions.
#define CELER_UNREACHABLE |
Mark a point in code as being impossible to reach in normal execution.
See https://clang.llvm.org/docs/LanguageExtensions.html#builtin-unreachable or https://msdn.microsoft.com/en-us/library/1b3fsfxw.aspx or https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#__builtin_unreachable
(The "unreachable" and "assume" compiler optimizations for CUDA are only available in API version 11.3 or higher, which is encoded as
).
CELER_ASSERT_UNREACHABLE()
defined in base/Assert.hh should be used instead (to provide a more detailed error message in case the point is reached).