1 #ifndef _ZOLTAN2_MACHINE_DRAGONFLY_RCALIBTEST_HPP_
2 #define _ZOLTAN2_MACHINE_DRAGONFLY_RCALIBTEST_HPP_
4 #include <Teuchos_Comm.hpp>
5 #include <Teuchos_CommHelpers.hpp>
21 template <
typename pcoord_t,
typename part_t>
35 transformed_networkDim(3),
37 transformed_procCoords(NULL),
38 actual_procCoords(NULL),
39 transformed_machine_extent(NULL),
40 actual_machine_extent(NULL),
43 is_transformed(false),
46 actual_machine_extent =
new int[actual_networkDim];
51 group_count =
new part_t[actual_machine_extent[0]];
53 memset(group_count, 0,
sizeof(
part_t) * actual_machine_extent[0]);
56 transformed_networkDim = 1 + actual_machine_extent[1] +
57 actual_machine_extent[2];
58 transformed_machine_extent =
new int[transformed_networkDim];
61 actual_procCoords =
new pcoord_t *[actual_networkDim];
62 transformed_procCoords =
new pcoord_t *[transformed_networkDim];
64 for (
int i = 0; i < actual_networkDim; ++i) {
65 actual_procCoords[i] =
new pcoord_t[this->
numRanks];
66 memset(actual_procCoords[i], 0,
70 pcoord_t *xyz =
new pcoord_t[transformed_networkDim];
72 for (
int i = 0; i < actual_networkDim; ++i)
73 actual_procCoords[i][this->
myRank] = xyz[i];
79 memset(tmp_vec, 0,
sizeof(
part_t) * actual_machine_extent[0]);
81 Teuchos::reduceAll<int, part_t>(comm, Teuchos::REDUCE_SUM,
82 actual_machine_extent[0],
87 num_unique_groups = 0;
89 for (
int i = 0; i < actual_machine_extent[0]; ++i) {
97 group_count =
new part_t[num_unique_groups];
100 for (
int i = 0; i < actual_machine_extent[0]; ++i) {
101 if (tmp_vec[i] > 0) {
102 group_count[pos] = tmp_vec[i];
110 gatherMachineCoordinates(this->actual_procCoords,
111 this->actual_networkDim, comm);
131 const Teuchos::ParameterList &pl_ ):
133 transformed_networkDim(3),
134 actual_networkDim(3),
135 transformed_procCoords(NULL),
136 actual_procCoords(NULL),
137 transformed_machine_extent(NULL),
138 actual_machine_extent(NULL),
139 num_unique_groups(0),
141 is_transformed(false),
144 actual_machine_extent =
new int[actual_networkDim];
149 group_count =
new part_t[actual_machine_extent[0]];
151 memset(group_count, 0,
sizeof(
part_t) * actual_machine_extent[0]);
154 actual_procCoords =
new pcoord_t *[actual_networkDim];
155 transformed_procCoords =
new pcoord_t *[transformed_networkDim];
157 pcoord_t *xyz =
new pcoord_t[actual_networkDim];
163 memset(tmp_vec, 0,
sizeof(
part_t) * actual_machine_extent[0]);
165 Teuchos::reduceAll<int, part_t>(comm, Teuchos::REDUCE_SUM,
166 actual_machine_extent[0],
171 num_unique_groups = 0;
173 for (
int i = 0; i < actual_machine_extent[0]; ++i) {
174 if (tmp_vec[i] > 0) {
180 delete[] group_count;
181 group_count =
new part_t[num_unique_groups];
184 for (
int i = 0; i < actual_machine_extent[0]; ++i)
186 if (tmp_vec[i] > 0) {
187 group_count[pos] = tmp_vec[i];
193 const Teuchos::ParameterEntry *pe2 =
194 this->pl->getEntryPtr(
"Machine_Optimization_Level");
198 int optimization_level;
199 optimization_level = pe2->getValue<
int>(&optimization_level);
201 if (optimization_level > 0) {
202 is_transformed =
true;
205 transformed_networkDim = 1 + actual_machine_extent[1] +
206 actual_machine_extent[2];
207 transformed_machine_extent =
new int[transformed_networkDim];
209 transformed_procCoords =
new pcoord_t *[transformed_networkDim];
212 for (
int i = 0; i < transformed_networkDim; ++i) {
213 transformed_procCoords[i] =
new pcoord_t[this->
numRanks];
214 memset(transformed_procCoords[i], 0,
219 int nx = this->actual_machine_extent[0];
220 int ny = this->actual_machine_extent[1];
221 int nz = this->actual_machine_extent[2];
223 const Teuchos::ParameterEntry *pe_x =
224 this->pl->getEntryPtr(
"Machine_X_Stretch");
225 const Teuchos::ParameterEntry *pe_y =
226 this->pl->getEntryPtr(
"Machine_Y_Stretch");
227 const Teuchos::ParameterEntry *pe_z =
228 this->pl->getEntryPtr(
"Machine_Z_Stretch");
236 x_stretch = pe_x->getValue<
int>(&x_stretch);
238 y_stretch = pe_y->getValue<
int>(&y_stretch);
240 z_stretch = pe_z->getValue<
int>(&z_stretch);
243 transformed_procCoords[0][this->
myRank] =
244 x_stretch * xyz[0] * ny * nz;
247 for (
int i = 1; i < 1 + ny; ++i) {
249 transformed_procCoords[i][this->
myRank] = 0;
251 if (xyz[1] == i - 1) {
252 transformed_procCoords[i][this->
myRank] = y_stretch;
256 for (
int i = 1 + ny; i < transformed_networkDim; ++i) {
258 transformed_procCoords[i][this->
myRank] = 0;
260 if (xyz[2] == i - (1 + ny))
261 transformed_procCoords[i][this->
myRank] = z_stretch;
264 this->transformed_machine_extent =
new int[transformed_networkDim];
267 this->transformed_machine_extent[0] = x_stretch * (nx - 1) * ny * nz;
268 for (
int i = 1; i < 1 + ny; ++i) {
269 this->transformed_machine_extent[i] = y_stretch;
271 for (
int i = 1 + ny; i < transformed_networkDim; ++i) {
272 this->transformed_machine_extent[i] = z_stretch;
276 gatherMachineCoordinates(this->transformed_procCoords,
277 this->transformed_networkDim, comm);
283 if (!is_transformed) {
285 for (
int i = 0; i < actual_networkDim; ++i) {
286 actual_procCoords[i] =
new pcoord_t[this->
numRanks];
287 memset(actual_procCoords[i], 0,
291 for (
int i = 0; i < actual_networkDim; ++i)
292 actual_procCoords[i][this->
myRank] = xyz[i];
295 gatherMachineCoordinates(this->actual_procCoords,
296 this->actual_networkDim, comm);
305 if (is_transformed) {
306 is_transformed =
false;
308 for (
int i = 0; i < transformed_networkDim; ++i) {
309 delete [] transformed_procCoords[i];
312 delete [] transformed_machine_extent;
316 for (
int i = 0; i < actual_networkDim; ++i) {
317 delete [] actual_procCoords[i];
322 delete [] actual_procCoords;
323 delete [] transformed_procCoords;
325 delete [] actual_machine_extent;
326 delete [] group_count;
334 return this->transformed_networkDim;
336 return this->actual_networkDim;
341 if (is_transformed) {
342 for (
int dim = 0; dim < transformed_networkDim; ++dim)
343 nxyz[dim] = this->transformed_machine_extent[dim];
392 return this->num_unique_groups;
398 if (group_count != NULL) {
399 for (
int i = 0; i < num_unique_groups; ++i) {
400 grp_count[i] = this->group_count[i];
413 if (is_transformed) {
414 for (
int i = 0; i < this->
numRanks; ++i) {
415 std::cout <<
"Rank:" << i <<
" ";
416 for (
int j = 0; j < this->transformed_networkDim; ++j) {
417 std::cout <<
" " << this->transformed_procCoords[j][i];
419 std::cout << std::endl;
422 std::cout << std::endl <<
"Transformed Machine Extent: ";
423 for (
int i = 0; i < this->transformed_networkDim; ++i) {
424 std::cout <<
" " << this->transformed_machine_extent[i];
426 std::cout << std::endl;
430 for (
int i = 0; i < this->
numRanks; ++i) {
431 std::cout <<
"Rank:" << i;
432 for (
int j = 0; j < this->actual_networkDim; ++j) {
433 std::cout <<
" " << actual_procCoords[j][i];
435 std::cout << std::endl;
438 std::cout << std::endl <<
"Actual Machine Extent: ";
439 for (
int i = 0; i < this->actual_networkDim; ++i) {
440 std::cout <<
" " << this->actual_machine_extent[i];
442 std::cout << std::endl;
449 if (is_transformed) {
450 for (
int i = 0; i < this->transformed_networkDim; ++i) {
451 xyz[i] = transformed_procCoords[i][this->
myRank];
516 pcoord_t *xyz)
const {
517 if (is_transformed) {
518 for (
int i = 0; i < this->transformed_networkDim; ++i) {
519 xyz[i] = transformed_procCoords[i][rank];
523 for (
int i = 0; i < this->actual_networkDim; ++i) {
524 xyz[i] = actual_procCoords[i][rank];
537 if (is_transformed) {
538 allCoords = transformed_procCoords;
541 allCoords = actual_procCoords;
555 std::cerr <<
"Rank outside bounds for the machine ranks";
559 if (this->is_transformed) {
563 if (this->transformed_procCoords[0][rank1] !=
564 this->transformed_procCoords[0][rank2])
574 for (
int i = 1; i < this->transformed_networkDim; ++i) {
575 if (this->transformed_procCoords[i][rank1] !=
576 this->transformed_procCoords[i][rank2])
585 if (this->actual_procCoords[0][rank1] !=
586 this->actual_procCoords[0][rank2])
595 for (
int i = 1; i < this->actual_networkDim; ++i) {
596 if (this->actual_procCoords[i][rank1] !=
597 this->actual_procCoords[i][rank2])
608 int transformed_networkDim;
609 int actual_networkDim;
612 pcoord_t **transformed_procCoords;
613 pcoord_t **actual_procCoords;
616 part_t *transformed_machine_extent;
617 part_t *actual_machine_extent;
627 const Teuchos::ParameterList *pl;
631 void gatherMachineCoordinates(pcoord_t **&coords,
int netDim,
632 const Teuchos::Comm<int> &comm) {
634 pcoord_t *tmpVect =
new pcoord_t [this->
numRanks];
636 for (
int i = 0; i < netDim; ++i) {
637 Teuchos::reduceAll<int, pcoord_t>(comm, Teuchos::REDUCE_SUM,
640 pcoord_t *tmp = tmpVect;
virtual bool getHopCount(int rank1, int rank2, pcoord_t &hops)
getHopCount function set hops between rank1 and rank2 return true if coordinates are available ...
MachineDragonflyRCAForTesting(const Teuchos::Comm< int > &comm)
Constructor: Dragonfly (e.g. Cori & Trinity) RCA network machine description;.
bool getMyActualMachineCoordinate(pcoord_t *xyz)
A Dragonfly (e.g. Cori, Trinity, Theta) Machine Class for testing only. A more realistic machine shou...
MachineDragonflyRCAForTesting(const Teuchos::Comm< int > &comm, const Teuchos::ParameterList &pl_)
Constructor: Dragonfly (e.g. Cori & Trinity) network machine description;.
virtual bool getMachineExtentWrapArounds(bool *wrap_around) const
MachineClass Base class for representing machine coordinates, networks, etc.
SparseMatrixAdapter_t::part_t part_t
int getMachineDim() const
virtual ~MachineDragonflyRCAForTesting()
bool getMyMachineCoordinate(pcoord_t *xyz)
bool getMachineCoordinate(const int rank, pcoord_t *xyz) const
bool hasMachineCoordinates() const
bool getGroupCount(part_t *grp_count) const override
bool getMachineCoordinate(const char *nodename, pcoord_t *xyz)
bool getAllMachineCoordinatesView(pcoord_t **&allCoords) const
bool getMyTransformedMachineCoordinate(pcoord_t *xyz)
bool getActualMachineExtent(int *nxyz) const
part_t getNumUniqueGroups() const override
getNumUniqueGroups function return the number of unique Dragonfly network groups in provided allocati...
bool getMachineExtent(int *nxyz) const
bool getTransformedMachineExtent(int *nxyz) const