From a1d402b2792f2b1338d1defab703eaedc0192729 Mon Sep 17 00:00:00 2001 From: "Noah S. Elliott" Date: Wed, 7 Aug 2024 09:57:28 -0700 Subject: [PATCH 01/11] Add constexpr to tbox::Dimension --- source/SAMRAI/tbox/Dimension.cpp | 11 ----------- source/SAMRAI/tbox/Dimension.h | 27 ++++++++++++++++----------- source/SAMRAI/tbox/Utilities.h | 21 +++++++++++++++++++++ 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/source/SAMRAI/tbox/Dimension.cpp b/source/SAMRAI/tbox/Dimension.cpp index 8e1b8fc5c..71e552ff7 100644 --- a/source/SAMRAI/tbox/Dimension.cpp +++ b/source/SAMRAI/tbox/Dimension.cpp @@ -12,17 +12,6 @@ namespace SAMRAI { namespace tbox { -Dimension::Dimension( - const unsigned short& dim):d_dim(dim) -{ - TBOX_DIM_ASSERT(dim > 0 && dim <= SAMRAI::MAX_DIM_VAL); -} - -Dimension::Dimension( - const Dimension& dimension):d_dim(dimension.d_dim) -{ -} - std::ostream& operator << ( std::ostream& s, diff --git a/source/SAMRAI/tbox/Dimension.h b/source/SAMRAI/tbox/Dimension.h index 8e39e8fc4..bf3a71611 100644 --- a/source/SAMRAI/tbox/Dimension.h +++ b/source/SAMRAI/tbox/Dimension.h @@ -55,19 +55,24 @@ class Dimension * * @pre (dim > 0) && (dim <= SAMRAI::MAX_DIM_VAL) */ - explicit Dimension( - const unsigned short& dim); + constexpr explicit Dimension( + const unsigned short& dim) : d_dim(dim) + { + TBOX_CONSTEXPR_DIM_ASSERT(dim > 0 && dim <= SAMRAI::MAX_DIM_VAL); + } /** * Construct a dimension equal to the argument. */ - Dimension( - const Dimension& dimension); + constexpr Dimension( + const Dimension& dimension) : d_dim(dimension.d_dim) + { + } /** * Equality operator. */ - bool + constexpr bool operator == ( const Dimension& rhs) const { @@ -77,7 +82,7 @@ class Dimension /** * Inequality operator. */ - bool + constexpr bool operator != ( const Dimension& rhs) const { @@ -87,7 +92,7 @@ class Dimension /** * Greater than operator. */ - bool + constexpr bool operator > ( const Dimension& rhs) const { @@ -97,7 +102,7 @@ class Dimension /** * Greater than or equal operator. */ - bool + constexpr bool operator >= ( const Dimension& rhs) const { @@ -107,7 +112,7 @@ class Dimension /** * Less than operator. */ - bool + constexpr bool operator < ( const Dimension& rhs) const { @@ -117,7 +122,7 @@ class Dimension /** * Less than or equal operator. */ - bool + constexpr bool operator <= ( const Dimension& rhs) const { @@ -132,7 +137,7 @@ class Dimension * used for comparisons, the Dimension comparison operations are * better suited for that purpose. */ - unsigned short + constexpr unsigned short getValue() const { return d_dim; diff --git a/source/SAMRAI/tbox/Utilities.h b/source/SAMRAI/tbox/Utilities.h index 5287e5e4a..c993ef605 100644 --- a/source/SAMRAI/tbox/Utilities.h +++ b/source/SAMRAI/tbox/Utilities.h @@ -347,6 +347,27 @@ typedef int mode_t; #endif +#ifdef DEBUG_CHECK_DIM_ASSERTIONS + +#define TBOX_CONSTEXPR_DIM_ASSERT(EXP) \ + do { \ + if (!(EXP)) { \ + printf("Failed dimension assertion: "); \ + printf( # EXP ); \ + printf("\n"); \ + SAMRAI::tbox::Utilities::abort("", __FILE__, __LINE__); \ + } \ + } while (0) + +#else + +/* + * No dimensional assertion checking + */ +#define TBOX_CONSTEXPR_DIM_ASSERT(EXP) + +#endif + /** * Throw an error assertion from within any C++ source code. This is * is similar to TBOX_ERROR(), but is designed to be invoked after a From 2e5a93af1207c7eba3e57e4bd6b7d062ea535168 Mon Sep 17 00:00:00 2001 From: "Noah S. Elliott" Date: Wed, 7 Aug 2024 10:54:10 -0700 Subject: [PATCH 02/11] Add constexpr to LocalId --- source/SAMRAI/hier/LocalId.cpp | 37 --------------- source/SAMRAI/hier/LocalId.h | 85 ++++++++++++++++++---------------- 2 files changed, 44 insertions(+), 78 deletions(-) diff --git a/source/SAMRAI/hier/LocalId.cpp b/source/SAMRAI/hier/LocalId.cpp index c4a3f3010..c9b697a43 100644 --- a/source/SAMRAI/hier/LocalId.cpp +++ b/source/SAMRAI/hier/LocalId.cpp @@ -20,43 +20,6 @@ LocalId::s_invalid_id( tbox::MathUtilities::getMax()); const LocalId LocalId::s_zero_id(0); -/* - ******************************************************************************* - ******************************************************************************* - */ -LocalId::LocalId(): - d_value(getInvalidId().d_value) { -} - -/* - ******************************************************************************* - ******************************************************************************* - */ -LocalId::LocalId( - const LocalId& other): - d_value(other.d_value) { -} - -/* - ******************************************************************************* - ******************************************************************************* - */ -LocalId::LocalId( - const int& value): - d_value(value) { -} - -/* - ******************************************************************************* - ******************************************************************************* - */ -LocalId::~LocalId() -{ -#ifdef DEBUG_CHECK_ASSERTIONS - d_value = s_invalid_id.d_value; -#endif -} - /* ******************************************************************************* ******************************************************************************* diff --git a/source/SAMRAI/hier/LocalId.h b/source/SAMRAI/hier/LocalId.h index e1225e97d..ebc8fb3df 100644 --- a/source/SAMRAI/hier/LocalId.h +++ b/source/SAMRAI/hier/LocalId.h @@ -35,26 +35,29 @@ class LocalId /*! * @brief Default constructor. */ - LocalId(); + constexpr LocalId() : d_value(getInvalidId().d_value) + { + } /*! * @brief Copy constructor. */ - LocalId( - const LocalId& other); + constexpr LocalId(const LocalId& other) = default; /*! * @brief Construct from a numerical value. * * This method is explicit to prevent automatic conversion. */ - explicit LocalId( - const int& value); + constexpr explicit LocalId( + const int& value) : d_value(value) + { + } /*! - * @brief Default constructor. + * @brief Default destructor. */ - ~LocalId(); + ~LocalId() = default; /*! * @brief Assignment operator. @@ -63,7 +66,7 @@ class LocalId * * @return @c *this */ - LocalId& + constexpr LocalId& operator = ( const LocalId& rhs) { @@ -78,7 +81,7 @@ class LocalId * * @return @c *this */ - LocalId& + constexpr LocalId& operator = ( const int& rhs) { @@ -89,7 +92,7 @@ class LocalId /*! * @brief Access the numerical value. */ - int& + constexpr int& getValue() { return d_value; @@ -98,7 +101,7 @@ class LocalId /*! * @brief Access the numerical value. */ - const int& + constexpr const int& getValue() const { return d_value; @@ -107,7 +110,7 @@ class LocalId /*! * @brief Whether value is a valid one (not equal to getInvalidId()). */ - bool + constexpr bool isValid() const { return d_value != s_invalid_id.getValue(); @@ -125,7 +128,7 @@ class LocalId /*! * @brief Get the designated invalid value for this class. */ - static const LocalId& + constexpr static const LocalId& getInvalidId() { return s_invalid_id; @@ -141,7 +144,7 @@ class LocalId * Pre-increment increments the value and returns the incremented * state. */ - LocalId + constexpr LocalId operator ++ () { ++d_value; @@ -154,7 +157,7 @@ class LocalId * Post-increment saves the value, increment it and returns an * object with the saved value. */ - LocalId + constexpr LocalId operator ++ ( int) { @@ -168,7 +171,7 @@ class LocalId * * @param[in] rhs */ - LocalId + constexpr LocalId operator + ( const LocalId& rhs) const { @@ -180,7 +183,7 @@ class LocalId * * @param[in] rhs */ - LocalId + constexpr LocalId operator - ( const LocalId& rhs) const { @@ -192,7 +195,7 @@ class LocalId * * @param[in] rhs */ - LocalId + constexpr LocalId operator * ( const LocalId& rhs) const { @@ -204,7 +207,7 @@ class LocalId * * @param[in] rhs */ - LocalId + constexpr LocalId operator / ( const LocalId& rhs) const { @@ -216,7 +219,7 @@ class LocalId * * @param[in] rhs */ - LocalId + constexpr LocalId operator % ( const LocalId& rhs) const { @@ -228,7 +231,7 @@ class LocalId * * @param[in] rhs */ - LocalId& + constexpr LocalId& operator += ( const LocalId& rhs) { @@ -241,7 +244,7 @@ class LocalId * * @param[in] rhs */ - LocalId& + constexpr LocalId& operator -= ( const LocalId& rhs) { @@ -254,7 +257,7 @@ class LocalId * * @param[in] rhs */ - LocalId + constexpr LocalId operator + ( const int& rhs) const { @@ -266,7 +269,7 @@ class LocalId * * @param[in] rhs */ - LocalId + constexpr LocalId operator - ( const int& rhs) const { @@ -278,7 +281,7 @@ class LocalId * * @param[in] rhs */ - LocalId + constexpr LocalId operator * ( const int& rhs) const { @@ -290,7 +293,7 @@ class LocalId * * @param[in] rhs */ - LocalId + constexpr LocalId operator / ( const int& rhs) const { @@ -302,7 +305,7 @@ class LocalId * * @param[in] rhs */ - LocalId + constexpr LocalId operator % ( const int& rhs) const { @@ -314,7 +317,7 @@ class LocalId * * @param[in] rhs */ - LocalId& + constexpr LocalId& operator += ( const int& rhs) { @@ -327,7 +330,7 @@ class LocalId * * @param[in] rhs */ - LocalId& + constexpr LocalId& operator -= ( const int& rhs) { @@ -348,7 +351,7 @@ class LocalId * * @param[in] rhs */ - bool + constexpr bool operator == ( const LocalId& rhs) const { @@ -362,7 +365,7 @@ class LocalId * * @param[in] rhs */ - bool + constexpr bool operator != ( const LocalId& rhs) const { @@ -376,7 +379,7 @@ class LocalId * * @param[in] rhs */ - bool + constexpr bool operator < ( const LocalId& rhs) const { @@ -390,7 +393,7 @@ class LocalId * * @param[in] rhs */ - bool + constexpr bool operator > ( const LocalId& rhs) const { @@ -404,7 +407,7 @@ class LocalId * * @param[in] rhs */ - bool + constexpr bool operator <= ( const LocalId& rhs) const { @@ -418,7 +421,7 @@ class LocalId * * @param[in] rhs */ - bool + constexpr bool operator >= ( const LocalId& rhs) const { @@ -438,7 +441,7 @@ class LocalId * * @param[in] rhs */ - bool + constexpr bool operator == ( const int& rhs) const { @@ -452,7 +455,7 @@ class LocalId * * @param[in] rhs */ - bool + constexpr bool operator != ( const int& rhs) const { @@ -466,7 +469,7 @@ class LocalId * * @param[in] rhs */ - bool + constexpr bool operator < ( const int& rhs) const { @@ -480,7 +483,7 @@ class LocalId * * @param[in] rhs */ - bool + constexpr bool operator > ( const int& rhs) const { @@ -494,7 +497,7 @@ class LocalId * * @param[in] rhs */ - bool + constexpr bool operator <= ( const int& rhs) const { @@ -508,7 +511,7 @@ class LocalId * * @param[in] rhs */ - bool + constexpr bool operator >= ( const int& rhs) const { From b4a06cbc0e592246f55f8df26372e9b006946348 Mon Sep 17 00:00:00 2001 From: "Noah S. Elliott" Date: Wed, 7 Aug 2024 11:26:05 -0700 Subject: [PATCH 03/11] Add constexpr to GlobalId --- source/SAMRAI/hier/GlobalId.cpp | 41 ------------------------------ source/SAMRAI/hier/GlobalId.h | 42 ++++++++++++++++++------------- source/SAMRAI/tbox/SAMRAI_MPI.cpp | 1 - source/SAMRAI/tbox/SAMRAI_MPI.h | 4 +-- 4 files changed, 27 insertions(+), 61 deletions(-) diff --git a/source/SAMRAI/hier/GlobalId.cpp b/source/SAMRAI/hier/GlobalId.cpp index 985afdd82..882d4b48f 100644 --- a/source/SAMRAI/hier/GlobalId.cpp +++ b/source/SAMRAI/hier/GlobalId.cpp @@ -14,47 +14,6 @@ namespace SAMRAI { namespace hier { -/* - ************************************************************************ - ************************************************************************ - */ -GlobalId::GlobalId(): - d_owner_rank(tbox::SAMRAI_MPI::getInvalidRank()), - d_local_id(LocalId::getInvalidId()) -{ -} - -/* - ************************************************************************ - ************************************************************************ - */ -GlobalId::GlobalId( - const LocalId& local_id, - const int owner): - d_owner_rank(owner), - d_local_id(local_id) -{ -} - -/* - ************************************************************************ - ************************************************************************ - */ -GlobalId::GlobalId( - const GlobalId& other): - d_owner_rank(other.d_owner_rank), - d_local_id(other.d_local_id) -{ -} - -/* - ************************************************************************ - ************************************************************************ - */ -GlobalId::~GlobalId() -{ -} - std::ostream& operator << ( std::ostream& co, diff --git a/source/SAMRAI/hier/GlobalId.h b/source/SAMRAI/hier/GlobalId.h index b85f81495..97864f911 100644 --- a/source/SAMRAI/hier/GlobalId.h +++ b/source/SAMRAI/hier/GlobalId.h @@ -49,32 +49,40 @@ class GlobalId * The object can be initialized using the assignment operator or * the non-const versions of the getOwnerRank() and getLocalId() methods. */ - GlobalId(); + constexpr GlobalId() : + d_owner_rank(tbox::SAMRAI_MPI::getInvalidRank()), + d_local_id(LocalId::getInvalidId()) + { + } /*! * @brief Initializing constructor. */ - GlobalId( + constexpr GlobalId( const LocalId& local_id, - const int owner_rank); + const int owner_rank) : + d_owner_rank(owner_rank), + d_local_id(local_id) + { + } /*! * @brief Copy constructor. * * @param[in] other */ - GlobalId( - const GlobalId& other); + constexpr GlobalId( + const GlobalId& other) = default; /*! * @brief Destructor. */ - ~GlobalId(); + ~GlobalId() = default; /*! * @brief Access the owner rank. */ - int& + constexpr int& getOwnerRank() { return d_owner_rank; @@ -83,7 +91,7 @@ class GlobalId /*! * @brief Access the owner rank. */ - const int& + constexpr const int& getOwnerRank() const { return d_owner_rank; @@ -92,7 +100,7 @@ class GlobalId /*! * @brief Access the LocalId. */ - LocalId& + constexpr LocalId& getLocalId() { return d_local_id; @@ -101,7 +109,7 @@ class GlobalId /*! * @brief Access the LocalId. */ - const LocalId& + constexpr const LocalId& getLocalId() const { return d_local_id; @@ -118,11 +126,11 @@ class GlobalId * owner values first; if they compare equal, compare the LocalId * next. */ - GlobalId& + constexpr GlobalId& operator = ( const GlobalId& r) = default; - bool + constexpr bool operator == ( const GlobalId& r) const { @@ -136,7 +144,7 @@ class GlobalId * * See note on comparison for operator==(const GlobalId&); */ - bool + constexpr bool operator != ( const GlobalId& r) const { @@ -150,7 +158,7 @@ class GlobalId * * See note on comparison for operator==(const GlobalId&); */ - bool + constexpr bool operator < ( const GlobalId& r) const { @@ -163,7 +171,7 @@ class GlobalId * * See note on comparison for operator==(const GlobalId&); */ - bool + constexpr bool operator > ( const GlobalId& r) const { @@ -176,7 +184,7 @@ class GlobalId * * See note on comparison for operator==(const GlobalId&); */ - bool + constexpr bool operator <= ( const GlobalId& r) const { @@ -190,7 +198,7 @@ class GlobalId * * See note on comparison for operator==(const GlobalId&); */ - bool + constexpr bool operator >= ( const GlobalId& r) const { diff --git a/source/SAMRAI/tbox/SAMRAI_MPI.cpp b/source/SAMRAI/tbox/SAMRAI_MPI.cpp index 29c260d98..6e5d49bf4 100644 --- a/source/SAMRAI/tbox/SAMRAI_MPI.cpp +++ b/source/SAMRAI/tbox/SAMRAI_MPI.cpp @@ -55,7 +55,6 @@ SAMRAI_MPI SAMRAI_MPI::s_samrai_world(MPI_COMM_NULL); bool SAMRAI_MPI::s_call_abort_in_serial_instead_of_exit = false; bool SAMRAI_MPI::s_call_abort_in_parallel_instead_of_mpiabort = false; -int SAMRAI_MPI::s_invalid_rank = -1; /* ************************************************************************** diff --git a/source/SAMRAI/tbox/SAMRAI_MPI.h b/source/SAMRAI/tbox/SAMRAI_MPI.h index 360be614c..2cd8a7d6b 100644 --- a/source/SAMRAI/tbox/SAMRAI_MPI.h +++ b/source/SAMRAI/tbox/SAMRAI_MPI.h @@ -176,7 +176,7 @@ class SAMRAI_MPI * This value is intended to be used by other classes as an invalid rank * number rather than using a hard-coded "magic" negative integer value. */ - static int + constexpr static int getInvalidRank() { return s_invalid_rank; @@ -909,7 +909,7 @@ class SAMRAI_MPI /*! * @brief Invalid (negative) rank number for getInvalidRank(). */ - static int s_invalid_rank; + static constexpr int s_invalid_rank = -1; //@{ //@name Structs for passing arguments to MPI From 3909ca92858961c940210d703c4ddd2057ea4c68 Mon Sep 17 00:00:00 2001 From: "Noah S. Elliott" Date: Wed, 7 Aug 2024 13:14:53 -0700 Subject: [PATCH 04/11] Add constexpr to PeriodicId --- source/SAMRAI/hier/PeriodicId.cpp | 36 ----------------------- source/SAMRAI/hier/PeriodicId.h | 48 ++++++++++++++++--------------- 2 files changed, 25 insertions(+), 59 deletions(-) diff --git a/source/SAMRAI/hier/PeriodicId.cpp b/source/SAMRAI/hier/PeriodicId.cpp index 00aab5617..f9b7b4217 100644 --- a/source/SAMRAI/hier/PeriodicId.cpp +++ b/source/SAMRAI/hier/PeriodicId.cpp @@ -17,42 +17,6 @@ namespace hier { const PeriodicId PeriodicId::s_invalid_id(-1); const PeriodicId PeriodicId::s_zero_id(0); -/* - ****************************************************************************** - ****************************************************************************** - */ -PeriodicId::PeriodicId(): - d_value(invalidId().d_value) { -} - -/* - ****************************************************************************** - ****************************************************************************** - */ -PeriodicId::PeriodicId( - const PeriodicId& other): - d_value(other.d_value) { -} - -/* - ****************************************************************************** - ****************************************************************************** - */ -PeriodicId::PeriodicId( - const int& value): - d_value(value) { -} - -/* - ****************************************************************************** - ****************************************************************************** - */ -PeriodicId::~PeriodicId() -{ -#ifdef DEBUG_CHECK_ASSERTIONS - d_value = s_invalid_id.d_value; -#endif -} /* ****************************************************************************** diff --git a/source/SAMRAI/hier/PeriodicId.h b/source/SAMRAI/hier/PeriodicId.h index a656d3924..e58439634 100644 --- a/source/SAMRAI/hier/PeriodicId.h +++ b/source/SAMRAI/hier/PeriodicId.h @@ -31,26 +31,32 @@ class PeriodicId /*! * @brief Default constructor. */ - PeriodicId(); + constexpr PeriodicId() : + d_value(invalidId().d_value) + { + } /*! * @brief Copy constructor. */ - PeriodicId( - const PeriodicId& other); + constexpr PeriodicId( + const PeriodicId& other) = default; /*! * @brief Construct from a numerical value. * * This method is explicit to prevent automatic conversion. */ - explicit PeriodicId( - const int& value); + constexpr explicit PeriodicId( + const int& value) : + d_value(value) + { + } /*! * @brief Default constructor. */ - ~PeriodicId(); + ~PeriodicId() = default; /*! * @brief Assignment operator. @@ -59,13 +65,9 @@ class PeriodicId * * @return @c *this */ - PeriodicId& + constexpr PeriodicId& operator = ( - const PeriodicId& rhs) - { - d_value = rhs.d_value; - return *this; - } + const PeriodicId& rhs) = default; /*! * @brief Assignment operator. @@ -74,7 +76,7 @@ class PeriodicId * * @return @c *this */ - PeriodicId& + constexpr PeriodicId& operator = ( const int& rhs) { @@ -85,7 +87,7 @@ class PeriodicId /*! * @brief Access the numerical value. */ - const int& + constexpr const int& getPeriodicValue() const { return d_value; @@ -94,7 +96,7 @@ class PeriodicId /*! * @brief Get the PeriodicId with a numerical value of zero. */ - static const PeriodicId& + constexpr static const PeriodicId& zero() { return s_zero_id; @@ -103,7 +105,7 @@ class PeriodicId /*! * @brief Return the invalid value for PeriodicId. */ - static const PeriodicId& + constexpr static const PeriodicId& invalidId() { return s_invalid_id; @@ -112,7 +114,7 @@ class PeriodicId /*! * @brief Returns True if the value is valid. */ - bool + constexpr bool isValid() const { return d_value >= 0; @@ -129,7 +131,7 @@ class PeriodicId * * @param[in] rhs */ - bool + constexpr bool operator == ( const PeriodicId& rhs) const { @@ -143,7 +145,7 @@ class PeriodicId * * @param[in] rhs */ - bool + constexpr bool operator != ( const PeriodicId& rhs) const { @@ -157,7 +159,7 @@ class PeriodicId * * @param[in] rhs */ - bool + constexpr bool operator < ( const PeriodicId& rhs) const { @@ -171,7 +173,7 @@ class PeriodicId * * @param[in] rhs */ - bool + constexpr bool operator > ( const PeriodicId& rhs) const { @@ -185,7 +187,7 @@ class PeriodicId * * @param[in] rhs */ - bool + constexpr bool operator <= ( const PeriodicId& rhs) const { @@ -199,7 +201,7 @@ class PeriodicId * * @param[in] rhs */ - bool + constexpr bool operator >= ( const PeriodicId& rhs) const { From 1ff86c5e2a0278c39529e03cc541072e0811bb4c Mon Sep 17 00:00:00 2001 From: "Noah S. Elliott" Date: Wed, 7 Aug 2024 16:54:42 -0700 Subject: [PATCH 05/11] Add constexpr to BoxId --- source/SAMRAI/hier/BoxId.cpp | 47 ------------------------ source/SAMRAI/hier/BoxId.h | 66 +++++++++++++++++++--------------- source/SAMRAI/tbox/Utilities.h | 20 +++++++++++ 3 files changed, 58 insertions(+), 75 deletions(-) diff --git a/source/SAMRAI/hier/BoxId.cpp b/source/SAMRAI/hier/BoxId.cpp index 9b9f2af25..22a3a674e 100644 --- a/source/SAMRAI/hier/BoxId.cpp +++ b/source/SAMRAI/hier/BoxId.cpp @@ -14,53 +14,6 @@ namespace SAMRAI { namespace hier { -/* - ************************************************************************ - * Constructors - ************************************************************************ - */ -BoxId::BoxId(): - d_global_id(), - d_periodic_id() -{ -} - -BoxId::BoxId( - const GlobalId& id, - const PeriodicId& periodic_id): - d_global_id(id), - d_periodic_id(periodic_id) -{ - TBOX_ASSERT(periodic_id.isValid()); -} - -BoxId::BoxId( - const LocalId& local_id, - const int owner, - const PeriodicId& periodic_id): - d_global_id(local_id, owner), - d_periodic_id(periodic_id) -{ - TBOX_ASSERT(periodic_id.isValid()); -} - -BoxId::BoxId( - const BoxId& r): - d_global_id(r.d_global_id), - d_periodic_id(r.d_periodic_id) -{ - TBOX_ASSERT(r.d_periodic_id.isValid()); -} - -/* - ************************************************************************ - * Destructor - ************************************************************************ - */ -BoxId::~BoxId() -{ -} - /* ****************************************************************************** * Stream-insert operator. diff --git a/source/SAMRAI/hier/BoxId.h b/source/SAMRAI/hier/BoxId.h index fbdbdcf16..77755113a 100644 --- a/source/SAMRAI/hier/BoxId.h +++ b/source/SAMRAI/hier/BoxId.h @@ -44,7 +44,7 @@ class BoxId * * The object can be changed using initialize() or by assignment. */ - BoxId(); + constexpr BoxId() = default; /*! * @brief Initializing constructor. @@ -57,10 +57,15 @@ class BoxId * * @pre periodic_id.isValid() */ - BoxId( + constexpr BoxId( const LocalId& local_id, const int owner_rank, - const PeriodicId& periodic_id = PeriodicId::zero()); + const PeriodicId& periodic_id = PeriodicId::zero()) : + d_global_id(local_id, owner_rank), + d_periodic_id(periodic_id) + { + TBOX_CONSTEXPR_ASSERT(periodic_id.isValid()); + } /*! * @brief Initializing constructor. @@ -71,9 +76,14 @@ class BoxId * * @pre periodic_id.isValid() */ - explicit BoxId( + constexpr explicit BoxId( const GlobalId& id, - const PeriodicId& periodic_id = PeriodicId::zero()); + const PeriodicId& periodic_id = PeriodicId::zero()) : + d_global_id(id), + d_periodic_id(periodic_id) + { + TBOX_CONSTEXPR_ASSERT(periodic_id.isValid()); + } /*! * @brief Copy constructor. @@ -82,13 +92,13 @@ class BoxId * * @pre other.periodic_id.isValid() */ - BoxId( - const BoxId& other); + constexpr BoxId( + const BoxId& other) = default; /*! * @brief Destructor. */ - ~BoxId(); + ~BoxId() = default; /*! * @brief Set all the attributes to given values. @@ -99,13 +109,13 @@ class BoxId * * @param[in] periodic_id */ - void + constexpr void initialize( const LocalId& local_id, const int owner_rank, const PeriodicId& periodic_id = PeriodicId::zero()) { - TBOX_ASSERT(periodic_id.isValid()); + TBOX_CONSTEXPR_ASSERT(periodic_id.isValid()); d_global_id.getLocalId() = local_id; d_global_id.getOwnerRank() = owner_rank; d_periodic_id = periodic_id; @@ -114,7 +124,7 @@ class BoxId /*! * @brief Access the GlobalId. */ - const GlobalId& + constexpr const GlobalId& getGlobalId() const { return d_global_id; @@ -123,7 +133,7 @@ class BoxId /*! * @brief Access the owner rank. */ - int + constexpr int getOwnerRank() const { return d_global_id.getOwnerRank(); @@ -151,7 +161,7 @@ class BoxId * @brief Whether the PeriodicId refers to a periodic * image. */ - bool + constexpr bool isPeriodicImage() const { return d_periodic_id != PeriodicId::zero(); @@ -161,7 +171,7 @@ class BoxId * @brief Whether the BoxId is valid--meaning it has a valid * GlobalId and PeriodicId. */ - bool + constexpr bool isValid() const { return d_periodic_id.isValid() && @@ -180,18 +190,18 @@ class BoxId * All comparison operators use the GlobalId and PeriodicId. */ - BoxId& + constexpr BoxId& operator = ( const BoxId& r) = default; - bool + constexpr bool operator == ( const BoxId& r) const { bool rval = d_global_id == r.d_global_id && d_periodic_id == r.d_periodic_id; - TBOX_ASSERT(d_periodic_id.isValid() && r.d_periodic_id.isValid()); + TBOX_CONSTEXPR_ASSERT(d_periodic_id.isValid() && r.d_periodic_id.isValid()); return rval; } @@ -200,11 +210,11 @@ class BoxId * * See note on comparison for operator==(const BoxId&); */ - bool + constexpr bool operator != ( const BoxId& r) const { - TBOX_ASSERT(d_periodic_id.isValid() && r.d_periodic_id.isValid()); + TBOX_CONSTEXPR_ASSERT(d_periodic_id.isValid() && r.d_periodic_id.isValid()); bool rval = d_global_id != r.d_global_id || d_periodic_id != r.d_periodic_id; return rval; @@ -216,11 +226,11 @@ class BoxId * Compare the owner ranks first; if they compare equal, compare the * LocalIds next; if they compare equal, compare the PeriodicIds. */ - bool + constexpr bool operator < ( const BoxId& r) const { - TBOX_ASSERT(d_periodic_id.isValid() && r.d_periodic_id.isValid()); + TBOX_CONSTEXPR_ASSERT(d_periodic_id.isValid() && r.d_periodic_id.isValid()); return d_global_id.getOwnerRank() < r.d_global_id.getOwnerRank() || (d_global_id.getOwnerRank() == r.d_global_id.getOwnerRank() && (d_global_id.getLocalId() < r.d_global_id.getLocalId() || @@ -234,11 +244,11 @@ class BoxId * Compare the owner ranks first; if they compare equal, compare the * LocalIds next; if they compare equal, compare the PeriodicIds. */ - bool + constexpr bool operator > ( const BoxId& r) const { - TBOX_ASSERT(d_periodic_id.isValid() && r.d_periodic_id.isValid()); + TBOX_CONSTEXPR_ASSERT(d_periodic_id.isValid() && r.d_periodic_id.isValid()); return d_global_id.getOwnerRank() > r.d_global_id.getOwnerRank() || (d_global_id.getOwnerRank() == r.d_global_id.getOwnerRank() && (d_global_id.getLocalId() > r.d_global_id.getLocalId() || @@ -249,22 +259,22 @@ class BoxId /*! * @brief Less-than-or-equal-to operator. */ - bool + constexpr bool operator <= ( const BoxId& r) const { - TBOX_ASSERT(d_periodic_id.isValid() && r.d_periodic_id.isValid()); + TBOX_CONSTEXPR_ASSERT(d_periodic_id.isValid() && r.d_periodic_id.isValid()); return *this < r || *this == r; } /*! * @brief Greater-than-or-equal-to operator. */ - bool + constexpr bool operator >= ( const BoxId& r) const { - TBOX_ASSERT(d_periodic_id.isValid() && r.d_periodic_id.isValid()); + TBOX_CONSTEXPR_ASSERT(d_periodic_id.isValid() && r.d_periodic_id.isValid()); return *this > r || *this == r; } @@ -280,7 +290,7 @@ class BoxId * * @see putToIntBuffer(), getFromIntBuffer(). */ - static int + constexpr static int commBufferSize() { return 3; diff --git a/source/SAMRAI/tbox/Utilities.h b/source/SAMRAI/tbox/Utilities.h index c993ef605..49aba1711 100644 --- a/source/SAMRAI/tbox/Utilities.h +++ b/source/SAMRAI/tbox/Utilities.h @@ -119,6 +119,26 @@ typedef int mode_t; #endif +#ifdef DEBUG_CHECK_ASSERTIONS + +#define TBOX_CONSTEXPR_ASSERT(EXP) \ + do { \ + if (!(EXP)) { \ + printf("Failed assertion: "); \ + printf( # EXP ); \ + printf("\n"); \ + SAMRAI::tbox::Utilities::abort("", __FILE__, __LINE__); \ + } \ + } while (0) +#else + +/* + * No assertion checking + */ +#define TBOX_CONSTEXPR_ASSERT(EXP) + +#endif + /*! * Throw an error assertion from within any C++ source code if the * given expression is not true. This is a parallel-friendly version From da65f0758831cdbdca51f96db8674a570a340dc4 Mon Sep 17 00:00:00 2001 From: "Noah S. Elliott" Date: Wed, 7 Aug 2024 17:19:27 -0700 Subject: [PATCH 06/11] Add constexpr to BlockId --- source/SAMRAI/hier/BlockId.cpp | 50 ----------------------- source/SAMRAI/hier/BlockId.h | 74 ++++++++++++++++++---------------- 2 files changed, 40 insertions(+), 84 deletions(-) diff --git a/source/SAMRAI/hier/BlockId.cpp b/source/SAMRAI/hier/BlockId.cpp index 7230c4237..0b9d0a8d2 100644 --- a/source/SAMRAI/hier/BlockId.cpp +++ b/source/SAMRAI/hier/BlockId.cpp @@ -21,56 +21,6 @@ BlockId::s_invalid_id( tbox::MathUtilities::getMax()); const BlockId BlockId::s_zero_id(0); -/* - ******************************************************************************* - ******************************************************************************* - */ -BlockId::BlockId(): - d_value(invalidId().d_value) -{ -} - -/* - ******************************************************************************* - ******************************************************************************* - */ -BlockId::BlockId( - const BlockId& other): - d_value(other.d_value) -{ -} - -/* - ******************************************************************************* - ******************************************************************************* - */ -BlockId::BlockId( - const unsigned int& value): - d_value(value) -{ -} - -/* - ******************************************************************************* - ******************************************************************************* - */ -BlockId::BlockId( - const int& value): - d_value(static_cast(value)) -{ - TBOX_ASSERT(value >=0); -} - -/* - ******************************************************************************* - ******************************************************************************* - */ -BlockId::~BlockId() -{ -#ifdef DEBUG_CHECK_ASSERTIONS - d_value = s_invalid_id.d_value; -#endif -} } } diff --git a/source/SAMRAI/hier/BlockId.h b/source/SAMRAI/hier/BlockId.h index 0ccdc4fe1..4b8d5b552 100644 --- a/source/SAMRAI/hier/BlockId.h +++ b/source/SAMRAI/hier/BlockId.h @@ -36,21 +36,27 @@ class BlockId /*! * @brief Default constructor sets the value to invalid. */ - BlockId(); + constexpr BlockId() : + d_value(invalidId().d_value) + { + } /*! * @brief Copy constructor. */ - BlockId( - const BlockId& other); + constexpr BlockId( + const BlockId& other) = default; /*! * @brief Construct from an unsigned int. * * This method is explicit to prevent automatic conversion. */ - explicit BlockId( - const unsigned int& value); + constexpr explicit BlockId( + const unsigned int& value) : + d_value(value) + { + } /*! * @brief Construct from a signed int. @@ -59,13 +65,17 @@ class BlockId * * @pre value >= 0 */ - explicit BlockId( - const int& value); + constexpr explicit BlockId( + const int& value) : + d_value(static_cast(value)) + { + TBOX_CONSTEXPR_ASSERT(value >=0); + } /*! * @brief Default constructor. */ - ~BlockId(); + ~BlockId() = default; /*! * @brief Assignment operator. @@ -74,28 +84,24 @@ class BlockId * * @return @c *this */ - BlockId& + constexpr BlockId& operator = ( - const BlockId& rhs) - { - d_value = rhs.d_value; - return *this; - } + const BlockId& rhs) = default; /*! * @brief Set to an int value. * * @param[in] rhs */ - void + constexpr void setId( const int& rhs) { - TBOX_ASSERT(rhs >= 0); + TBOX_CONSTEXPR_ASSERT(rhs >= 0); d_value = static_cast(rhs); } - void + constexpr void setId( const unsigned int& rhs) { @@ -105,16 +111,16 @@ class BlockId /*! * @brief Whether the value is valid. */ - bool + constexpr bool isValid() const { - return d_value != s_invalid_id.d_value; + return d_value != invalidId().d_value; } /*! * @brief Access the numerical value. */ - const block_t& + constexpr const block_t& getBlockValue() const { return d_value; @@ -123,7 +129,7 @@ class BlockId /*! * @brief Get the BlockId with a numerical value of zero. */ - static const BlockId& + constexpr static const BlockId& zero() { return s_zero_id; @@ -132,7 +138,7 @@ class BlockId /*! * @brief Get the designated invalid value for this class. */ - static const BlockId& + constexpr static const BlockId& invalidId() { return s_invalid_id; @@ -149,7 +155,7 @@ class BlockId * * @param[in] rhs */ - bool + constexpr bool operator == ( const BlockId& rhs) const { @@ -163,7 +169,7 @@ class BlockId * * @param[in] rhs */ - bool + constexpr bool operator != ( const BlockId& rhs) const { @@ -177,7 +183,7 @@ class BlockId * * @param[in] rhs */ - bool + constexpr bool operator < ( const BlockId& rhs) const { @@ -191,7 +197,7 @@ class BlockId * * @param[in] rhs */ - bool + constexpr bool operator > ( const BlockId& rhs) const { @@ -205,7 +211,7 @@ class BlockId * * @param[in] rhs */ - bool + constexpr bool operator <= ( const BlockId& rhs) const { @@ -219,7 +225,7 @@ class BlockId * * @param[in] rhs */ - bool + constexpr bool operator >= ( const BlockId& rhs) const { @@ -239,7 +245,7 @@ class BlockId * * @param[in] rhs */ - bool + constexpr bool operator == ( const block_t& rhs) const { @@ -253,7 +259,7 @@ class BlockId * * @param[in] rhs */ - bool + constexpr bool operator != ( const block_t& rhs) const { @@ -267,7 +273,7 @@ class BlockId * * @param[in] rhs */ - bool + constexpr bool operator < ( const block_t& rhs) const { @@ -281,7 +287,7 @@ class BlockId * * @param[in] rhs */ - bool + constexpr bool operator > ( const block_t& rhs) const { @@ -295,7 +301,7 @@ class BlockId * * @param[in] rhs */ - bool + constexpr bool operator <= ( const block_t& rhs) const { @@ -309,7 +315,7 @@ class BlockId * * @param[in] rhs */ - bool + constexpr bool operator >= ( const block_t& rhs) const { From f0064c0402b741bbdfeb1a3da8d9f5c7bc7c44fd Mon Sep 17 00:00:00 2001 From: "Noah S. Elliott" Date: Thu, 8 Aug 2024 10:53:15 -0700 Subject: [PATCH 07/11] Remove constexpr from a few methods not meant to be const --- source/SAMRAI/hier/BoxId.h | 18 ++++++++++-------- source/SAMRAI/hier/GlobalId.h | 4 ++-- source/SAMRAI/hier/LocalId.h | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/source/SAMRAI/hier/BoxId.h b/source/SAMRAI/hier/BoxId.h index 77755113a..1f2565689 100644 --- a/source/SAMRAI/hier/BoxId.h +++ b/source/SAMRAI/hier/BoxId.h @@ -95,6 +95,13 @@ class BoxId constexpr BoxId( const BoxId& other) = default; + /*! + * @brief Assignment operator + */ + constexpr BoxId& + operator = ( + const BoxId& r) = default; + /*! * @brief Destructor. */ @@ -109,7 +116,7 @@ class BoxId * * @param[in] periodic_id */ - constexpr void + void initialize( const LocalId& local_id, const int owner_rank, @@ -142,7 +149,7 @@ class BoxId /*! * @brief Access the LocalId. */ - const LocalId& + constexpr const LocalId& getLocalId() const { return d_global_id.getLocalId(); @@ -151,7 +158,7 @@ class BoxId /*! * @brief Access the PeriodicId. */ - const PeriodicId& + constexpr const PeriodicId& getPeriodicId() const { return d_periodic_id; @@ -190,11 +197,6 @@ class BoxId * All comparison operators use the GlobalId and PeriodicId. */ - constexpr BoxId& - operator = ( - const BoxId& r) = default; - - constexpr bool operator == ( const BoxId& r) const diff --git a/source/SAMRAI/hier/GlobalId.h b/source/SAMRAI/hier/GlobalId.h index 97864f911..3840b05b2 100644 --- a/source/SAMRAI/hier/GlobalId.h +++ b/source/SAMRAI/hier/GlobalId.h @@ -82,7 +82,7 @@ class GlobalId /*! * @brief Access the owner rank. */ - constexpr int& + int& getOwnerRank() { return d_owner_rank; @@ -100,7 +100,7 @@ class GlobalId /*! * @brief Access the LocalId. */ - constexpr LocalId& + LocalId& getLocalId() { return d_local_id; diff --git a/source/SAMRAI/hier/LocalId.h b/source/SAMRAI/hier/LocalId.h index ebc8fb3df..e16d7e567 100644 --- a/source/SAMRAI/hier/LocalId.h +++ b/source/SAMRAI/hier/LocalId.h @@ -92,7 +92,7 @@ class LocalId /*! * @brief Access the numerical value. */ - constexpr int& + int& getValue() { return d_value; From c5b0f6b674b8b5fc3533de9c09c65a117c03f34e Mon Sep 17 00:00:00 2001 From: "Noah S. Elliott" Date: Thu, 8 Aug 2024 14:03:53 -0700 Subject: [PATCH 08/11] Remove some constexpr usage that caused compilation difficulties --- source/SAMRAI/hier/BlockId.h | 8 ++++---- source/SAMRAI/hier/BoxId.h | 2 +- source/SAMRAI/hier/GlobalId.h | 2 +- source/SAMRAI/hier/LocalId.h | 4 ++-- source/SAMRAI/hier/PeriodicId.h | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/source/SAMRAI/hier/BlockId.h b/source/SAMRAI/hier/BlockId.h index 4b8d5b552..5e95b0903 100644 --- a/source/SAMRAI/hier/BlockId.h +++ b/source/SAMRAI/hier/BlockId.h @@ -37,7 +37,7 @@ class BlockId * @brief Default constructor sets the value to invalid. */ constexpr BlockId() : - d_value(invalidId().d_value) + d_value(s_invalid_id.d_value) { } @@ -114,7 +114,7 @@ class BlockId constexpr bool isValid() const { - return d_value != invalidId().d_value; + return d_value != s_invalid_id.d_value; } /*! @@ -129,7 +129,7 @@ class BlockId /*! * @brief Get the BlockId with a numerical value of zero. */ - constexpr static const BlockId& + static const BlockId& zero() { return s_zero_id; @@ -138,7 +138,7 @@ class BlockId /*! * @brief Get the designated invalid value for this class. */ - constexpr static const BlockId& + static const BlockId& invalidId() { return s_invalid_id; diff --git a/source/SAMRAI/hier/BoxId.h b/source/SAMRAI/hier/BoxId.h index 1f2565689..ba89d0894 100644 --- a/source/SAMRAI/hier/BoxId.h +++ b/source/SAMRAI/hier/BoxId.h @@ -44,7 +44,7 @@ class BoxId * * The object can be changed using initialize() or by assignment. */ - constexpr BoxId() = default; + BoxId() = default; /*! * @brief Initializing constructor. diff --git a/source/SAMRAI/hier/GlobalId.h b/source/SAMRAI/hier/GlobalId.h index 3840b05b2..93d49fe3d 100644 --- a/source/SAMRAI/hier/GlobalId.h +++ b/source/SAMRAI/hier/GlobalId.h @@ -49,7 +49,7 @@ class GlobalId * The object can be initialized using the assignment operator or * the non-const versions of the getOwnerRank() and getLocalId() methods. */ - constexpr GlobalId() : + GlobalId() : d_owner_rank(tbox::SAMRAI_MPI::getInvalidRank()), d_local_id(LocalId::getInvalidId()) { diff --git a/source/SAMRAI/hier/LocalId.h b/source/SAMRAI/hier/LocalId.h index e16d7e567..f71e81cbf 100644 --- a/source/SAMRAI/hier/LocalId.h +++ b/source/SAMRAI/hier/LocalId.h @@ -35,7 +35,7 @@ class LocalId /*! * @brief Default constructor. */ - constexpr LocalId() : d_value(getInvalidId().d_value) + constexpr LocalId() : d_value(s_invalid_id.d_value) { } @@ -128,7 +128,7 @@ class LocalId /*! * @brief Get the designated invalid value for this class. */ - constexpr static const LocalId& + static const LocalId& getInvalidId() { return s_invalid_id; diff --git a/source/SAMRAI/hier/PeriodicId.h b/source/SAMRAI/hier/PeriodicId.h index e58439634..c39384c8b 100644 --- a/source/SAMRAI/hier/PeriodicId.h +++ b/source/SAMRAI/hier/PeriodicId.h @@ -32,7 +32,7 @@ class PeriodicId * @brief Default constructor. */ constexpr PeriodicId() : - d_value(invalidId().d_value) + d_value(s_invalid_id.d_value) { } @@ -96,7 +96,7 @@ class PeriodicId /*! * @brief Get the PeriodicId with a numerical value of zero. */ - constexpr static const PeriodicId& + static const PeriodicId& zero() { return s_zero_id; @@ -105,7 +105,7 @@ class PeriodicId /*! * @brief Return the invalid value for PeriodicId. */ - constexpr static const PeriodicId& + static const PeriodicId& invalidId() { return s_invalid_id; From b898a40f94ecaef88e191d29f36dc2b401839410 Mon Sep 17 00:00:00 2001 From: "Noah S. Elliott" Date: Thu, 8 Aug 2024 14:57:40 -0700 Subject: [PATCH 09/11] Fix usage of statics in constexpr functions --- source/SAMRAI/hier/BlockId.cpp | 6 ++---- source/SAMRAI/hier/BlockId.h | 9 +++++++-- source/SAMRAI/hier/BoxId.h | 2 +- source/SAMRAI/hier/LocalId.cpp | 6 ++---- source/SAMRAI/hier/LocalId.h | 8 ++++++-- source/SAMRAI/hier/PeriodicId.cpp | 4 ++-- source/SAMRAI/hier/PeriodicId.h | 6 +++++- source/SAMRAI/tbox/MathUtilities.cpp | 7 ------- source/SAMRAI/tbox/MathUtilities.h | 8 ++++++-- 9 files changed, 31 insertions(+), 25 deletions(-) diff --git a/source/SAMRAI/hier/BlockId.cpp b/source/SAMRAI/hier/BlockId.cpp index 0b9d0a8d2..7c80920a9 100644 --- a/source/SAMRAI/hier/BlockId.cpp +++ b/source/SAMRAI/hier/BlockId.cpp @@ -16,10 +16,8 @@ namespace SAMRAI { namespace hier { -const BlockId -BlockId::s_invalid_id( - tbox::MathUtilities::getMax()); -const BlockId BlockId::s_zero_id(0); +const BlockId BlockId::s_invalid_id(s_invalid_val); +const BlockId BlockId::s_zero_id(s_zero_val); } diff --git a/source/SAMRAI/hier/BlockId.h b/source/SAMRAI/hier/BlockId.h index 5e95b0903..faa9b3b2f 100644 --- a/source/SAMRAI/hier/BlockId.h +++ b/source/SAMRAI/hier/BlockId.h @@ -12,6 +12,7 @@ #define included_hier_BlockId #include "SAMRAI/SAMRAI_config.h" +#include "SAMRAI/tbox/MathUtilities.h" #include "SAMRAI/tbox/Utilities.h" #include @@ -37,7 +38,7 @@ class BlockId * @brief Default constructor sets the value to invalid. */ constexpr BlockId() : - d_value(s_invalid_id.d_value) + d_value(s_invalid_val) { } @@ -114,7 +115,7 @@ class BlockId constexpr bool isValid() const { - return d_value != s_invalid_id.d_value; + return d_value != s_invalid_val; } /*! @@ -342,6 +343,10 @@ class BlockId */ unsigned int d_value; + static constexpr unsigned int s_zero_val = 0; + static constexpr unsigned int s_invalid_val = + tbox::MathUtilities::getMax(); + /*! * @brief BlockId with a numerical value of zero. */ diff --git a/source/SAMRAI/hier/BoxId.h b/source/SAMRAI/hier/BoxId.h index ba89d0894..0a2cf5d08 100644 --- a/source/SAMRAI/hier/BoxId.h +++ b/source/SAMRAI/hier/BoxId.h @@ -168,7 +168,7 @@ class BoxId * @brief Whether the PeriodicId refers to a periodic * image. */ - constexpr bool + bool isPeriodicImage() const { return d_periodic_id != PeriodicId::zero(); diff --git a/source/SAMRAI/hier/LocalId.cpp b/source/SAMRAI/hier/LocalId.cpp index c9b697a43..2e4be691a 100644 --- a/source/SAMRAI/hier/LocalId.cpp +++ b/source/SAMRAI/hier/LocalId.cpp @@ -15,10 +15,8 @@ namespace SAMRAI { namespace hier { -const LocalId -LocalId::s_invalid_id( - tbox::MathUtilities::getMax()); -const LocalId LocalId::s_zero_id(0); +const LocalId LocalId::s_invalid_id(s_invalid_val); +const LocalId LocalId::s_zero_id(s_zero_val); /* ******************************************************************************* diff --git a/source/SAMRAI/hier/LocalId.h b/source/SAMRAI/hier/LocalId.h index f71e81cbf..48846d979 100644 --- a/source/SAMRAI/hier/LocalId.h +++ b/source/SAMRAI/hier/LocalId.h @@ -12,6 +12,7 @@ #define included_hier_LocalId #include "SAMRAI/SAMRAI_config.h" +#include "SAMRAI/tbox/MathUtilities.h" #include @@ -35,7 +36,7 @@ class LocalId /*! * @brief Default constructor. */ - constexpr LocalId() : d_value(s_invalid_id.d_value) + constexpr LocalId() : d_value(s_invalid_val) { } @@ -113,7 +114,7 @@ class LocalId constexpr bool isValid() const { - return d_value != s_invalid_id.getValue(); + return d_value != s_invalid_val; } /*! @@ -534,6 +535,9 @@ class LocalId */ int d_value; + static constexpr int s_zero_val = 0; + static constexpr int s_invalid_val = tbox::MathUtilities::getMax(); + /*! * @brief LocalId with a numerical value of zero. */ diff --git a/source/SAMRAI/hier/PeriodicId.cpp b/source/SAMRAI/hier/PeriodicId.cpp index f9b7b4217..ec07a6fae 100644 --- a/source/SAMRAI/hier/PeriodicId.cpp +++ b/source/SAMRAI/hier/PeriodicId.cpp @@ -14,8 +14,8 @@ namespace SAMRAI { namespace hier { -const PeriodicId PeriodicId::s_invalid_id(-1); -const PeriodicId PeriodicId::s_zero_id(0); +const PeriodicId PeriodicId::s_invalid_id(s_invalid_val); +const PeriodicId PeriodicId::s_zero_id(s_zero_val); /* diff --git a/source/SAMRAI/hier/PeriodicId.h b/source/SAMRAI/hier/PeriodicId.h index c39384c8b..2d08b5a9c 100644 --- a/source/SAMRAI/hier/PeriodicId.h +++ b/source/SAMRAI/hier/PeriodicId.h @@ -32,7 +32,7 @@ class PeriodicId * @brief Default constructor. */ constexpr PeriodicId() : - d_value(s_invalid_id.d_value) + d_value(s_invalid_val) { } @@ -224,6 +224,10 @@ class PeriodicId */ int d_value; + static constexpr int s_zero_val = 0; + + static constexpr int s_invalid_val = -1; + /*! * @brief PeriodicId with a numerical value of zero. */ diff --git a/source/SAMRAI/tbox/MathUtilities.cpp b/source/SAMRAI/tbox/MathUtilities.cpp index 599df8d15..789ea19a6 100644 --- a/source/SAMRAI/tbox/MathUtilities.cpp +++ b/source/SAMRAI/tbox/MathUtilities.cpp @@ -153,13 +153,6 @@ MathUtilities::getSignalingNaN() return std::numeric_limits::signaling_NaN(); } -template -TYPE -MathUtilities::getMax() -{ - return std::numeric_limits::max(); -} - template TYPE MathUtilities::getMin() diff --git a/source/SAMRAI/tbox/MathUtilities.h b/source/SAMRAI/tbox/MathUtilities.h index 05813f3e0..7052b4fee 100644 --- a/source/SAMRAI/tbox/MathUtilities.h +++ b/source/SAMRAI/tbox/MathUtilities.h @@ -15,6 +15,7 @@ #include "SAMRAI/tbox/Complex.h" +#include #include namespace SAMRAI { @@ -138,8 +139,11 @@ class MathUtilities * parts set to the POSIX max value for type double. For * other types, will return the POSIX max value for the type. */ - static TYPE - getMax(); + constexpr static TYPE + getMax() + { + return std::numeric_limits::max(); + } /*! * @brief Set vector entries to value given by getMax(). From 84b9d95c74f7060bb535bba919d0eea5219f2c9e Mon Sep 17 00:00:00 2001 From: "Noah S. Elliott" Date: Thu, 8 Aug 2024 16:11:07 -0700 Subject: [PATCH 10/11] Change a CI compiler --- .gitlab/jobs/tioga.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab/jobs/tioga.yml b/.gitlab/jobs/tioga.yml index b949e98a7..e2efd0713 100644 --- a/.gitlab/jobs/tioga.yml +++ b/.gitlab/jobs/tioga.yml @@ -40,7 +40,7 @@ release_resources: #### # Build and test jobs for specific compilers, extends generic tioga build and # test job -cce_16_0_0_rocm_5_6_0: +cce_17_0_1_rocm_6.1.2: variables: - COMPILER: "cce-16.0.0-rocm-5.6.0" + COMPILER: "cce-17.0.1-rocm-6.1.2" extends: .job_on_tioga From fcf82abaf3759b4f6dcd8dae834e6db913bc2527 Mon Sep 17 00:00:00 2001 From: "Noah S. Elliott" Date: Thu, 8 Aug 2024 16:48:18 -0700 Subject: [PATCH 11/11] Change a CI compiler --- .gitlab/jobs/tioga.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab/jobs/tioga.yml b/.gitlab/jobs/tioga.yml index e2efd0713..6ab6fae37 100644 --- a/.gitlab/jobs/tioga.yml +++ b/.gitlab/jobs/tioga.yml @@ -40,7 +40,7 @@ release_resources: #### # Build and test jobs for specific compilers, extends generic tioga build and # test job -cce_17_0_1_rocm_6.1.2: +amdclang_rocm_6.0.2: variables: - COMPILER: "cce-17.0.1-rocm-6.1.2" + COMPILER: "amdclang-rocm-6.0.2-gfx90a" extends: .job_on_tioga