10 #ifndef _ZOLTAN2_MACHINEDEFAULT_HPP_
11 #define _ZOLTAN2_MACHINEDEFAULT_HPP_
13 #include <Teuchos_Comm.hpp>
14 #include <Teuchos_CommHelpers.hpp>
23 template <
typename nNo_t,
typename nCoord_t>
31 nCoord_t **procCoords;
40 numProcs(comm.getSize()),
41 myRank(comm.getRank()),
66 procCoords =
new nCoord_t *[networkDim];
67 for (
int i = 0; i < networkDim; ++i) {
68 procCoords[i] =
new nCoord_t [numProcs];
69 memset (procCoords[i], 0,
sizeof(nCoord_t) * numProcs);
86 numProcs(comm_->getSize()),
112 procCoords =
new nCoord_t *[networkDim];
113 for (
int i = 0; i < networkDim; ++i) {
114 procCoords[i] =
new nCoord_t [numProcs];
115 memset (procCoords[i], 0,
sizeof(nCoord_t) * numProcs);
145 int myRank = comm->getRank();
147 int slice = int (pow(
double(numProcs),
double(1.0 / networkDim)) + 0.5 );
150 for (
int i = 0; i < networkDim; ++i) {
151 procCoords[i][myRank] = m / int(pow(slice,
double(networkDim - i - 1)));
152 m = m % int(pow(
double(slice),
double(networkDim - i - 1)));
164 nCoord_t *tmpVect =
new nCoord_t [numProcs];
166 for (
int i = 0; i < networkDim; ++i) {
167 reduceAll<int, nCoord_t>(
173 nCoord_t *tmp = tmpVect;
174 tmpVect = procCoords[i];
184 for (
int i = 0; i < networkDim; ++i) {
185 delete [] procCoords[i];
187 delete [] procCoords;
A Default MachineRepresentation Class.
int getProcDim() const
getProcDim function returns the dimension of the physical processor layout.
nCoord_t ** getProcCoords() const
getProcDim function returns the coordinates of processors in two dimensional array.
void getMyCoordinate()
getMyCoordinate function stores the coordinate of the current processor in procCoords[*][rank] ...
virtual ~MachineRepresentation()
destructor of the class free memory in procCoords.
int getNumProcs() const
getNumProcs function returns the number of processors.
MachineRepresentation(const RCP< Comm< int > > &comm_)
Constructor MachineRepresentation Class.
MachineRepresentation Class Base class for representing machine coordinates, networks, etc.
MachineRepresentation(const Comm< int > &comm)
Constructor MachineRepresentation Class.
void gatherMachineCoordinates()
gatherMachineCoordinates function reduces and stores all machine coordinates.