Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
amrex::DenseBins< T > Class Template Reference

A container for storing items in a set of bins. More...

#include <AMReX_DenseBins.H>

Public Types

using BinIteratorFactory = DenseBinIteratorFactory< T >
 
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 &&f)
 Populate the bins with a set of items.
 
template<typename N , typename F >
void build (N nitems, const_pointer_input_type v, int nbins, F &&f)
 Populate the bins with a set of items.
 
template<typename N , typename F >
void build (BinPolicy::GPUBinPolicy, N nitems, const_pointer_input_type v, const Box &bx, F const &f)
 Populate the bins with a set of items.
 
template<typename N , typename F >
void build (BinPolicy::GPUBinPolicy, N nitems, const_pointer_input_type v, int nbins, F const &f)
 Populate the bins with a set of items.
 
template<typename N , typename F >
void build (BinPolicy::OpenMPBinPolicy, N nitems, const_pointer_input_type v, const Box &bx, F const &f)
 Populate the bins with a set of items.
 
template<typename N , typename F >
void build (BinPolicy::OpenMPBinPolicy, N nitems, const_pointer_input_type v, int nbins, F const &f)
 Populate the bins with a set of items.
 
template<typename N , typename F >
void build (BinPolicy::SerialBinPolicy, N nitems, const_pointer_input_type v, const Box &bx, F const &f)
 Populate the bins with a set of items.
 
template<typename N , typename F >
void build (BinPolicy::SerialBinPolicy, N nitems, const_pointer_input_type v, int nbins, F const &f)
 Populate the bins with a set of items.
 
Long numItems () const noexcept
 the number of items in the container
 
Long numBins () const noexcept
 the number of bins in the container
 
index_typepermutationPtr () noexcept
 returns the pointer to the permutation array
 
index_typeoffsetsPtr () noexcept
 returns the pointer to the offsets array
 
index_typebinsPtr () noexcept
 returns the pointer to the bins array
 
const index_typepermutationPtr () const noexcept
 returns const pointer to the permutation array
 
const index_typeoffsetsPtr () const noexcept
 returns const pointer to the offsets array
 
const index_typebinsPtr () const noexcept
 returns the const pointer to the bins array
 
DenseBinIteratorFactory< T > getBinIteratorFactory () const noexcept
 returns a GPU-capable object that can create iterators over the items in a bin.
 

Detailed Description

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

A container for storing items in a set of bins.

The underlying data structure is an array of size nitems defining a permutation of the items in the container that puts them in bin-sorted order, plus an array of size nbins+1 that stores the offsets into the permutation array where each bin starts.

The storage for the bins is "dense" in the sense that users pass in either a Box or an integer 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

◆ BinIteratorFactory

template<typename T >
using amrex::DenseBins< T >::BinIteratorFactory = DenseBinIteratorFactory<T>

◆ const_pointer_input_type

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

◆ const_pointer_type

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

◆ index_type

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

Member Function Documentation

◆ binsPtr() [1/2]

template<typename T >
const index_type * amrex::DenseBins< T >::binsPtr ( ) const
inlinenoexcept

returns the const pointer to the bins array

◆ binsPtr() [2/2]

template<typename T >
index_type * amrex::DenseBins< T >::binsPtr ( )
inlinenoexcept

returns the pointer to the bins array

◆ build() [1/8]

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

Populate the bins with a set of items.

The algorithm is similar to a counting sort. First, we count the number of items in each bin. Then, we perform a prefix sum on the resulting counts. Finally, the set of partial sums is incremented in parallel using atomicInc, which results in a permutation array that places the items in bin-sorted order.

This version uses a 3D box to specify the index space over which the bins are defined.

This overload uses the "GPU" parallelization strategy. If AMReX has been compiled for GPU, it runs on the GPU. Otherwise, it executes in serial.

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
vParticleTileData or pointer 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

◆ build() [2/8]

template<typename T >
template<typename N , typename F >
void amrex::DenseBins< T >::build ( BinPolicy::GPUBinPolicy  ,
nitems,
const_pointer_input_type  v,
int  nbins,
F const &  f 
)
inline

Populate the bins with a set of items.

The algorithm is similar to a counting sort. First, we count the number of items in each bin. Then, we perform a prefix sum on the resulting counts. Finally, the set of partial sums is incremented in parallel using atomicInc, which results in a permutation array that places the items in bin-sorted order.

This version uses a 1D index space for the set of bins.

This overload uses the "GPU" parallelization strategy. If AMReX has been compiled for GPU, it runs on the GPU. Otherwise, it executes in serial.

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
vParticleTileData or pointer to the start of the items
nbinsthe number of bins to use
fa function object that maps items to bins

◆ build() [3/8]

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

Populate the bins with a set of items.

