Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
Tpetra::Details::FHT::FillPairs< PairsViewType, KeysViewType, CountsViewType, SizeType > Class Template Reference

Parallel reduce functor for filling the FixedHashTable, and computing the min and max keys. More...

#include <Tpetra_Details_FixedHashTable_def.hpp>

Public Member Functions

 FillPairs (const pairs_view_type &pairs, const counts_view_type &counts, const offsets_view_type &ptr, const keys_view_type &keys, const typename pair_type::second_type startingValue)
 Constructor. More...
 
 FillPairs (const pairs_view_type &pairs, const counts_view_type &counts, const offsets_view_type &ptr, const keys_view_type &keys, const typename pair_type::second_type startingValue, const key_type initMinKey, const key_type initMaxKey)
 Constructor that takes initial min and max key values. More...
 
KOKKOS_INLINE_FUNCTION void init (value_type &dst) const
 Set the initial value of the reduction result. More...
 
KOKKOS_INLINE_FUNCTION void operator() (const size_type &i, value_type &dst) const
 Parallel loop body; do this for every entry of keys_. More...
 

Detailed Description

template<class PairsViewType, class KeysViewType, class CountsViewType, class SizeType = typename KeysViewType::size_type>
class Tpetra::Details::FHT::FillPairs< PairsViewType, KeysViewType, CountsViewType, SizeType >

Parallel reduce functor for filling the FixedHashTable, and computing the min and max keys.

This is also a parallel reduce functor in order to check for failure. Failure should only happen on a bug (in CountBuckets or computeOffsetsFromCounts), but checking for it is cheap and easy.

Template Parameters
PairsViewTypeType of the Kokkos::View specialization used to store the (key,value) pairs in the FixedHashTable; output of this functor.
KeysViewTypeType of the Kokkos::View specialization used to store the keys; input of this functor.
CountsViewTypeType of the Kokkos::View specialization used to store the bucket counts; input of this functor, used as scratch space (so it must be nonconst; offsets_view_type is the const version of this).
SizeTypeThe parallel loop index type; a built-in integer type. Defaults to the type of the input View's dimension. You may use a shorter type to improve performance.
Note
This functor CANNOT also find duplicate keys. This is because different threads might have different keys that hash to the same bucket, concurrently. Threads resolve this by using atomic updates to "reserve" a position in the 'vals' output array. Thus, two threads might concurrently check for existing duplicates and find none, but then concurrently insert (key,value) pairs with duplicate keys. The only thread-scalable way to check for duplicate keys is to wait until after the table has been filled.

Definition at line 279 of file Tpetra_Details_FixedHashTable_def.hpp.

Constructor & Destructor Documentation

template<class PairsViewType , class KeysViewType , class CountsViewType , class SizeType = typename KeysViewType::size_type>
Tpetra::Details::FHT::FillPairs< PairsViewType, KeysViewType, CountsViewType, SizeType >::FillPairs ( const pairs_view_type &  pairs,
const counts_view_type &  counts,
const offsets_view_type &  ptr,
const keys_view_type &  keys,
const typename pair_type::second_type  startingValue 
)
inline

Constructor.

Parameters
pairs[out] (Preallocated) View of (key,value) pairs
counts[in/out] View of bucket counts; overwritten as scratch space
ptr[in] View of offsets
keys[in] View of the keys
startingValue[in] Starting value. For each key keys[i], the corresponding value (in the (key,value) pair) is startingValue + i.

Definition at line 314 of file Tpetra_Details_FixedHashTable_def.hpp.

template<class PairsViewType , class KeysViewType , class CountsViewType , class SizeType = typename KeysViewType::size_type>
Tpetra::Details::FHT::FillPairs< PairsViewType, KeysViewType, CountsViewType, SizeType >::FillPairs ( const pairs_view_type &  pairs,
const counts_view_type &  counts,
const offsets_view_type &  ptr,
const keys_view_type &  keys,
const typename pair_type::second_type  startingValue,
const key_type  initMinKey,
const key_type  initMaxKey 
)
inline

Constructor that takes initial min and max key values.

This constructor is useful for Tpetra::Map's noncontiguous constructor. That constructor first harvests an initial sequence of contiguous global indices, then puts any remaining global indices that follow into the hash table. That initial sequence defines initial min and max keys.

Parameters
pairs[out] (Preallocated) View of (key,value) pairs
counts[in/out] View of bucket counts; overwritten as scratch space
ptr[in] View of offsets
keys[in] View of the keys
startingValue[in] Starting value. For each key keys[i], the corresponding value (in the (key,value) pair) is startingValue + i.
initMinKey[in] Initial min key value
initMaxKey[in] Initial max key value

Definition at line 349 of file Tpetra_Details_FixedHashTable_def.hpp.

Member Function Documentation

template<class PairsViewType , class KeysViewType , class CountsViewType , class SizeType = typename KeysViewType::size_type>
KOKKOS_INLINE_FUNCTION void Tpetra::Details::FHT::FillPairs< PairsViewType, KeysViewType, CountsViewType, SizeType >::init ( value_type dst) const
inline

Set the initial value of the reduction result.

Definition at line 367 of file Tpetra_Details_FixedHashTable_def.hpp.

template<class PairsViewType , class KeysViewType , class CountsViewType , class SizeType = typename KeysViewType::size_type>
KOKKOS_INLINE_FUNCTION void Tpetra::Details::FHT::FillPairs< PairsViewType, KeysViewType, CountsViewType, SizeType >::operator() ( const size_type &  i,
value_type dst 
) const
inline

Parallel loop body; do this for every entry of keys_.

Add (key = keys_[i], value = startingValue_ + i) pair to the hash table. Compute min and max key value.

Definition at line 392 of file Tpetra_Details_FixedHashTable_def.hpp.


The documentation for this class was generated from the following file: