SMG2S
Sparse Matrix Generator with Given Spectrum
|
|
24 #ifndef __PARVECTORMAP_H__
25 #define __PARVECTORMAP_H__
27 #include "utils/MPI_DataType.hpp"
81 MPI_Comm_compare(
comm, map1.
comm, &flag);
82 if(flag == MPI_IDENT){
95 MPI_Comm_compare(
comm, map1.
comm, &flag);
96 if(flag == MPI_IDENT){
146 MPI_Comm_dup(ncomm, &comm);
147 MPI_Comm_size(comm, &nproc);
148 MPI_Comm_rank(comm, &rank);
151 lower_bound = lbound;
152 upper_bound = ubound;
154 local_size = upper_bound - lower_bound;
158 MPI_Allreduce(&local_size, &global_size, 1, MPI_INT, MPI_SUM, comm);
160 lprocbound_map.resize(nproc);
161 uprocbound_map.resize(nproc);
163 MPI_Allgather(&lower_bound, 1 , getMPI_Type<S>() , lprocbound_map.data() , 1 , getMPI_Type<S>(), comm ) ;
164 MPI_Allgather(&upper_bound, 1 , getMPI_Type<S>() , uprocbound_map.data(), 1 , getMPI_Type<S>() , comm ) ;
175 S global_index = lower_bound + local_index;
178 if (global_index > global_size){
183 catch(S local_index){
184 std::cout <<
"The given local index <" << local_index <<
"> is out of bound." << std::endl;
193 S local_index = global_index - lower_bound;
196 if (local_index < 0 || local_index >= local_size){
200 }
catch(S global_index){
std::vector< S > GetLBoundMap()
Return parVectorMap<S>::lprocbound_map.
Definition: parVectorMap.hpp:134
A class which determines the way to distribute a vector across MPI procs.
Definition: parVectorMap.hpp:40
int GetRank()
Return parVectorMap<S>::rank.
Definition: parVectorMap.hpp:124
S upper_bound
`upper_bound-1 = ` the largest index of a distributed vector on each MPI proc
Definition: parVectorMap.hpp:53
MPI_Comm GetCurrentComm()
Return parVectorMap<S>::comm.
Definition: parVectorMap.hpp:122
parVectorMap()
A constructor of `parVectorMap`.
Definition: parVectorMap.hpp:141
bool operator!=(const parVectorMap &map1)
Compare if this map is different with another one `map1`.
Definition: parVectorMap.hpp:92
int rank
rank of each MPI procs within the working MPI communicator parVectorMap::comm
Definition: parVectorMap.hpp:49
S GetLowerBound()
Return parVectorMap<S>::lower_bound.
Definition: parVectorMap.hpp:126
S GetUpperBound()
Return parVectorMap<S>::upper_bound.
Definition: parVectorMap.hpp:128
S lower_bound
the smallest index of a distributed vector on each MPI proc
Definition: parVectorMap.hpp:51
std::vector< S > uprocbound_map
A `std::vector` which stores the parVectorMap::upper_bound of all MPI procs together.
Definition: parVectorMap.hpp:61
S Glob2Loc(S global_index)
Convert a index of global vector into its index in the local vector on each MPI proc.
Definition: parVectorMap.hpp:191
S global_size
Global size of this distributed vector.
Definition: parVectorMap.hpp:57
S GetLocalSize()
Return parVectorMap<S>::local_size.
Definition: parVectorMap.hpp:130
S Loc2Glob(S local_index)
Convert a index of local vector on each MPI proc into its index in the global distributed vector.
Definition: parVectorMap.hpp:173
std::vector< S > GetUBoundMap()
Return parVectorMap<S>::uprocbound_map.
Definition: parVectorMap.hpp:136
bool operator==(const parVectorMap &map1)
Compare if this map is identical to another one `map1`.
Definition: parVectorMap.hpp:78
std::vector< S > lprocbound_map
A `std::vector` which stores the parVectorMap::lower_bound of all MPI procs together.
Definition: parVectorMap.hpp:59
MPI_Comm comm
The working MPI Communicator.
Definition: parVectorMap.hpp:45
int nproc
number of MPI procs within the working MPI communicator parVectorMap::comm
Definition: parVectorMap.hpp:47
~parVectorMap()
A destructor of `parVectorMap`.
Definition: parVectorMap.hpp:169
S local_size
The number of elements of vector stored on each MPI proc.
Definition: parVectorMap.hpp:55
S GetGlobalSize()
Return parVectorMap<S>::global_size.
Definition: parVectorMap.hpp:132