IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
ippl::FieldLayout< Dim > Class Template Reference

#include <FieldLayout.h>

Inheritance diagram for ippl::FieldLayout< Dim >:
Collaboration diagram for ippl::FieldLayout< Dim >:

Classes

struct  bound_type

Public Types

using NDIndex_t = NDIndex<Dim>
using view_type = typename detail::ViewType<NDIndex_t, 1>::view_type
using host_mirror_type = typename view_type::host_mirror_type
using rank_list = std::vector<int>
using bounds_list = std::vector<bound_type>
using neighbor_list = std::array<rank_list, detail::countHypercubes(Dim) - 1>
using neighbor_range_list = std::array<bounds_list, detail::countHypercubes(Dim) - 1>

Public Member Functions

 FieldLayout (const mpi::Communicator &=MPI_COMM_WORLD)
 FieldLayout (mpi::Communicator, const NDIndex< Dim > &domain, std::array< bool, Dim > decomp, bool isAllPeriodic=false)
virtual ~FieldLayout ()=default
void initialize (const NDIndex< Dim > &domain, std::array< bool, Dim > decomp, bool isAllPeriodic=false)
const NDIndex< Dim > & getDomain () const
template<unsigned Dim2>
bool operator== (const FieldLayout< Dim2 > &x) const
bool operator== (const FieldLayout< Dim > &x) const
bool getDistribution (unsigned int d) const
std::array< bool, DimisParallel () const
const NDIndex_tgetLocalNDIndex () const
const NDIndex_tgetLocalNDIndex (int rank) const
const host_mirror_type getHostLocalDomains () const
const view_type getDeviceLocalDomains () const
const neighbor_listgetNeighbors () const
const neighbor_range_listgetNeighborsSendRange () const
const neighbor_range_listgetNeighborsRecvRange () const
void findPeriodicNeighbors (const int nghost, const NDIndex< Dim > &localDomain, NDIndex< Dim > &grown, NDIndex< Dim > &neighborDomain, const int rank, std::map< unsigned int, int > &offsets, unsigned d0=0, unsigned codim=0)
void findNeighbors (int nghost=1)
void addNeighbors (const NDIndex_t &gnd, const NDIndex_t &nd, const NDIndex_t &ndNeighbor, const NDIndex_t &intersect, int nghost, int rank)
void write (std::ostream &=std::cout) const
void updateLayout (const std::vector< NDIndex_t > &domains)

Static Public Member Functions

static int getMatchingIndex (int index)

Public Attributes

bool isAllPeriodic_m
mpi::Communicator comm

Protected Member Functions

void calcWidths ()

Protected Attributes

NDIndex_t gDomain_m
 Global domain.
view_type dLocalDomains_m
 Local domains (device view).
host_mirror_type hLocalDomains_m
 Local domains (host mirror view).
std::array< bool, DimisParallelDim_m
unsigned int minWidth_m [Dim]

Private Member Functions

bound_type getBounds (const NDIndex_t &nd1, const NDIndex_t &nd2, const NDIndex_t &offset, int nghost)
int getPeriodicOffset (const NDIndex_t &nd, const unsigned int d, const int k)

Private Attributes

neighbor_list neighbors_m
neighbor_range_list neighborsSendRange_m
neighbor_range_list neighborsRecvRange_m

Detailed Description

template<unsigned Dim>
class ippl::FieldLayout< Dim >

Definition at line 166 of file FieldLayout.h.

Member Typedef Documentation

◆ bounds_list

template<unsigned Dim>
using ippl::FieldLayout< Dim >::bounds_list = std::vector<bound_type>

Definition at line 192 of file FieldLayout.h.

◆ host_mirror_type

template<unsigned Dim>
using ippl::FieldLayout< Dim >::host_mirror_type = typename view_type::host_mirror_type

Definition at line 170 of file FieldLayout.h.

◆ NDIndex_t

template<unsigned Dim>
using ippl::FieldLayout< Dim >::NDIndex_t = NDIndex<Dim>

Definition at line 168 of file FieldLayout.h.

◆ neighbor_list

template<unsigned Dim>
using ippl::FieldLayout< Dim >::neighbor_list = std::array<rank_list, detail::countHypercubes(Dim) - 1>

Definition at line 194 of file FieldLayout.h.

◆ neighbor_range_list

template<unsigned Dim>
using ippl::FieldLayout< Dim >::neighbor_range_list = std::array<bounds_list, detail::countHypercubes(Dim) - 1>

Definition at line 195 of file FieldLayout.h.

◆ rank_list

template<unsigned Dim>
using ippl::FieldLayout< Dim >::rank_list = std::vector<int>

