95 transformed_networkDim(3),
97 transformed_procCoords(NULL),
98 actual_procCoords(NULL),
99 transformed_machine_extent(NULL),
100 actual_machine_extent(NULL),
101 num_unique_groups(0),
103 is_transformed(false),
106 actual_machine_extent =
new int[actual_networkDim];
111 group_count =
new part_t[actual_machine_extent[0]];
113 memset(group_count, 0,
sizeof(
part_t) * actual_machine_extent[0]);
116 transformed_networkDim = 1 + actual_machine_extent[1] +
117 actual_machine_extent[2];
118 transformed_machine_extent =
new int[transformed_networkDim];
121 actual_procCoords =
new pcoord_t *[actual_networkDim];
122 transformed_procCoords =
new pcoord_t *[transformed_networkDim];
124 for (
int i = 0; i < actual_networkDim; ++i) {
125 actual_procCoords[i] =
new pcoord_t[this->
numRanks];
126 memset(actual_procCoords[i], 0,
130 pcoord_t *xyz =
new pcoord_t[transformed_networkDim];
132 for (
int i = 0; i < actual_networkDim; ++i)
133 actual_procCoords[i][this->
myRank] = xyz[i];
138 part_t * tmp_vec =
new part_t[actual_machine_extent[0]];
139 memset(tmp_vec, 0,
sizeof(
part_t) * actual_machine_extent[0]);
141 Teuchos::reduceAll<int, part_t>(comm, Teuchos::REDUCE_SUM,
142 actual_machine_extent[0],
147 num_unique_groups = 0;
149 for (
int i = 0; i < actual_machine_extent[0]; ++i) {
150 if (tmp_vec[i] > 0) {
156 delete[] group_count;
157 group_count =
new part_t[num_unique_groups];
160 for (
int i = 0; i < actual_machine_extent[0]; ++i) {
161 if (tmp_vec[i] > 0) {
162 group_count[pos] = tmp_vec[i];
170 gatherMachineCoordinates(this->actual_procCoords,
171 this->actual_networkDim, comm);
191 const Teuchos::ParameterList &pl_ ):
193 transformed_networkDim(3),
194 actual_networkDim(3),
195 transformed_procCoords(NULL),
196 actual_procCoords(NULL),
197 transformed_machine_extent(NULL),
198 actual_machine_extent(NULL),
199 num_unique_groups(0),
201 is_transformed(false),
204 actual_machine_extent =
new int[actual_networkDim];
208 group_count =
new part_t[actual_machine_extent[0]];
210 memset(group_count, 0,
sizeof(
part_t) * actual_machine_extent[0]);
213 actual_procCoords =
new pcoord_t *[actual_networkDim];
214 transformed_procCoords =
new pcoord_t *[transformed_networkDim];
216 pcoord_t *xyz =
new pcoord_t[actual_networkDim];
221 part_t * tmp_vec =
new part_t[actual_machine_extent[0]];
222 memset(tmp_vec, 0,
sizeof(
part_t) * actual_machine_extent[0]);
224 Teuchos::reduceAll<int, part_t>(comm, Teuchos::REDUCE_SUM,
225 actual_machine_extent[0],
230 num_unique_groups = 0;
232 for (
int i = 0; i < actual_machine_extent[0]; ++i) {
233 if (tmp_vec[i] > 0) {
239 delete[] group_count;
240 group_count =
new part_t[num_unique_groups];
243 for (
int i = 0; i < actual_machine_extent[0]; ++i) {
244 if (tmp_vec[i] > 0) {
245 group_count[pos] = tmp_vec[i];
251 const Teuchos::ParameterEntry *pe2 =
252 this->pl->getEntryPtr(
"Machine_Optimization_Level");
256 int optimization_level;
257 optimization_level = pe2->getValue<
int>(&optimization_level);
259 if (optimization_level > 0) {
260 is_transformed =
true;
263 transformed_networkDim = 1 + actual_machine_extent[1] +
264 actual_machine_extent[2];
265 transformed_machine_extent =
new int[transformed_networkDim];
267 transformed_procCoords =
new pcoord_t *[transformed_networkDim];
270 for (
int i = 0; i < transformed_networkDim; ++i) {
271 transformed_procCoords[i] =
new pcoord_t[this->
numRanks];
272 memset(transformed_procCoords[i], 0,
277 int nx = this->actual_machine_extent[0];
278 int ny = this->actual_machine_extent[1];
279 int nz = this->actual_machine_extent[2];
281 const Teuchos::ParameterEntry *pe_x =
282 this->pl->getEntryPtr(
"Machine_X_Stretch");
283 const Teuchos::ParameterEntry *pe_y =
284 this->pl->getEntryPtr(
"Machine_Y_Stretch");
285 const Teuchos::ParameterEntry *pe_z =
286 this->pl->getEntryPtr(
"Machine_Z_Stretch");
294 x_stretch = pe_x->getValue<
int>(&x_stretch);
296 y_stretch = pe_y->getValue<
int>(&y_stretch);
298 z_stretch = pe_z->getValue<
int>(&z_stretch);
301 transformed_procCoords[0][this->
myRank] =
302 x_stretch * xyz[0] * ny * nz;
305 for (
int i = 1; i < 1 + ny; ++i) {
307 transformed_procCoords[i][this->
myRank] = 0;
310 transformed_procCoords[i][this->
myRank] = y_stretch;
313 for (
int i = 1 + ny; i < transformed_networkDim; ++i) {
315 transformed_procCoords[i][this->
myRank] = 0;
317 if (xyz[2] == i - (1 + ny))
318 transformed_procCoords[i][this->
myRank] = z_stretch;
321 this->transformed_machine_extent =
new int[transformed_networkDim];
324 this->transformed_machine_extent[0] = x_stretch * (nx - 1) * ny * nz;
325 for (
int i = 1; i < 1 + ny; ++i) {
326 this->transformed_machine_extent[i] = y_stretch;
328 for (
int i = 1 + ny; i < transformed_networkDim; ++i) {
329 this->transformed_machine_extent[i] = z_stretch;
333 gatherMachineCoordinates(this->transformed_procCoords,
334 this->transformed_networkDim, comm);
340 if (!is_transformed) {
342 for (
int i = 0; i < actual_networkDim; ++i) {
343 actual_procCoords[i] =
new pcoord_t[this->
numRanks];
344 memset(actual_procCoords[i], 0,
348 for (
int i = 0; i < actual_networkDim; ++i)
349 actual_procCoords[i][this->
myRank] = xyz[i];
352 gatherMachineCoordinates(this->actual_procCoords,
353 this->actual_networkDim, comm);
581 virtual bool getHopCount(
int rank1,
int rank2, pcoord_t &hops)
const override {
584 if (is_transformed) {
588 if (this->transformed_procCoords[0][rank1] !=
589 this->transformed_procCoords[0][rank2])
598 for (
int i = 1; i < this->transformed_networkDim; ++i) {
599 if (this->transformed_procCoords[i][rank1] !=
600 this->transformed_procCoords[i][rank2])
609 if (this->actual_procCoords[0][rank1] !=
610 this->actual_procCoords[0][rank2])
619 for (
int i = 1; i < actual_networkDim; ++i) {
620 if (this->actual_procCoords[i][rank1] !=
621 this->actual_procCoords[i][rank2])