Block-Structured AMR Software Framework
amrex::SparseBins< T > Class Template Reference

A container for storing items in a set of bins using "sparse" storage. More...

#include <AMReX_SparseBins.H>

Public Types

using BinIteratorFactory = SparseBinIteratorFactory< T >
 
using bin_type = IntVect
 
using index_type = int
 
using const_pointer_type = std::conditional_t< IsParticleTileData< T >(), T, const T * >
 
using const_pointer_input_type = std::conditional_t< IsParticleTileData< T >(), const T &, const T * >
 

Public Member Functions

template<typename N , typename F >
void build (N nitems, const_pointer_input_type v, const Box &bx, F const &f)
 Populate the bins with a set of items. More...
 
Long numItems () const noexcept
 the number of items in the container More...
 
Long numBins () const noexcept
 the number of bins in the container More...
 
index_typepermutationPtr () noexcept
 returns the pointer to the permutation array More...
 
index_typeoffsetsPtr () noexcept
 returns the pointer to the offsets array More...
 
index_typegetNonZeroBinsPtr () noexcept
 returns the pointer to the array of non-zero bins More...
 
const index_typepermutationPtr () const noexcept
 returns const pointer to the permutation array More...
 
const index_typeoffsetsPtr () const noexcept
 returns const pointer to the offsets array More...
 
const index_typegetNonZeroBinsPtr () const noexcept
 returns the pointer to the array of non-zero bins More...
 
SparseBinIteratorFactory< T > getBinIteratorFactory () const noexcept
 returns a GPU-capable object that can create iterators over the items in a bin. More...
 

Private Attributes

const_pointer_type m_items
 
Gpu::DeviceVector< index_typem_bins
 
Gpu::DeviceVector< index_typem_offsets
 
Gpu::DeviceVector< index_typem_perm
 

Detailed Description

template<typename T>
class amrex::SparseBins< T >

A container for storing items in a set of bins using "sparse" storage.

The underlying data structure consists of three arrays. The first is a sorted array of bin numbers with a size equal to the number of non-zero bins. The second is an array of size nitems defining a permutation of the items in the container that puts them in bin-sorted order. Finally, there is an offsets array that stores, for each non-zero bin, the offsets into the permutation array where each bin starts.

The storage for the bins is "sparse" in the sense that users pass in a Box that defines the space over which the bins will be defined, and empty bins will still take up space.

Template Parameters
Thetype of items we hold

Member Typedef Documentation

◆ bin_type

template<typename T >
using amrex::SparseBins< T >::bin_type = IntVect

◆ BinIteratorFactory

template<typename T >
using amrex::SparseBins< T >::BinIteratorFactory = SparseBinIteratorFactory<T>

◆ const_pointer_input_type

template<typename T >
using amrex::SparseBins< T >::const_pointer_input_type = std::conditional_t<IsParticleTileData<T>(), const T&, const T* >

◆ const_pointer_type

template<typename T >
using amrex::SparseBins< T >::const_pointer_type = std::conditional_t<IsParticleTileData<T>(), T, const T* >

◆ index_type

template<typename T >
using amrex::SparseBins< T >::index_type = int

Member Function Documentation

◆ build()

template<typename T >
template<typename N , typename F >
void amrex::SparseBins< T >::build ( nitems,
const_pointer_input_type  v,
const Box bx,
F const &  f 
)
inline

Populate the bins with a set of items.

Template Parameters
Nthe 'size' type that can enumerate all the items
Fa function that maps items to IntVect bins
Parameters
nitemsthe number of items to put in the bins
vpointer to the start of the items
bxthe Box that defines the space over which the bins will be defined
fa function object that maps items to bins

◆ getBinIteratorFactory()

template<typename T >
SparseBinIteratorFactory<T> amrex::SparseBins< T >::getBinIteratorFactory ( ) const
inlinenoexcept

returns a GPU-capable object that can create iterators over the items in a bin.

◆ getNonZeroBinsPtr() [1/2]

template<typename T >
const index_type* amrex::SparseBins< T >::getNonZeroBinsPtr ( ) const
inlinenoexcept

returns the pointer to the array of non-zero bins

◆ getNonZeroBinsPtr() [2/2]

template<typename T >
index_type* amrex::SparseBins< T >::getNonZeroBinsPtr ( )
inlinenoexcept

returns the pointer to the array of non-zero bins

◆ numBins()

template<typename T >
Long amrex::SparseBins< T >::numBins ( ) const
inlinenoexcept

the number of bins in the container

◆ numItems()

template<typename T >
Long amrex::SparseBins< T >::numItems ( ) const
inlinenoexcept

the number of items in the container

◆ offsetsPtr() [1/2]

template<typename T >
const index_type* amrex::SparseBins< T >::offsetsPtr ( ) const
inlinenoexcept

returns const pointer to the offsets array

◆ offsetsPtr() [2/2]

template<typename T >
index_type* amrex::SparseBins< T >::offsetsPtr ( )
inlinenoexcept

returns the pointer to the offsets array

◆ permutationPtr() [1/2]

template<typename T >
const index_type* amrex::SparseBins< T >::permutationPtr ( ) const
inlinenoexcept

returns const pointer to the permutation array

◆ permutationPtr() [2/2]

template<typename T >
index_type* amrex::SparseBins< T >::permutationPtr ( )
inlinenoexcept

returns the pointer to the permutation array

Member Data Documentation

◆ m_bins

template<typename T >
Gpu::DeviceVector<index_type> amrex::SparseBins< T >::m_bins
private

◆ m_items

template<typename T >
const_pointer_type amrex::SparseBins< T >::m_items
private

◆ m_offsets

template<typename T >
Gpu::DeviceVector<index_type> amrex::SparseBins< T >::m_offsets
private

◆ m_perm

template<typename T >
Gpu::DeviceVector<index_type> amrex::SparseBins< T >::m_perm
private

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