Definition at line 191 of file FieldLayout.h.

◆ view_type

template<unsigned Dim>
using ippl::FieldLayout< Dim >::view_type = typename detail::ViewType<NDIndex_t, 1>::view_type

Definition at line 169 of file FieldLayout.h.

Constructor & Destructor Documentation

◆ FieldLayout() [1/2]

template<unsigned Dim>
ippl::FieldLayout< Dim >::FieldLayout ( const mpi::Communicator & communicator = MPI_COMM_WORLD)

Default constructor, which should only be used if you are going to call 'initialize' soon after (before using in any context)

Definition at line 37 of file FieldLayout.hpp.

References comm, Dim, dLocalDomains_m, hLocalDomains_m, and minWidth_m.

Referenced by FieldLayout(), operator==(), operator==(), ippl::SubFieldLayout< Dim >::operator==(), ippl::SubFieldLayout< Dim >::SubFieldLayout(), ippl::SubFieldLayout< Dim >::SubFieldLayout(), and ippl::SubFieldLayout< Dim >::SubFieldLayout().

Here is the caller graph for this function:

◆ FieldLayout() [2/2]

template<unsigned Dim>
ippl::FieldLayout< Dim >::FieldLayout ( mpi::Communicator communicator,
const NDIndex< Dim > & domain,
std::array< bool, Dim > decomp,
bool isAllPeriodic = false )

Definition at line 47 of file FieldLayout.hpp.

References FieldLayout(), initialize(), and isParallel().

Here is the call graph for this function:

◆ ~FieldLayout()

template<unsigned Dim>
virtual ippl::FieldLayout< Dim >::~FieldLayout ( )
virtualdefault

Member Function Documentation

◆ addNeighbors()

template<unsigned Dim>
void ippl::FieldLayout< Dim >::addNeighbors ( const NDIndex_t & gnd,
const NDIndex_t & nd,
const NDIndex_t & ndNeighbor,
const NDIndex_t & intersect,
int nghost,
int rank )

Adds a neighbor to the neighbor list

Parameters
gndthe local domain, including ghost cells
ndthe local domain
ndNeighborthe neighbor rank's domain
intersectthe intersection of the domains
nghostnumber of ghost cells
rankthe neighbor's rank

Definition at line 275 of file FieldLayout.hpp.

References getBounds().

Here is the call graph for this function:

◆ calcWidths()

template<unsigned Dim>
void ippl::FieldLayout< Dim >::calcWidths ( )
protected

Definition at line 172 of file FieldLayout.hpp.

References Dim, gDomain_m, hLocalDomains_m, ippl::NDIndex< Dim >::length(), and minWidth_m.

Referenced by initialize(), ippl::SubFieldLayout< Dim >::initialize(), and updateLayout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findNeighbors()

template<unsigned Dim>
void ippl::FieldLayout< Dim >::findNeighbors ( int nghost = 1)

Finds all neighboring ranks based on the field layout

Parameters
nghostnumber of ghost cells (default 1)

Definition at line 228 of file FieldLayout.hpp.

References comm, ippl::detail::countHypercubes(), Dim, IpplTimings::getTimer(), hLocalDomains_m, neighbors_m, neighborsRecvRange_m, neighborsSendRange_m, and IpplTimings::startTimer().

Referenced by initialize(), ippl::SubFieldLayout< Dim >::initialize(), and updateLayout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findPeriodicNeighbors()

template<unsigned Dim>
void ippl::FieldLayout< Dim >::findPeriodicNeighbors ( const int nghost,
const NDIndex< Dim > & localDomain,
NDIndex< Dim > & grown,
NDIndex< Dim > & neighborDomain,
const int rank,
std::map< unsigned int, int > & offsets,
unsigned d0 = 0,
unsigned codim = 0 )

Recursively finds neighbor ranks for layouts with all periodic boundary conditions

Parameters
nghostnumber of ghost cells
localDomainthe rank's local domain
grownthe local domain, grown by the number of ghost cells
neighborDomaina candidate neighbor rank's domain
rankthe candidate neighbor's rank
offsetsa dictionary containing offsets along different dimensions
d0the dimension from which to start checking (default 0)
codimthe codimension of overlapping regions to check (default 0)

Definition at line 190 of file FieldLayout.hpp.

References Dim, and getPeriodicOffset().

Here is the call graph for this function:

◆ getBounds()

template<unsigned Dim>
FieldLayout< Dim >::bound_type ippl::FieldLayout< Dim >::getBounds ( const NDIndex_t & nd1,
const NDIndex_t & nd2,
const NDIndex_t & offset,
int nghost )
private

Obtain the bounds to send / receive. The second domain, i.e., nd2, is grown by nghost cells in each dimension in order to figure out the intersecting cells.

