AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
Macros.hpp File Reference
#include "axom/config.hpp"
#include <cassert>

Macros

#define AXOM_DEVICE
 
#define AXOM_HOST_DEVICE
 CUDA or HIP host/device macros for decorating functions/lambdas. More...
 
#define AXOM_HOST
 
#define AXOM_LAMBDA   [=]
 Convenience macro used for lambda capture by value. More...
 
#define AXOM_DEVICE_LAMBDA   [=]
 
#define AXOM_HOST_LAMBDA   [=]
 
#define AXOM_STRINGIFY(x)   AXOM_DO_STRINGIFY(x)
 
#define AXOM_DO_STRINGIFY(x)   #x
 
#define AXOM_PRAGMA(x)   _Pragma(AXOM_STRINGIFY(x))
 
#define AXOM_SUPPRESS_HD_WARN
 
#define AXOM_CUDA_TEST(X, Y)   TEST(X, Y)
 Convenience macro used for a gtest that uses cuda. More...
 
#define AXOM_UNUSED_PARAM(x)
 Macro used to silence compiler warnings in methods with unused arguments. More...
 
#define AXOM_STATIC_ASSERT(cond)   static_assert(cond, #cond)
 
#define AXOM_STATIC_ASSERT_MSG(cond, MSG)   static_assert(cond, MSG)
 This macro wraps the compile time static_assert functionality so you don't have to provide a message. More...
 
#define AXOM_UNUSED_VAR(_x)   static_cast<void>(_x)
 Macro used to silence compiler warnings about variables that are defined but not used. More...
 
#define AXOM_DEBUG_PARAM(_x)   _x
 Macro used to silence compiler warnings about parameters that are only used when AXOM_DEBUG is defined. More...
 
#define DISABLE_DEFAULT_CTOR(className)   className() = delete
 Macro to disable default constructor for the given class. More...
 
#define DISABLE_COPY_AND_ASSIGNMENT(className)
 Macro to disable copy and assignment operations for the given class. More...
 
#define DISABLE_MOVE_AND_ASSIGNMENT(className)
 Macro to disable move constructor and move assignment operations for the given class. More...
 
#define AXOM_TYPED_TEST(CaseName, TestName)
 Minor tweak of gtest's TYPED_TEST macro to work with device code. More...
 

Macro Definition Documentation

◆ AXOM_DEVICE

#define AXOM_DEVICE

◆ AXOM_HOST_DEVICE

#define AXOM_HOST_DEVICE

CUDA or HIP host/device macros for decorating functions/lambdas.

Note
These will expand to the corresponding CUDA/HIP decorations when compiled with -DAXOM_USE_CUDA or -DAXOM_USE_HIP

◆ AXOM_HOST

#define AXOM_HOST

◆ AXOM_LAMBDA

#define AXOM_LAMBDA   [=]

Convenience macro used for lambda capture by value.

Note
When CUDA or HIP is used, the macro always expands to a host/device lambda.

◆ AXOM_DEVICE_LAMBDA

#define AXOM_DEVICE_LAMBDA   [=]

◆ AXOM_HOST_LAMBDA

#define AXOM_HOST_LAMBDA   [=]

◆ AXOM_STRINGIFY

#define AXOM_STRINGIFY (   x)    AXOM_DO_STRINGIFY(x)

◆ AXOM_DO_STRINGIFY

#define AXOM_DO_STRINGIFY (   x)    #x

◆ AXOM_PRAGMA

#define AXOM_PRAGMA (   x)    _Pragma(AXOM_STRINGIFY(x))

◆ AXOM_SUPPRESS_HD_WARN

#define AXOM_SUPPRESS_HD_WARN

◆ AXOM_CUDA_TEST

#define AXOM_CUDA_TEST (   X,
 
)    TEST(X, Y)

Convenience macro used for a gtest that uses cuda.

◆ AXOM_UNUSED_PARAM

#define AXOM_UNUSED_PARAM (   x)

Macro used to silence compiler warnings in methods with unused arguments.

Note
The intent is to use this macro in the function signature. For example:
void my_function(int x, int AXOM_UNUSED_PARAM(y))
{
// my implementation
}
#define AXOM_UNUSED_PARAM(x)
Macro used to silence compiler warnings in methods with unused arguments.
Definition: Macros.hpp:146

◆ AXOM_STATIC_ASSERT

#define AXOM_STATIC_ASSERT (   cond)    static_assert(cond, #cond)

◆ AXOM_STATIC_ASSERT_MSG

#define AXOM_STATIC_ASSERT_MSG (   cond,
  MSG 
)    static_assert(cond, MSG)

