50 #include <Teuchos_DefaultComm.hpp> 52 template <
typename nCoord_t,
typename part_t>
61 const int failval = 100000000;
63 int np = comm.getSize();
64 int me = comm.getRank();
67 int *nxyz =
new int[dim];
69 nCoord_t *xyz =
new nCoord_t[dim];
78 for (
int i = 0; i < np; i++) {
80 if (me == 0) std::cout <<
"RANK " << i <<
" COORD ";
81 for (
int d = 0; d < dim; d++) {
82 if (me == 0) std::cout <<
" " << xyz[d];
83 if (xyz[d] != allCoords[d][i])
fail = failval;
84 if (haveExtent && (xyz[d] < 0 || xyz[d] >= nxyz[d]))
fail = failval;
86 if (me == 0) std::cout << std::endl;
89 std::cout <<
"Rank " << me
90 <<
" getMachineCoordinate failed " << std::endl;
94 if (
fail == failval) {
95 std::cout <<
"Rank " << me
96 <<
" Invalid coordinates from getAllMachineCoordinatesView or " 97 <<
"getMachineCoordinate" << std::endl;
102 for (
int d = 0; d < dim; d++)
103 if (xyz[d] != allCoords[d][me])
fail = failval;
107 std::cout <<
"Rank " << me
108 <<
"getMyMachineCoordinates failed" << std::endl;
113 std::cout <<
"Rank " << me
114 <<
"couldn't retrieve coordinates with " 115 <<
"getAllMachineCoordinatesView" << std::endl;
127 int rank = comm.getRank();
129 std::cerr <<
"Proc " << rank <<
" error: " << code << std::endl;
140 int main(
int argc,
char *argv[])
142 Teuchos::GlobalMPISession session(&argc, &argv);
143 Teuchos::RCP<const Comm<int> > comm = Teuchos::DefaultComm<int>::getComm();
145 int me = comm->getRank();
146 int np = comm->getSize();
148 char node0[6] = {
'n',
'o',
'd',
'e',
'0',
'\0'};
161 fail += checkAllCoords<ncoord_t,part_t>(*comm, mach);
166 #if defined(HAVE_ZOLTAN2_LDMS) 171 #elif defined(HAVE_ZOLTAN2_RCA) 176 #elif defined(HAVE_ZOLTAN2_TOPOMANAGER) 181 #elif defined(HAVE_ZOLTAN2_BGQTEST) 194 if (nxyz[0] != np || nxyz[1] != 2*np || nxyz[2] != 3*np)
201 ncoord_t xyz_expected[3] = {me, np, np+1};
205 if ((xyz[0] != xyz_expected[0]) ||
206 (xyz[1] != xyz_expected[1]) ||
207 (xyz[2] != xyz_expected[2]))
218 if (me == 0) std::cout <<
"PASS" << std::endl;
int main(int argc, char *argv[])
bool getMachineCoordinate(const int rank, pcoord_t *xyz) const
getCoordinate function set the machine coordinate xyz of any rank process return true if coordinates ...
common code used by tests
int checkErrorCode(const Teuchos::Comm< int > &comm, int code)
bool getMyMachineCoordinate(pcoord_t *xyz) const
getMyCoordinate function set the machine coordinate xyz of the current process return true if current...
int getMachineDim() const
returns the dimension (number of coords per node) in the machine
bool getAllMachineCoordinatesView(pcoord_t **&allCoords) const
getProcDim function set the coordinates of all ranks allCoords[i][j], i=0,...,getMachineDim(), j=0,...,getNumRanks(), is the i-th dimensional coordinate for rank j. return true if coordinates are available for all ranks
MachineRepresentation Class Base class for representing machine coordinates, networks, etc.
static const std::string fail
#define TEST_FAIL_AND_RETURN_VALUE(comm, ok, s, rc)
bool getMachineExtent(int *nxyz) const
sets the number of unique coordinates in each machine dimension return true if coordinates are availa...
int getNumRanks() const
return the number of ranks.
int checkAllCoords(const Teuchos::Comm< int > &comm, const Zoltan2::MachineRepresentation< nCoord_t, part_t > &mach)
bool hasMachineCoordinates() const
indicates whether or not the machine has coordinates