Skip to content

Commit

Permalink
Tpetra: Fixing Issue #13034 (#13036)
Browse files Browse the repository at this point in the history
* Update Tpetra_Details_FixedHashTable_decl.hpp

* Tpetra: Adding associated test

* Update packages/tpetra/core/test/HashTable/FixedHashTableTest.cpp

Co-authored-by: Tomasetti Romin <[email protected]>

* Update packages/tpetra/core/src/Tpetra_Details_FixedHashTable_decl.hpp

Co-authored-by: Tomasetti Romin <[email protected]>

* Update Tpetra_Details_FixedHashTable_decl.hpp

* Update packages/tpetra/core/src/Tpetra_Details_FixedHashTable_decl.hpp

Co-authored-by: Tomasetti Romin <[email protected]>

* Update FixedHashTableTest.cpp

---------

Co-authored-by: Tomasetti Romin <[email protected]>
  • Loading branch information
csiefer2 and romintomasetti authored Jun 7, 2024
1 parent a6fd730 commit 0d278ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,7 @@ class FixedHashTable {
/// In Tpetra::Map, this corresponds to the maximum global index
/// (local to the MPI process).
/// @remark It will be set in @ref init.
KeyType maxKey_ = ::Kokkos::ArithTraits<KeyType>::is_integer ?
::Kokkos::ArithTraits<KeyType>::min() :
-::Kokkos::ArithTraits<KeyType>::max();
KeyType maxKey_ = ::Kokkos::ArithTraits<KeyType>::max();

/// \brief Minimum value.
///
Expand Down Expand Up @@ -461,9 +459,7 @@ class FixedHashTable {
/// In that case, the initial contiguous sequence of keys may have
/// length 1 or more. Length 1 means that the sequence is trivial
/// (there are no initial contiguous keys).
KeyType lastContigKey_ = ::Kokkos::ArithTraits<KeyType>::is_integer ?
::Kokkos::ArithTraits<KeyType>::min() :
-::Kokkos::ArithTraits<KeyType>::max();
KeyType lastContigKey_ = ::Kokkos::ArithTraits<KeyType>::max();

/// \brief Whether the table was created using one of the
/// constructors that assume contiguous values.
Expand Down
13 changes: 12 additions & 1 deletion packages/tpetra/core/test/HashTable/FixedHashTableTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,16 @@ namespace { // (anonymous)
out << "Got to the end!" << endl;
}

//! @test Check that a default-initialized @ref FixedHashTable claims 0 pairs. This test was proposed in issue #13034.
TEUCHOS_UNIT_TEST_TEMPLATE_3_DECL(FixedHashTable_T, ZeroPairsOnDefaultInit, ValueType, KeyType, DeviceType)
{
using fixed_hash_table_t = Tpetra::Details::FixedHashTable<KeyType,ValueType,DeviceType>;

fixed_hash_table_t table {};

TEST_EQUALITY_CONST(table.numPairs(), 0);
}

//
// Instantiations of the templated unit test(s) above.
//
Expand All @@ -1116,7 +1126,8 @@ namespace { // (anonymous)
TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( FixedHashTable_T, NoncontigKeysAndVals, LO, GO, DEVICE ) \
TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( FixedHashTable_T, DuplicateKeys, LO, GO, DEVICE ) \
TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( FixedHashTable_T, CopyCtorNoDupKeys, LO, GO, DEVICE ) \
TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( FixedHashTable_T, CopyCtorDupKeys, LO, GO, DEVICE )
TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( FixedHashTable_T, CopyCtorDupKeys, LO, GO, DEVICE ) \
TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT( FixedHashTable_T, ZeroPairsOnDefaultInit, LO, GO, DEVICE )

// The typedefs below are there because macros don't like arguments
// with commas in them.
Expand Down

0 comments on commit 0d278ca

Please sign in to comment.