1 #ifndef _ZOLTAN2_MACHINEDEFAULT_HPP_
2 #define _ZOLTAN2_MACHINEDEFAULT_HPP_
4 #include <Teuchos_Comm.hpp>
5 #include <Teuchos_CommHelpers.hpp>
13 template <
typename nNo_t,
typename nCoord_t>
21 nCoord_t **procCoords;
29 networkDim(0), numProcs(comm.getSize()), myRank(comm.getRank()),
54 procCoords =
new nCoord_t *[networkDim];
55 for (
int i = 0; i < networkDim; ++i){
56 procCoords[i] =
new nCoord_t [numProcs];
57 memset (procCoords[i], 0,
sizeof(nCoord_t) * numProcs);
72 networkDim(0), numProcs(comm_->getSize()), procCoords(0), comm(comm_){
95 procCoords =
new nCoord_t *[networkDim];
96 for (
int i = 0; i < networkDim; ++i){
97 procCoords[i] =
new nCoord_t [numProcs];
98 memset (procCoords[i], 0,
sizeof(nCoord_t) * numProcs);
127 int myRank = comm->getRank();
129 int slice = int (pow(
double(numProcs),
double(1.0 / networkDim)) + 0.5 );
132 for (
int i = 0; i < networkDim; ++i){
133 procCoords[i][myRank] = m / int(pow(slice,
double(networkDim - i - 1)));
134 m = m % int(pow(
double(slice),
double(networkDim - i - 1)));
146 nCoord_t *tmpVect =
new nCoord_t [numProcs];
148 for (
int i = 0; i < networkDim; ++i){
149 reduceAll<int, nCoord_t>(
155 nCoord_t *tmp = tmpVect;
156 tmpVect = procCoords[i];
166 for (
int i = 0; i < networkDim; ++i){
167 delete [] procCoords[i];
169 delete [] procCoords;
A Default MachineRepresentation Class for testing only A more correct machine representation should b...
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.