This macro wraps the compile time static_assert functionality so you don't have to provide a message.

◆ AXOM_UNUSED_VAR

#define AXOM_UNUSED_VAR (   _x)    static_cast<void>(_x)

Macro used to silence compiler warnings about variables that are defined but not used.

Note
The intent is to use this macro for variables that are only used within compiler defines (e.g. in debug assertions). For example:
double myVar = ...
AXOM_UNUSED_VAR(myVar);
// code emits the following warning in release builds
// if extra warnings are enabled and this macro is not called
// warning: unused variable 'myVar' [-Wunused-variable]
SLIC_ASSERT(myVar > 0)
#define SLIC_ASSERT(EXP)
Asserts that a given expression is true. If the expression is not true an error will be logged and th...
Definition: slic_macros.hpp:336

◆ AXOM_DEBUG_PARAM

#define AXOM_DEBUG_PARAM (   _x)    _x

Macro used to silence compiler warnings about parameters that are only used when AXOM_DEBUG is defined.

Note
Default values are ok
void my_function(int x, int AXOM_DEBUG_PARAM(y))
{
// my implementation
SLIC_ASSERT(y > 0)
}
#define AXOM_DEBUG_PARAM(_x)
Macro used to silence compiler warnings about parameters that are only used when AXOM_DEBUG is define...
Definition: Macros.hpp:197

◆ DISABLE_DEFAULT_CTOR

#define DISABLE_DEFAULT_CTOR (   className)    className() = delete

Macro to disable default constructor for the given class.

Note
This macro should only be used within the private section of a class, as indicated in the example below.
class Foo
{
public:
// Public methods here
private:
};
#define DISABLE_DEFAULT_CTOR(className)
Macro to disable default constructor for the given class.
Definition: Macros.hpp:222

◆ DISABLE_COPY_AND_ASSIGNMENT

#define DISABLE_COPY_AND_ASSIGNMENT (   className)
Value:
className(const className&) = delete; \
className& operator=(const className&) = delete

Macro to disable copy and assignment operations for the given class.

Note
This macro should only be used within the private section of a class, as indicated in the example below.
class Foo
{
public:
Foo();
~Foo();
// Other methods here
private:
};
#define DISABLE_COPY_AND_ASSIGNMENT(className)
Macro to disable copy and assignment operations for the given class.
Definition: Macros.hpp:246

◆ DISABLE_MOVE_AND_ASSIGNMENT

#define DISABLE_MOVE_AND_ASSIGNMENT (   className)
Value:
className(className&&) = delete; \
className& operator=(className&&) = delete

Macro to disable move constructor and move assignment operations for the given class.

Note
This macro should only be used within the private section of a class, as indicated in the example below.
class Foo
{
public:
Foo();
~Foo();
// Other methods here
private:
};
#define DISABLE_MOVE_AND_ASSIGNMENT(className)
Macro to disable move constructor and move assignment operations for the given class.
Definition: Macros.hpp:273

◆ AXOM_TYPED_TEST

#define AXOM_TYPED_TEST (   CaseName,
  TestName 
)
Value:
static_assert(sizeof(GTEST_STRINGIFY_(TestName)) > 1, \
"test-name must not be empty"); \
template <typename gtest_TypeParam_> \
class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \
: public CaseName<gtest_TypeParam_> \
{ \
public: \
typedef CaseName<gtest_TypeParam_> TestFixture; \
typedef gtest_TypeParam_ TypeParam; \
void TestBody() override; \
}; \
static bool gtest_##CaseName##_##TestName##_registered_ GTEST_ATTRIBUTE_UNUSED_ = \
::testing::internal::TypeParameterizedTest< \
CaseName, \
::testing::internal::TemplateSel<GTEST_TEST_CLASS_NAME_(CaseName, TestName)>, \
GTEST_TYPE_PARAMS_(CaseName)>:: \
Register( \
"", \
::testing::internal::CodeLocation(__FILE__, __LINE__), \
GTEST_STRINGIFY_(CaseName), \
GTEST_STRINGIFY_(TestName), \
0, \
::testing::internal::GenerateNames<GTEST_NAME_GENERATOR_(CaseName), \
GTEST_TYPE_PARAMS_(CaseName)>()); \
template <typename gtest_TypeParam_> \
void GTEST_TEST_CLASS_NAME_(CaseName, TestName)<gtest_TypeParam_>::TestBody()

Minor tweak of gtest's TYPED_TEST macro to work with device code.

Note
Can be used in test files after including gtest/gtest.h