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 narg,
char *arg[])
142 Tpetra::ScopeGuard tscope(&narg, &arg);
143 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
145 int me = comm->getRank();
146 int np = comm->getSize();
148 char node0[6] = {
'n',
'o',
'd',
'e',
'0',
'\0'};
155 Teuchos::ParameterList pl;
163 fail += checkAllCoords<ncoord_t,part_t>(*comm, mach);
168 #if defined(HAVE_ZOLTAN2_LDMS)
170 if (me == 0 ) std::cout <<
"LDMS Topology" << std::endl;
174 #elif defined(HAVE_ZOLTAN2_RCALIB)
176 if (me == 0 ) std::cout <<
"RCALIB Topology" << std::endl;
181 #elif defined(HAVE_ZOLTAN2_TOPOMANAGER)
183 if (me == 0 ) std::cout <<
"TOPOMANAGER Topology" << std::endl;
188 #elif defined(HAVE_ZOLTAN2_BGQTEST)
190 if (me == 0 ) std::cout <<
"BGQTEST Topology" << std::endl;
197 if (me == 0 ) std::cout <<
"TEST Topology" << std::endl;
200 std::cout <<
"Error: Dimension != 3" << std::endl;
206 std::cout <<
"Error: getMachineExtent failed" << std::endl;
209 if (nxyz[0] != np || nxyz[1] != 2*np || nxyz[2] != 3*np) {
211 std::cout <<
"Error: incorrect MachineExtent" << std::endl;
218 ncoord_t xyz_expected[3] = {me, np, np+1};
221 std::cout <<
"Error: getMyMachineCoordinate failed" << std::endl;
225 if ((xyz[0] != xyz_expected[0]) ||
226 (xyz[1] != xyz_expected[1]) ||
227 (xyz[2] != xyz_expected[2])) {
228 std::cout <<
"Error: incorrect MyMachineCoordinate" << std::endl;
234 std::cout <<
"Error: getMachineCoordinate failed" << std::endl;
243 if (me == 0) std::cout <<
"PASS" << std::endl;
int main(int narg, char *arg[])
common code used by tests
int checkErrorCode(Teuchos::RCP< const Teuchos::Comm< int > > &comm, int code)
bool getMachineCoordinate(const int rank, pcoord_t *xyz) const
getCoordinate function set the machine coordinate xyz of any rank process return true if coordinates ...
SparseMatrixAdapter_t::part_t part_t
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
int getNumRanks() const
return the number of 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 hasMachineCoordinates() const
indicates whether or not the machine has coordinates
bool getMyMachineCoordinate(pcoord_t *xyz) const
getMyCoordinate function set the machine coordinate xyz of the current process return true if current...
int checkAllCoords(const Teuchos::Comm< int > &comm, const Zoltan2::MachineRepresentation< nCoord_t, part_t > &mach)
bool getMachineExtent(int *nxyz) const
sets the number of unique coordinates in each machine dimension return true if coordinates are availa...