SMG2S
Sparse Matrix Generator with Given Spectrum
parVectorMap< S > Class Template Reference

A class which determines the way to distribute a vector across MPI procs. More...

#include <parVectorMap.hpp>

Public Member Functions

 parVectorMap ()
 A constructor of `parVectorMap`.
 
 parVectorMap (MPI_Comm ncomm, S lbound, S ubound)
 A constructor of `parVectorMap`. More...
 
 ~parVectorMap ()
 A destructor of `parVectorMap`.
 
bool operator== (const parVectorMap &map1)
 Compare if this map is identical to another one `map1`.
 
bool operator!= (const parVectorMap &map1)
 Compare if this map is different with another one `map1`.
 
Loc2Glob (S local_index)
 Convert a index of local vector on each MPI proc into its index in the global distributed vector. More...
 
Glob2Loc (S global_index)
 Convert a index of global vector into its index in the local vector on each MPI proc. More...
 
MPI_Comm GetCurrentComm ()
 Return parVectorMap<S>::comm.
 
int GetRank ()
 Return parVectorMap<S>::rank.
 
GetLowerBound ()
 Return parVectorMap<S>::lower_bound.
 
GetUpperBound ()
 Return parVectorMap<S>::upper_bound.
 
GetLocalSize ()
 Return parVectorMap<S>::local_size.
 
GetGlobalSize ()
 Return parVectorMap<S>::global_size.
 
std::vector< S > GetLBoundMap ()
 Return parVectorMap<S>::lprocbound_map.
 
std::vector< S > GetUBoundMap ()
 Return parVectorMap<S>::uprocbound_map.
 

Private Attributes

MPI_Comm comm
 The working MPI Communicator.
 
int nproc
 number of MPI procs within the working MPI communicator parVectorMap::comm
 
int rank
 rank of each MPI procs within the working MPI communicator parVectorMap::comm
 
lower_bound
 the smallest index of a distributed vector on each MPI proc
 
upper_bound
 `upper_bound-1 = ` the largest index of a distributed vector on each MPI proc
 
local_size
 The number of elements of vector stored on each MPI proc.
 
global_size
 Global size of this distributed vector.
 
std::vector< S > lprocbound_map
 A `std::vector` which stores the parVectorMap::lower_bound of all MPI procs together.
 
std::vector< S > uprocbound_map
 A `std::vector` which stores the parVectorMap::upper_bound of all MPI procs together.
 

Detailed Description

template<typename S>
class parVectorMap< S >

A class which determines the way to distribute a vector across MPI procs.

  • This class is to create a mapping from a fixed-size vector to multiple MPI procs in 1D grid.
  • This class can also be used to create more distributed vectors and sparse matrices following the same way.
  • For each MPI proc, a piece of vector with indexing `[lower_bound, upper_bound)` is allocated.
Template Parameters
Stype of integer to describes the dimension of vector to be generated.

Constructor & Destructor Documentation

◆ parVectorMap()

template<typename S >
parVectorMap< S >::parVectorMap ( MPI_Comm  ncomm,
lbound,
ubound 
)

A constructor of `parVectorMap`.

Parameters
[in]ncommthe working MPI Communicator
[in]lboundthe smallest index of a distributed vector on each MPI proc
[in]ubound`ubound-1 = ` the largest index of a distributed vector on each MPI proc

Member Function Documentation

◆ Glob2Loc()

template<typename S >
S parVectorMap< S >::Glob2Loc ( global_index)

Convert a index of global vector into its index in the local vector on each MPI proc.

Parameters
[in]global_indexthe index global vector to be converted
  • Attention, this function is in distributed manner, each MPI proc can only convert the global index of vector in the range `[lower_bound, upper_bound)`.

◆ Loc2Glob()

template<typename S >
S parVectorMap< S >::Loc2Glob ( local_index)

Convert a index of local vector on each MPI proc into its index in the global distributed vector.

Parameters
[in]local_indexthe index local vector to be converted
  • Attention, this function is in distributed manner, each MPI proc can only convert the local index of vector stored on itself.

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