@@ -233,37 +233,38 @@ double MaxVal(double TestVec3[6], int NVals) {
233
233
// *****************************************************************************/
234
234
// Determine the mapping of processors to grid data
235
235
void InitialDecomposition (int &DecompositionStrategy, int nx, int ny, int &ProcessorsInXDirection,
236
- int &ProcessorsInYDirection, int id, int np, int &MyLeft, int &MyRight, int &MyIn, int &MyOut,
237
- int &MyLeftIn, int &MyLeftOut, int &MyRightIn, int &MyRightOut) {
236
+ int &ProcessorsInYDirection, int id, int np, int &NeighborRank_North, int &NeighborRank_South,
237
+ int &NeighborRank_East, int &NeighborRank_West, int &NeighborRank_NorthEast,
238
+ int &NeighborRank_NorthWest, int &NeighborRank_SouthEast, int &NeighborRank_SouthWest) {
238
239
239
240
if (DecompositionStrategy == 1 ) {
240
241
OneDim:
241
242
ProcessorsInXDirection = 1 ;
242
243
ProcessorsInYDirection = np;
243
244
if (np > 1 ) {
244
- MyLeft = id - 1 ;
245
- MyRight = id + 1 ;
245
+ NeighborRank_South = id - 1 ;
246
+ NeighborRank_North = id + 1 ;
246
247
if (id == 0 )
247
- MyLeft = MPI_PROC_NULL;
248
+ NeighborRank_South = MPI_PROC_NULL;
248
249
if (id == np - 1 )
249
- MyRight = MPI_PROC_NULL;
250
- MyIn = MPI_PROC_NULL;
251
- MyRightIn = MPI_PROC_NULL;
252
- MyOut = MPI_PROC_NULL;
253
- MyRightOut = MPI_PROC_NULL;
254
- MyLeftIn = MPI_PROC_NULL;
255
- MyLeftOut = MPI_PROC_NULL;
250
+ NeighborRank_North = MPI_PROC_NULL;
251
+ NeighborRank_West = MPI_PROC_NULL;
252
+ NeighborRank_NorthWest = MPI_PROC_NULL;
253
+ NeighborRank_NorthEast = MPI_PROC_NULL;
254
+ NeighborRank_East = MPI_PROC_NULL;
255
+ NeighborRank_SouthWest = MPI_PROC_NULL;
256
+ NeighborRank_SouthEast = MPI_PROC_NULL;
256
257
}
257
258
else {
258
259
// No MPI communication
259
- MyLeft = MPI_PROC_NULL;
260
- MyRight = MPI_PROC_NULL;
261
- MyIn = MPI_PROC_NULL;
262
- MyRightIn = MPI_PROC_NULL;
263
- MyOut = MPI_PROC_NULL;
264
- MyRightOut = MPI_PROC_NULL;
265
- MyLeftIn = MPI_PROC_NULL;
266
- MyLeftOut = MPI_PROC_NULL;
260
+ NeighborRank_West = MPI_PROC_NULL;
261
+ NeighborRank_East = MPI_PROC_NULL;
262
+ NeighborRank_North = MPI_PROC_NULL;
263
+ NeighborRank_NorthWest = MPI_PROC_NULL;
264
+ NeighborRank_NorthEast = MPI_PROC_NULL;
265
+ NeighborRank_South = MPI_PROC_NULL;
266
+ NeighborRank_SouthWest = MPI_PROC_NULL;
267
+ NeighborRank_SouthEast = MPI_PROC_NULL;
267
268
}
268
269
}
269
270
else if (DecompositionStrategy == 2 ) {
@@ -276,31 +277,30 @@ void InitialDecomposition(int &DecompositionStrategy, int nx, int ny, int &Proce
276
277
}
277
278
ProcessorsInXDirection = 2 ;
278
279
ProcessorsInYDirection = np / 2 ;
279
- MyLeft = id - 1 ;
280
- MyRight = id + 1 ;
281
- MyIn = id + ProcessorsInYDirection;
282
- MyOut = id - ProcessorsInYDirection;
283
- MyLeftIn = MyIn - 1 ;
284
- MyRightIn = MyIn + 1 ;
285
- ;
286
- MyLeftOut = MyOut - 1 ;
287
- MyRightOut = MyOut + 1 ;
280
+ NeighborRank_South = id - 1 ;
281
+ NeighborRank_North = id + 1 ;
282
+ NeighborRank_East = id + ProcessorsInYDirection;
283
+ NeighborRank_West = id - ProcessorsInYDirection;
284
+ NeighborRank_SouthEast = NeighborRank_East - 1 ;
285
+ NeighborRank_NorthEast = NeighborRank_East + 1 ;
286
+ NeighborRank_SouthWest = NeighborRank_West - 1 ;
287
+ NeighborRank_NorthWest = NeighborRank_West + 1 ;
288
288
if (id % ProcessorsInYDirection == 0 )
289
- MyLeft = MPI_PROC_NULL;
289
+ NeighborRank_South = MPI_PROC_NULL;
290
290
if (id % ProcessorsInYDirection == ProcessorsInYDirection - 1 )
291
- MyRight = MPI_PROC_NULL;
291
+ NeighborRank_North = MPI_PROC_NULL;
292
292
if (id < ProcessorsInYDirection)
293
- MyOut = MPI_PROC_NULL;
293
+ NeighborRank_West = MPI_PROC_NULL;
294
294
if (id >= (np - ProcessorsInYDirection))
295
- MyIn = MPI_PROC_NULL;
296
- if ((MyLeft == MPI_PROC_NULL) || (MyIn == MPI_PROC_NULL))
297
- MyLeftIn = MPI_PROC_NULL;
298
- if ((MyRight == MPI_PROC_NULL) || (MyIn == MPI_PROC_NULL))
299
- MyRightIn = MPI_PROC_NULL;
300
- if ((MyLeft == MPI_PROC_NULL) || (MyOut == MPI_PROC_NULL))
301
- MyLeftOut = MPI_PROC_NULL;
302
- if ((MyRight == MPI_PROC_NULL) || (MyOut == MPI_PROC_NULL))
303
- MyRightOut = MPI_PROC_NULL;
295
+ NeighborRank_East = MPI_PROC_NULL;
296
+ if ((NeighborRank_South == MPI_PROC_NULL) || (NeighborRank_East == MPI_PROC_NULL))
297
+ NeighborRank_SouthEast = MPI_PROC_NULL;
298
+ if ((NeighborRank_North == MPI_PROC_NULL) || (NeighborRank_East == MPI_PROC_NULL))
299
+ NeighborRank_NorthEast = MPI_PROC_NULL;
300
+ if ((NeighborRank_South == MPI_PROC_NULL) || (NeighborRank_West == MPI_PROC_NULL))
301
+ NeighborRank_SouthWest = MPI_PROC_NULL;
302
+ if ((NeighborRank_North == MPI_PROC_NULL) || (NeighborRank_West == MPI_PROC_NULL))
303
+ NeighborRank_NorthWest = MPI_PROC_NULL;
304
304
}
305
305
else if (DecompositionStrategy == 3 ) {
306
306
@@ -362,48 +362,54 @@ void InitialDecomposition(int &DecompositionStrategy, int nx, int ny, int &Proce
362
362
if (id == 0 )
363
363
std::cout << " Processors in X: " << ProcessorsInXDirection
364
364
<< " Processors in Y: " << ProcessorsInYDirection << std::endl;
365
- MyLeft = id - 1 ;
366
- MyRight = id + 1 ;
367
- MyIn = id + ProcessorsInYDirection;
368
- MyOut = id - ProcessorsInYDirection;
369
- MyLeftIn = MyIn - 1 ;
370
- MyRightIn = MyIn + 1 ;
371
- ;
372
- MyLeftOut = MyOut - 1 ;
373
- MyRightOut = MyOut + 1 ;
365
+ NeighborRank_South = id - 1 ;
366
+ NeighborRank_North = id + 1 ;
367
+ NeighborRank_East = id + ProcessorsInYDirection;
368
+ NeighborRank_West = id - ProcessorsInYDirection;
374
369
if (id % ProcessorsInYDirection == 0 )
375
- MyLeft = MPI_PROC_NULL;
370
+ NeighborRank_South = MPI_PROC_NULL;
376
371
if (id % ProcessorsInYDirection == ProcessorsInYDirection - 1 )
377
- MyRight = MPI_PROC_NULL;
372
+ NeighborRank_North = MPI_PROC_NULL;
378
373
if (id < ProcessorsInYDirection)
379
- MyOut = MPI_PROC_NULL;
374
+ NeighborRank_West = MPI_PROC_NULL;
380
375
if (id >= (np - ProcessorsInYDirection))
381
- MyIn = MPI_PROC_NULL;
382
- if ((MyLeft == MPI_PROC_NULL) || (MyIn == MPI_PROC_NULL))
383
- MyLeftIn = MPI_PROC_NULL;
384
- if ((MyRight == MPI_PROC_NULL) || (MyIn == MPI_PROC_NULL))
385
- MyRightIn = MPI_PROC_NULL;
386
- if ((MyLeft == MPI_PROC_NULL) || (MyOut == MPI_PROC_NULL))
387
- MyLeftOut = MPI_PROC_NULL;
388
- if ((MyRight == MPI_PROC_NULL) || (MyOut == MPI_PROC_NULL))
389
- MyRightOut = MPI_PROC_NULL;
376
+ NeighborRank_East = MPI_PROC_NULL;
377
+ if ((NeighborRank_South == MPI_PROC_NULL) || (NeighborRank_East == MPI_PROC_NULL))
378
+ NeighborRank_SouthEast = MPI_PROC_NULL;
379
+ else
380
+ NeighborRank_SouthEast = NeighborRank_East - 1 ;
381
+
382
+ if ((NeighborRank_North == MPI_PROC_NULL) || (NeighborRank_East == MPI_PROC_NULL))
383
+ NeighborRank_NorthEast = MPI_PROC_NULL;
384
+ else
385
+ NeighborRank_NorthEast = NeighborRank_East + 1 ;
386
+
387
+ if ((NeighborRank_South == MPI_PROC_NULL) || (NeighborRank_West == MPI_PROC_NULL))
388
+ NeighborRank_SouthWest = MPI_PROC_NULL;
389
+ else
390
+ NeighborRank_SouthWest = NeighborRank_West - 1 ;
391
+
392
+ if ((NeighborRank_North == MPI_PROC_NULL) || (NeighborRank_West == MPI_PROC_NULL))
393
+ NeighborRank_NorthWest = MPI_PROC_NULL;
394
+ else
395
+ NeighborRank_NorthWest = NeighborRank_West + 1 ;
390
396
}
391
397
}
392
398
393
399
// *****************************************************************************/
394
400
// Determine the scan limits for each rank in X and Y directions
395
- void XYLimitCalc (int &LLX, int &LLY, int &ULX, int &ULY, int MyXSlices, int MyYSlices, int MyLeft, int MyRight ,
396
- int MyIn , int MyOut ) {
401
+ void XYLimitCalc (int &LLX, int &LLY, int &ULX, int &ULY, int MyXSlices, int MyYSlices, int NeighborRank_South ,
402
+ int NeighborRank_North , int NeighborRank_East, int NeighborRank_West ) {
397
403
LLX = 0 ;
398
404
LLY = 0 ;
399
405
ULX = MyXSlices - 1 ;
400
406
ULY = MyYSlices - 1 ;
401
- if (MyLeft == MPI_PROC_NULL)
407
+ if (NeighborRank_South == MPI_PROC_NULL)
402
408
LLY = 1 ;
403
- if (MyRight == MPI_PROC_NULL)
409
+ if (NeighborRank_North == MPI_PROC_NULL)
404
410
ULY = MyYSlices - 2 ;
405
- if (MyIn == MPI_PROC_NULL)
411
+ if (NeighborRank_East == MPI_PROC_NULL)
406
412
ULX = MyXSlices - 2 ;
407
- if (MyOut == MPI_PROC_NULL)
413
+ if (NeighborRank_West == MPI_PROC_NULL)
408
414
LLX = 1 ;
409
415
}
0 commit comments