18
. Querying Network Topology
The following calls provide information about the machine upon which the
parallel program is executed. A processing element (PE) refers to a single CPU,
whereas a node refers to a single machine - a set of processing elements that share
memory (i.e. an address space). PEs and nodes are ranked separately starting
from zero, i.e., PEs are ranked in range 0 to
CmiNumPes()
, and nodes are
ranked in range 0 to
CmiNumNodes()
.
Charm++ provides a unified abstraction for querying topology of IBM's BG/L, BG/P
and BG/Q, and Cray's XT4, XT5 and XE6. Class TopoManager, which can be used
by including TopoManager.h, contains following member functions:
- TopoManager():
- Default constructor.
- getDimNX(), getDimNY(), getDimNZ():
- Returns the length of X, Y and Z dimensions (except BG/Q).
- getDimNA(), getDimNB(), getDimNC(), getDimND(), getDimNE():
- Returns the length of A, B, C, D and E dimensions on BG/Q.
- getDimNT():
- Returns the length of T dimension. TopoManager uses T dimension to represent different cores that reside within a physical node.
- rankToCoordinates(int pe, int &x, int &y, int &z, int &t):
- Get the coordinates of PE with rank pe (except BG/Q).
- rankToCoordinates(int pe, int &a, int &b, int &c, int &d, int &e, int &t):
- Get the coordinates of PE with rank pe on BG/Q.
- coordinatesToRank(int x, int y, int z, int t):
- Returns the rank of PE with given coordinates (except BG/Q).
- coordinatesToRank(int a, int b, int c, int d, int e, int t):
- Returns the rank of PE with given coordinates on BG/Q.
- getHopsBetweenRanks(int pe1, int pe2):
- Returns the distance between the given PEs in terms of the hops count on the network between the two PEs.
- printAllocation(FILE *fp):
- Outputs the allocation for a particular execution to the given file.
For example, one can obtain rank of a processor, whose coordinates are known, on BG/P as well as on Cray XE6 using the following code:
TopoManager tmgr;
int rank,x,y,z,t;
x = y = z = t = 2;
rank = tmgr.coordinatesToRank(x,y,z,t);
For more examples, please refer to examples/charm++/topology.