The algorithm is similar to a counting sort. First, we count the number of items in each bin. Then, we perform a prefix sum on the resulting counts. Finally, the set of partial sums is incremented in parallel using atomicInc, which results in a permutation array that places the items in bin-sorted order.

This version uses a 3D box to specify the index space over which the bins are defined.

This overload uses the "OpenMP" parallelization strategy and always runs on the host. If AMReX has been compiled with OpenMP support, the execution will be parallelized, otherwise it will be serial.

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
vParticleTileData or pointer 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

◆ build() [4/8]

template<typename T >
template<typename N , typename F >
void amrex::DenseBins< T >::build ( BinPolicy::OpenMPBinPolicy  ,
nitems,
const_pointer_input_type  v,
int  nbins,
F const &  f 
)
inline

Populate the bins with a set of items.

The algorithm is similar to a counting sort. First, we count the number of items in each bin. Then, we perform a prefix sum on the resulting counts. Finally, the set of partial sums is incremented in parallel using atomicInc, which results in a permutation array that places the items in bin-sorted order.

This version uses a 1D index space for the set of bins.

This overload uses the "OpenMP" parallelization strategy and always runs on the host. If AMReX has been compiled with OpenMP support, the execution will be parallelized, otherwise it will be serial.

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
vParticleTileData or pointer to the start of the items
nbinsthe number of bins to use
fa function object that maps items to bins

◆ build() [5/8]

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

Populate the bins with a set of items.

The algorithm is similar to a counting sort. First, we count the number of items in each bin. Then, we perform a prefix sum on the resulting counts. Finally, the set of partial sums is incremented in parallel using atomicInc, which results in a permutation array that places the items in bin-sorted order.

This version uses a 3D box to specify the index space over which the bins are defined.

This overload uses the "Serial" parallelization strategy. It always runs in serial on the host, regardless of whether AMREX_USE_GPU or AMREX_USE_OMP has been defined.

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
vParticleTileData or pointer 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

◆ build() [6/8]

template<typename T >
template<typename N , typename F >
void amrex::DenseBins< T >::build ( BinPolicy::SerialBinPolicy  ,
nitems,
const_pointer_input_type  v,
int  nbins,
F const &  f 
)
inline

Populate the bins with a set of items.

The algorithm is similar to a counting sort. First, we count the number of items in each bin. Then, we perform a prefix sum on the resulting counts. Finally, the set of partial sums is incremented in parallel using atomicInc, which results in a permutation array that places the items in bin-sorted order.

This version uses a 1D index space for the set of bins.

This overload uses the "Serial" parallelization strategy. It always runs in serial on the host, regardless of whether AMREX_USE_GPU or AMREX_USE_OMP has been defined.

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
vParticleTileData or pointer to the start of the items
nbinsthe number of bins to use
fa function object that maps items to bins

◆ build() [7/8]

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

Populate the bins with a set of items.

The algorithm is similar to a counting sort. First, we count the number of items in each bin. Then, we perform a prefix sum on the resulting counts. Finally, the set of partial sums is incremented in parallel using atomicInc, which results in a permutation array that places the items in bin-sorted order.

This version uses a 3D box to specify the index space over which the bins are defined.

This overload uses the "default" parallelization strategy. If AMReX has been compiled for GPU, it runs on the GPU. Otherwise, it executes in serial.

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
vParticleTileData or pointer 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

◆ build() [8/8]

template<typename T >
template<typename N , typename F >
void amrex::DenseBins< T >::build ( nitems,
const_pointer_input_type  v,
int  nbins,
F &&  f 
)
inline

Populate the bins with a set of items.

The algorithm is similar to a counting sort. First, we count the number of items in each bin. Then, we perform a prefix sum on the resulting counts. Finally, the set of partial sums is incremented in parallel using atomicInc, which results in a permutation array that places the items in bin-sorted order.

This version uses a 1D index space for the set of bins.

This overload uses the "default" parallelization strategy. If AMReX has been compiled for GPU, it runs on the GPU. Otherwise, it executes in serial.

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
vParticleTileData or pointer to the start of the items
nbinsthe number of bins to use
fa function object that maps items to bins

◆ getBinIteratorFactory()

template<typename T >
DenseBinIteratorFactory< T > amrex::DenseBins< T >::getBinIteratorFactory ( ) const
inlinenoexcept

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

◆ numBins()

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

the number of bins in the container

◆ numItems()

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

the number of items in the container

◆ offsetsPtr() [1/2]

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

returns const pointer to the offsets array

◆ offsetsPtr() [2/2]

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

returns the pointer to the offsets array

◆ permutationPtr() [1/2]

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

returns const pointer to the permutation array

◆ permutationPtr() [2/2]

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

returns the pointer to the permutation array


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