1 #ifndef _ZOLTAN2_MACHINEDEFAULT_HPP_
2 #define _ZOLTAN2_MACHINEDEFAULT_HPP_
4 #include <Teuchos_Comm.hpp>
5 #include <Teuchos_CommHelpers.hpp>
14 template <
typename nNo_t,
typename nCoord_t>
22 nCoord_t **procCoords;
31 numProcs(comm.getSize()),
32 myRank(comm.getRank()),
57 procCoords =
new nCoord_t *[networkDim];
58 for (
int i = 0; i < networkDim; ++i) {
59 procCoords[i] =
new nCoord_t [numProcs];
60 memset (procCoords[i], 0,
sizeof(nCoord_t) * numProcs);
77 numProcs(comm_->getSize()),
103 procCoords =
new nCoord_t *[networkDim];
104 for (
int i = 0; i < networkDim; ++i) {
105 procCoords[i] =
new nCoord_t [numProcs];
106 memset (procCoords[i], 0,
sizeof(nCoord_t) * numProcs);
136 int myRank = comm->getRank();
138 int slice = int (pow(
double(numProcs),
double(1.0 / networkDim)) + 0.5 );
141 for (
int i = 0; i < networkDim; ++i) {
142 procCoords[i][myRank] = m / int(pow(slice,
double(networkDim - i - 1)));
143 m = m % int(pow(
double(slice),
double(networkDim - i - 1)));
155 nCoord_t *tmpVect =
new nCoord_t [numProcs];
157 for (
int i = 0; i < networkDim; ++i) {
158 reduceAll<int, nCoord_t>(
164 nCoord_t *tmp = tmpVect;
165 tmpVect = procCoords[i];
175 for (
int i = 0; i < networkDim; ++i) {
176 delete [] procCoords[i];
178 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.