Parameters
nd1either remote or owned domain
nd2either remote or owned domain
offsetto map global to local grid point
nghostnumber of ghost cells per dimension

Definition at line 305 of file FieldLayout.hpp.

References ippl::NDIndex< Dim >::grow().

Referenced by addNeighbors().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDeviceLocalDomains()

template<unsigned Dim>
const FieldLayout< Dim >::view_type ippl::FieldLayout< Dim >::getDeviceLocalDomains ( ) const

Definition at line 135 of file FieldLayout.hpp.

References dLocalDomains_m.

◆ getDistribution()

template<unsigned Dim>
bool ippl::FieldLayout< Dim >::getDistribution ( unsigned int d) const
inline

Definition at line 252 of file FieldLayout.h.

References gDomain_m, and minWidth_m.

◆ getDomain()

◆ getHostLocalDomains()

template<unsigned Dim>
const FieldLayout< Dim >::host_mirror_type ippl::FieldLayout< Dim >::getHostLocalDomains ( ) const

◆ getLocalNDIndex() [1/2]

◆ getLocalNDIndex() [2/2]

template<unsigned Dim>
const FieldLayout< Dim >::NDIndex_t & ippl::FieldLayout< Dim >::getLocalNDIndex ( int rank) const

Definition at line 121 of file FieldLayout.hpp.

References comm, hLocalDomains_m, and PAssert.

◆ getMatchingIndex()

template<unsigned Dim>
int ippl::FieldLayout< Dim >::getMatchingIndex ( int index)
static

Given the index of a hypercube, find the index of the opposite hypercube, i.e. the component with the same codimension belonging to a neighboring domain that touches the hypercube with the given index, as determined by the ternary encoding for hypercubes.

For neighbor communication, the opposite component is the one that receives sent data or sends us data to receive for a given component.

The matching index is given by swapping alls 1s for 0s and vice versa in the ternary encoding, while keeping the 2s unchanged. This can be understood from the fact that if the local component is on the upper boundary of the local domain, the neighbor component must be on the lower boundary of its local domain, and vice versa. The 2s are unchanged because both the local component and the neighbor component must be parallel to the same axes, otherwise their intersection would have lower or higher dimension than the components themselves.

Parameters
indexindex of the known component
Returns
Index of the matching component

Definition at line 22 of file FieldLayout.hpp.

References ippl::detail::countHypercubes(), and Dim.

Referenced by ippl::detail::HaloCells< T, Dim, ViewArgs >::exchangeBoundaries().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNeighbors()

template<unsigned Dim>
const FieldLayout< Dim >::neighbor_list & ippl::FieldLayout< Dim >::getNeighbors ( ) const

Get a list of all the neighbors, arranged by ternary encoding of the hypercubes

Returns
List of list of neighbor ranks touching each boundary component

Definition at line 140 of file FieldLayout.hpp.

References neighbors_m.

Referenced by ippl::detail::HaloCells< T, Dim, ViewArgs >::exchangeBoundaries().

Here is the caller graph for this function:

◆ getNeighborsRecvRange()

template<unsigned Dim>
const FieldLayout< Dim >::neighbor_range_list & ippl::FieldLayout< Dim >::getNeighborsRecvRange ( ) const

Get the domain ranges corresponding to regions that should be received from neighbor ranks

Returns
Ranges to receive

Definition at line 151 of file FieldLayout.hpp.

References neighborsRecvRange_m.

Referenced by ippl::detail::HaloCells< T, Dim, ViewArgs >::exchangeBoundaries().

Here is the caller graph for this function:

◆ getNeighborsSendRange()

template<unsigned Dim>
const FieldLayout< Dim >::neighbor_range_list & ippl::FieldLayout< Dim >::getNeighborsSendRange ( ) const

Get the domain ranges corresponding to regions that should be sent to neighbor ranks

Returns
Ranges to send

Definition at line 145 of file FieldLayout.hpp.

References neighborsSendRange_m.

Referenced by ippl::detail::HaloCells< T, Dim, ViewArgs >::exchangeBoundaries().

Here is the caller graph for this function:

◆ getPeriodicOffset()

template<unsigned Dim>
int ippl::FieldLayout< Dim >::getPeriodicOffset ( const NDIndex_t & nd,
const unsigned int d,
const int k )
private

Definition at line 327 of file FieldLayout.hpp.

References gDomain_m, and ippl::max.

Referenced by findPeriodicNeighbors().

Here is the caller graph for this function:

◆ initialize()

template<unsigned Dim>
void ippl::FieldLayout< Dim >::initialize ( const NDIndex< Dim > & domain,
std::array< bool, Dim > decomp,
bool isAllPeriodic = false )

