1 #ifndef _ZOLTAN2_MACHINEREPRESENTATION_HPP_ 2 #define _ZOLTAN2_MACHINEREPRESENTATION_HPP_ 4 #include <Teuchos_Comm.hpp> 5 #include <Teuchos_CommHelpers.hpp> 12 template <
typename pcoord_t>
19 pcoord_t **procCoords;
20 const RCP<const Comm<int> > comm;
27 networkDim(0), numProcs(comm_->getSize()), procCoords(0), comm(comm_){
50 procCoords =
new pcoord_t *[networkDim];
51 for (
int i = 0; i < networkDim; ++i){
52 procCoords[i] =
new pcoord_t [numProcs];
53 memset (procCoords[i], 0,
sizeof(pcoord_t) * numProcs);
68 networkDim(0), numProcs(comm_->getSize()), procCoords(0), comm(comm_){
91 procCoords =
new pcoord_t *[networkDim];
92 for (
int i = 0; i < networkDim; ++i){
93 procCoords[i] =
new pcoord_t [numProcs];
94 memset (procCoords[i], 0,
sizeof(pcoord_t) * numProcs);
117 int myRank = comm->getRank();
119 int slice = int (pow(
double(numProcs),
double(1.0 / networkDim)) + 0.5 );
122 for (
int i = 0; i < networkDim; ++i){
123 procCoords[i][myRank] = m / int(pow(slice,
double(networkDim - i - 1)));
124 m = m % int(pow(
double(slice),
double(networkDim - i - 1)));
132 pcoord_t *tmpVect =
new pcoord_t [numProcs];
134 for (
int i = 0; i < networkDim; ++i){
135 reduceAll<int, pcoord_t>(
141 pcoord_t *tmp = tmpVect;
142 tmpVect = procCoords[i];
152 for (
int i = 0; i < networkDim; ++i){
153 delete [] procCoords[i];
pcoord_t ** getProcCoords() const
getProcDim function returns the coordinates of processors in two dimensional array.
MachineRepresentation(const RCP< Comm< int > > &comm_)
Constructor MachineRepresentation Class.
MachineRepresentation(const RCP< const Comm< int > > &comm_)
Constructor MachineRepresentation Class.
void gatherMachineCoordinates()
gatherMachineCoordinates function reduces and stores all machine coordinates.
MachineRepresentation Class Finds the coordinate of the processor. Used to find the processor coordin...
~MachineRepresentation()
destructor of the class free memory in procCoords.
int getProcDim() const
getProcDim function returns the dimension of the physical processor layout.
int getNumProcs() const
getNumProcs function returns the number of processors.
void getMyCoordinate()
getMyCoordinate function stores the coordinate of the current processor in procCoords[*][rank] ...