Definition at line 71 of file FieldLayout.hpp.

References calcWidths(), comm, Dim, dLocalDomains_m, findNeighbors(), gDomain_m, hLocalDomains_m, isAllPeriodic_m, isParallel(), isParallelDim_m, ippl::NDIndex< Dim >::length(), and ippl::detail::Partitioner< Dim >::split().

Referenced by FieldLayout(), ippl::SubFieldLayout< Dim >::initialize(), and ippl::SubFieldLayout< Dim >::initialize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isParallel()

template<unsigned Dim>
std::array< bool, Dim > ippl::FieldLayout< Dim >::isParallel ( ) const
inline

Definition at line 258 of file FieldLayout.h.

References isParallelDim_m.

Referenced by FieldLayout(), ippl::FFTPeriodicPoissonSolver< FieldLHS, FieldRHS >::initialize(), initialize(), ippl::SubFieldLayout< Dim >::initialize(), ippl::SubFieldLayout< Dim >::initialize(), ippl::SubFieldLayout< Dim >::SubFieldLayout(), and ippl::SubFieldLayout< Dim >::SubFieldLayout().

Here is the caller graph for this function:

◆ operator==() [1/2]

template<unsigned Dim>
bool ippl::FieldLayout< Dim >::operator== ( const FieldLayout< Dim > & x) const
inline

Definition at line 235 of file FieldLayout.h.

References comm, Dim, FieldLayout(), gDomain_m, getDomain(), getLocalNDIndex(), and hLocalDomains_m.

Here is the call graph for this function:

◆ operator==() [2/2]

template<unsigned Dim>
template<unsigned Dim2>
bool ippl::FieldLayout< Dim >::operator== ( const FieldLayout< Dim2 > & x) const
inline

Definition at line 225 of file FieldLayout.h.

References FieldLayout(), gDomain_m, and getDomain().

Here is the call graph for this function:

◆ updateLayout()

template<unsigned Dim>
void ippl::FieldLayout< Dim >::updateLayout ( const std::vector< NDIndex_t > & domains)

Definition at line 54 of file FieldLayout.hpp.

References calcWidths(), dLocalDomains_m, findNeighbors(), and hLocalDomains_m.

Referenced by ippl::OrthogonalRecursiveBisection< Field, Tp >::binaryRepartition().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write()

template<unsigned Dim>
void ippl::FieldLayout< Dim >::write ( std::ostream & out = std::cout) const

Definition at line 157 of file FieldLayout.hpp.

References comm, gDomain_m, and hLocalDomains_m.

Referenced by ippl::operator<<().

Here is the caller graph for this function:

Member Data Documentation

◆ comm

◆ dLocalDomains_m

template<unsigned Dim>
view_type ippl::FieldLayout< Dim >::dLocalDomains_m
protected

Local domains (device view).

Definition at line 382 of file FieldLayout.h.

Referenced by FieldLayout(), getDeviceLocalDomains(), initialize(), ippl::SubFieldLayout< Dim >::initialize(), and updateLayout().

◆ gDomain_m

◆ hLocalDomains_m

◆ isAllPeriodic_m

template<unsigned Dim>
bool ippl::FieldLayout< Dim >::isAllPeriodic_m

Definition at line 351 of file FieldLayout.h.

Referenced by initialize().

◆ isParallelDim_m

template<unsigned Dim>
std::array<bool, Dim> ippl::FieldLayout< Dim >::isParallelDim_m
protected

Definition at line 387 of file FieldLayout.h.

Referenced by initialize(), and isParallel().

◆ minWidth_m

template<unsigned Dim>
unsigned int ippl::FieldLayout< Dim >::minWidth_m[Dim]
protected

Definition at line 390 of file FieldLayout.h.

Referenced by calcWidths(), FieldLayout(), and getDistribution().

◆ neighbors_m

template<unsigned Dim>
neighbor_list ippl::FieldLayout< Dim >::neighbors_m
private

Definition at line 371 of file FieldLayout.h.

Referenced by findNeighbors(), and getNeighbors().

◆ neighborsRecvRange_m

template<unsigned Dim>
neighbor_range_list ippl::FieldLayout< Dim >::neighborsRecvRange_m
private

Definition at line 375 of file FieldLayout.h.

Referenced by findNeighbors(), and getNeighborsRecvRange().

◆ neighborsSendRange_m

template<unsigned Dim>
neighbor_range_list ippl::FieldLayout< Dim >::neighborsSendRange_m
private

Definition at line 375 of file FieldLayout.h.

Referenced by findNeighbors(), and getNeighborsSendRange().


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