Full text
Hypercube Algorithms on Mesh Connected Multicomputers Luis Dı ´az de Cerio, Miguel Valero-Garcı ´a, and Antonio Gonza ´lez, Member,IEEE Computer Society Abstract—A new methodology named CALMANT (CC-cube Algorithms on Meshes and Tori) for mapping a kind of algorithms that we call CC-cube algorithm onto multicomputers with hypercube, mesh, or torus interconnection topology is proposed. This methodology is suitable when the initial problem can be expressed as a set of processes that communicate through a hypercube topology (a CC-cube algorithm). There are many important algorithms that fit into the CC-cube type. CALMANT is based on three different techniques: a) the standard embedding to assign the processes of the algorithm to the nodes of the mesh multicomputer; b) the communication pipelining technique to increase the level of communication parallelism inherent in the CC-cube algorithms; and c) optimal message-scheduling algorithms proposed in this work in order to avoid conflicts and minimizing in this way the communication time. Although CALMANT is proposed for multicomputers with different interconnection network topologies, this paper only focuses on the particular case of meshes. Index Terms—Mapping algorithms, hypercube algorithms, mesh interconnected multicomputers, standard embedding, communication pipelining, message-scheduling algorithms, complete exchange. æ 1INTRODUCTION DISTRIBUTED memory multiprocessors with an interconnection network based on point to point links (multicomputer for short) is a common architecture of parallel computers. Among different interconnection topologies, multidimensional meshes and tori are particularly attractive since they are scalable. Some of the major supercomputer manufacturers have launched multicomputers with a mesh or a torus interconnection network (i.e., the CrayT3E system, Intel Paragon, and Convex SPP). Designing parallel algorithms for multicomputers is not an easy task. Processes are assigned to the multicomputer nodes and message-scheduling algorithms are defined in order to maximize the processor utilization and minimize communication costs. In this work, we propose a methodology named CALMANT (Cc-cube ALgorithms on Meshes ANd Tori) for mapping a kind of algorithms that we call CC-cube algorithms onto multicomputers with hypercube, mesh, or torus interconnection topology. CALMANT is suitable when the initial problem, after the partition and combination phases, can be expressed as a set of processes that communicate through a hypercube topology (a CC-cube algorithm). Although CALMANT is proposed for multicomputers with different interconnection network topologies, this paper only focuses on the particular case of meshes. The initial ideas from which we have developed the CALMANT methodology come from the study of graph embeddings of a hypercube onto a mesh or a torus [5]. This work builds upon a preliminary version of CALMANT for mapping CC-cube algorithms on hypercubes with synchronous communication [2] and asynchronous communication [3]. We are currently extending the proposed methodology to torus interconnected multicomputers. CALMANT is based on three different techniques: a) the standard embedding [10] to assign the processes of the algorithm to the nodes of the mesh multicomputer; b) the communication pipelining technique to increase the level of communication parallelism inherent in the CC-cube algorithms; and c) optimal message-scheduling algorithms proposed in this work in order to avoid conflicts and minimizing in this way the communication time. There are many important algorithms that fit into the CC-cube type [5]. Fast Fourier Transform, Complete Exchange communication problem (also known as All- to-All personalized communication), and Jacobi methods for single value decomposition and eigenvalue computation are some examples that can be solved by means of a CC-cube algorithm. The organization of the rest of the paper is as follows: In Section 2, we present the groundwork on which this work is based. Section 3 describes CALMANT for the case of lines (one-dimensional meshes). The extension to meshes of any dimensionality is described in Section 4. In Section 5, CALMANT is applied to the Complete Exchange communication problem and the results are compared with other proposals particularly designed to solve this problem on meshes. Finally, Section 6 summarizes the main conclusions of this work. 2GROUNDWORK This section describes the most important details of the target architectures and the target algorithms we have considered, the standard embedding of hypercubes onto IEEE TRANSACTIONS ON PARALLEL AND DISTRIBUTED SYSTEMS, VOL. 13, NO. 12, DECEMBER 2002 1247 .The authors are with the Computer Architecture Department, Universitat Politcnica de Catalunya (UPC), Barcelona, Spain. E-mail: {ldiaz, miguel, antonio}@ac.upc.es. Manuscript received 21 Dec. 1999; revised 14 May 2001; accepted 26 Apr. 2002. For information on obtaining reprints of this article, please send e-mail to: [email protected], and reference IEEECS Log Number 111140. 1045-9219/02/$17.00 ß2002 IEEE
meshes and the communication pipelining technique. Finally, some notation and definitions are introduced. 2.1 Target Architecture We assume a distributed memory multicomputer consisting of 2dnodes connected by point-to-point links in a (2d=c ::: 2d=c)c-dimensional mesh topology (c¼2;3). We assume d=c 2; otherwise, the architecture is equivalent to a hypercube, which was already studied in [2] and [3]. We assume a synchronous communication protocol, that is, processors are blocked after initiating a communication operation through one of their links, until the communication operation finishes. Modern parallel computers mostly use a wormhole switching model. As long as there is no congestion, the time for transferring a message of size Lbetween two nodes is almost independent of the distance and can be approximated by: þL; ð1Þ where is the communication start-up and is the communication time per size unit. It is also assumed that nodes only have one port available (one-port model), that is to say, nodes can only send and/or receive one message at the same time. Nevertheless, other messages can pass through the node if it is located in the path between the source and the destination nodes of other communication operations. Finally, we also assume that messages traverse the interconnection network following a dimension-ordering routing policy. In other words, messages use the dimensions of the mesh always following an established order. However, any other routing policy in which messages use the shortest path between the source and destination nodes would not affect the CALMANT methodology, since each message travels along one dimension and, therefore, the shortest path is unique. 2.2 Target Algorithm The starting point for CALMANT is a CC-cube algorithm. A CC-cube algorithm consist of 2dprocesses such that every process communicates with exactly other dprocesses. These dprocesses are called its neighbors, and the communication topology of the algorithm is a hypercube. This means that the 2dprocesses can be labeled from 0 to 2dÿ1in such a way that processes nand n0are neighbors (i.e., they communicate) if the binary codes for nand n0differ in a single bit. If this bit is the ith bit, then n0is the neighbor of n in dimension iand it will be denoted by n0¼NiðnÞ.Itis obvious that if n0¼NiðnÞ, then n¼Niðn0Þ. In addition, the code executed by every process of a CC-cube algorithm is the same and it has the following structure: do i=0, K-1 compute xi½1:Nand some local data exchange xiwith neighbor in dimension di enddo where diis one of the dimensions of the CC-cube (di2½0;dÿ1). In the computation stage, Ndata items are computed. These data are represented by vector xi½1:N. After a computation stage there is a communication stage in which the computed data xiare exchanged with one of the neighbors in the CC-cube. In this paper, we consider only the case of those CC-cube algorithms in which K¼dand di6¼ djfor all i6¼ j. The Fast Fourier Transform and the Complete Exchange communication problem are some examples that can be solved by means of a CC-cube with these characteristics. We will assume that di¼iwithout loss of generality. To avoid misunderstandings, from now on CC-cube dimensions will be referred to as just dimensions and mesh dimensions will be referred to as axes. 2.3 Standard Embedding Different approaches for embedding hypercube algorithms onto meshes and tori have been proposed [4], [5], [8], [10]. The standard embedding [10] has been shown to be optimal for meshes [5] in the sense of reducing the average dilation of the hypercube dimensions. Let hndÿ1;n dÿ2; :::; n0ibe the binary representation of process nof a CC-cube. Let hmcÿ1;m cÿ2; :::; m0ibe the label of node mof a mesh, where the different elements of this label are the coordinates of the node inside the mesh. And let hmj;d=cÿ1;m j;d=cÿ2; :::; mj;0ibe the binary representation of mj(j2½0;cÿ1). Then, the standard embedding of a d-dimensional hypercube onto a mesh, which is denoted by fstd, is defined as follows: m¼fstdðnÞ; where: mj;l ¼njþlc;8j2½0;cÿ1;8l2½0; d=c ÿ1: The above definition is slightly different to that given by Matic[10]inwhichmj;l ¼nðd=cÞjþl. It includes a bit permutation in the binary representation of the processes (n). Nevertheless, the minimum average dilation property of the embedding is not affected [5]. Fig. 1 illustrates how the processes of a CC-cube are assigned to the nodes of a mesh when the standard embedding is applied. The shortest paths between any process nand two of its neighbors along two consecutive dimensions (NiðnÞand Niþ1ðnÞ) follow different axes of the mesh. As it will be shown later, this property, facilitates an efficient scheduling of messages. Let us define the distance between any two processes n and n0as the number of links in the shortest path between the nodes fstdðnÞand fstdðn0Þof the mesh. Let ibe any of the CC-cube dimensions. The distance between processes nand NiðnÞdepends on ibut not on n. This property is called constant dilation property. Moreover, the shortest path between processes nand NiðnÞuses a single axis of the mesh: the axis imod c. We will say that the dimension iof the CC-cube is mapped onto the axis imod cof the mesh. Let Dið0i<dÞbe the dilation of the dimension iof a CC-cube when it is embedded on a mesh through the standard embedding. We can express the value of Dias: 1248 IEEE TRANSACTIONS ON PARALLEL AND DISTRIBUTED SYSTEMS, VOL. 13, NO. 12, DECEMBER 2002
Di¼2i=c:ð2Þ The following list summarizes the main properties of the standard embedding: .Constant dilation. .Minimal average dilation. .The shortest path between any two CC-cube neighbor processes along a given dimension uses a single mesh axis, and this axis only depends on the CC-cube dimension. When we execute the iteration iof the CC-cube on the mesh, due to the standard embedding properties, all the processes send a message through the same mesh axis to their corresponding neighbors that are located at a distance Di. Since only one message can traverse a link at the same time in each direction, the cost of the communication stage in each iteration of the CC-cube is proportional to Diand can be expressed as: ti¼DiðþNÞ; where Nis the size of vector xi. The computation in one iteration of a CC-cube algorithm requires the data received in the previous one. Since only one CC-cube dimension is used in every iteration, the total time that the algorithm spends in communication is: t¼X dÿ1 i¼0 ti¼X dÿ1 i¼0 2i=cðþNÞ¼cð2d=c ÿ1ÞðþNÞ: The use of only one CC-cube dimension in every iteration prevents an effective exploitation of the communication bandwidth of the mesh. To reduce the communication costs, we will reorganize the CC-cube algorithm so that several messages can be sent in parallel through several or even all the dimensions in every iteration. To introduce this parallelism in the communications, we will apply the communication pipelining technique to the original CC- cube algorithm. 2.4 Communication Pipelining The communication pipelining technique is inspired in the software pipelining approach used to generate code for VLIW processors [9]. It is based on the fact that the whole vector xiÿ1from neighbor in dimension iÿ1may not be needed to compute xi½j. Communication pipelining can be applied to a CC-cube in those cases in which the computation of a given element xi½jcan be expressed as: xi½j¼fðxiÿ1½1:j;x iÿ2½1:jþ1;...; x1½1:jþiÿ2;local dataÞ: In other words, xi½jmust be a function of the jfirst elements received through dimension iÿ1, and the jþ1first elements received through dimension iÿ2, and so on. Communication pipelining is based on splitting the vector xiinto Qpackets of size N=Q 1 and rewriting the algorithm as follows: In the first iteration, every node computes the first packet of x0and sends the result to its neighbor in dimension 0. In the second iteration, every node computes the second packet of x0and the first packet of x1. At the end of this second iteration, each node exchanges two messages, one of them with its neighbor in dimension 0, containing the second packet of x0, and the other one with its neighbor in dimension 1, containing the first packet of x1. Both packets canbesentinparallel. Proceedingin thisway,at theend ofthe third iteration, every node can send three messages in parallel. Following this approach, a parallel algorithm that makes use of all the dimensions of the CC-cube at the same time can be designed. The resulting algorithm is referred to as pipelined CC-cube. Fig. 2 shows how a 3-dimensional CC-cube is transformed when the communication pipelining technique is applied. Data that is computed by the processes in every iteration of the algorithms are represented by boxes. Different gray levels identify data belonging to different iterations of the original CC-cube. Moreover, the links through which communication takes place in every iteration are highlighted. The value of Qis referred to as the pipelining degree.A pipelined CC-cube algorithm consists of three different phases: prologue,kernel,andepilogue.IfQ<d,the prologue and the epilogue are composed of Qÿ1 iterations each and the kernel consists of dÿQþ1 iterations. The communication in the kth iteration of the prologue involves the dimensions 0 to kÿ1of the CC- cube. The kth iteration of the kernel uses the dimensions kÿ1to Qþkÿ2and, finally, the kth iteration of the epilogue involves the dimensions dÿQþkto dÿ1.We refer to this situation as shallow pipelining because all d dimensions of the CC-cube are never used simultaneously. If Qd, the prologue and the epilogue are composed of dÿ1iterations each and the kernel consists of Qÿdþ1iterations. In this case, the kth iteration of the prologue uses the dimensions 0 to kÿ1. All iterations of D IIAZ DE CERIO ET AL.: HYPERCUBE ALGORITHMS ON MESH CONNECTED MULTICOMPUTERS 1249 Fig. 1. The standard embedding: a 4-dimensional CC-cube onto a (4 x 4) mesh. 1. For the sake of clarity, we assume that Nis a multiple of Q. It can be easily shown that the analytical models developed in this paper introduce a negligible error when they are used for arbitrary values of Nand Q.
the kernel involve the dimensions 0 to dÿ1and, finally, the kth iteration of the epilogue communicates through the dimensions kto dÿ1. We refer to this situation as deep pipelining because every iteration of the kernel uses all the dimensions of the CC-cube simultaneously. Fig. 2b is a case of deep pipelining since d¼3and Q¼4. The communication pipelining technique introduces a certain level of communication parallelism in the pipelined CC-cube that depends on the value of Q. An increment in Q increases the parallelism in the communication but results in a greater number of messages to be transmitted. Thus, to minimize the total communication cost, the optimal Q corresponds to the best trade-off between the level of parallelism and the cost due to message startups. The communication pipelining technique was previously proposed for solving the FFT on the Connection Machine [6]. Since, in that case, the startup time can be neglected, the authors only considered the case of maximum pipelining Q¼N. Afterwards, we generalized this technique introducing the concept of pipelining degree for mapping CC-cube algorithms on hypercubes with synchronous [2] and asynchronous [3] communications and proposed some approaches to evaluating the optimal pipelining degree. 2.5 Notations and Definitions Next, sections study and evaluate the execution of a pipelined CC-cube algorithm when it is mapped onto a c-dimensional mesh by means of the standard embedding. Before that, we introduce some notations and definitions. In every iteration of the pipelined CC-cube several messages, all of them of equal size, are exchanged through a set of consecutive dimensions. In general, the task of exchanging Mmessages through the dimensions ito iþMÿ1 (one through each dimension) when the pipelined CC-cube is mapped onto a c-dimensional mesh, is denoted by hi; Mic.An iteration of the kernel phase of the example represented in Fig. 2 should be denoted by h0;3icand the first iteration of the epilogue phase by h1;2ic. The load of a link due to a task hi; Micis defined as the number of messages that traverse the link in each direction when the task is performed using a shortest path routing policy. Due to the standard embedding properties, there is just one way to perform this task, which causes any link to be traversed by the same number of messages in each direction. The maximum load of a mesh when performing the task hi; Mic is defined as the load of the link with maximum load and it is denoted by maxhi; Mic. Contention in a communication task is difficult to quantify. In order to simplify the evaluation of the communication time that is involved in a task hi; Mic, we assume a synchronous lockstep communication model. That is to say, time is viewed as a succession of indivisible parts called steps, such that in each step, several communication operations involving messages of equal size, can be performed in parallel. In this way, a communication step is defined as the time required to complete the sending of a message of size Lfrom one node to another of the mesh, when there are no message conflicts. This time is given by the expression (1) in Section 2.1. Several messages can simultaneously travel through the mesh during a communication step, provided that there are no conflicts in the use of the resources (i.e., ports and links). This assumption is not made in order to consider a particular characteristic of the architecture but in order to simplify the description and the evaluation of the algorithms. In fact, it is a conservative assumption because synchronization between steps will not be required to perform the communication tasks. As it is shown later, barriers are required only after the algorithm iterations and the communication overhead of a barrier will be denoted by b. A lower bound on the number of communication steps required to perform the task hi; Micis denoted by LBhi; Mic and the number of communication steps used by a given scheduling algorithm to perform this task is denoted by Phi; Mic.IfLBhi; Mic¼Phi; Micfor a given algorithm, we can conclude that this algorithm is optimal from the point of view of communication cost. The communication cost of a task is represented by Thi; Mic. Due to the fact that all the messages involved in our scheduling algorithms have the same size, the following relation holds: Thi; Mic¼Phi; MicðþLÞ: In the next two sections of this paper, we propose an efficient solution to perform the tasks hi; Mic, first for lines and then for c-dimensional meshes. 3PIPELINED CC-CUBE ON A LINE Since every iteration of the pipelined CC-cube performs a communication through a set of consecutive dimensions, the communication stage of each iteration can be represented by means of task hi; Mi1. For instance, the communication stage of any iteration of the kernel phase when deep pipelining is applied can be represented by h0;di1.In this case, all the dimensions of the CC-cube (from 0 to dÿ1) are involved in the communication. 1250 IEEE TRANSACTIONS ON PARALLEL AND DISTRIBUTED SYSTEMS, VOL. 13, NO. 12, DECEMBER 2002 Fig. 2. The communication pipelining technique: (a) a 3-dimensional CC-cube without communication pipelining and (b) a 3-dimensional CC-cube with communication pipelining.
3.1 Maximum Load and Lower Bound In this section, we provide an expression for maxhi; Mi1 (the maximum load of a line due to a task hi; Mi1) and use this expression to establish a lower bound on the number of communication steps of task hi; Mi1, which is denoted by LBhi; Mi1. Theorem 1. The maximum load of a line when a task hi; Mi1is performed can be computed as follows: maxhi; Mi1¼ð2iþMþ1ÿ2iþ1Þ=3;if Mis even; ð2iþMþ1ÿ2iÞ=3;if Mis odd : Proof. See Appendix. tu Theorem 2. A lower bound on the number of communication steps required to perform the task hi; Mi1on a line (LBhi; Mi1) can be expressed as: Phi; Mi1maxhi; Mi1¼LBhi; Mi1: Proof. Since only one message can traverse a link in a given direction at the same time, it is obvious that Phi; Mi1must be greater than or equal to maxhi; Mi1. On the other hand, nodes cannot send (receive) multiple messages at the same time in a one-port line and therefore, Phi; Mi1must also be greater than or equal to M. Thus, we have that: Phi; Mi1maxfmaxhi; Mi1;Mg; but, according to the expressing given by Theorem 1, it can be proven that: maxhi; Mi1maxh0;Mi1M: ut 3.2 An Optimal Message-Scheduling Algorithm In this section, we propose a message-scheduling algorithm to perform the task hi; Mi1that achieves the lower bound on the number of communication steps. The idea is to decompose the task hi; Mi1into a set of smaller subtasks in such a way that the sum of the lower bounds of every subtask is LBhi; Mi1. The task hi; Mi1can be decomposed into the following set of subtasks: hi; Mi1SM=2ÿ1 k¼0hiþ2k; 2i1;if Mis even; SðMÿ1Þ=2 k¼1hiþ2kÿ1;2i1[hi; 1i1;if Mis odd: ( For instance, the task h0;6i1will be decomposed into the subtasks h0;2i1,h2;2i1, and h4;2i1. Lemma 1. A lower bound on the number of communication steps to perform the task hi; Mi1on a line is given by the following expression: LBhi; Mi1 ¼PM=2ÿ1 k¼0LBhiþ2k; 2i1;if Mis even; LBhi; 1i1þPðMÿ1Þ=2 k¼1LBhiþ2kÿ1;2i1;if Mis odd: ( Proof. It is a direct consequence of Theorem 1 and Theorem 2. tu 3.2.1 An Optimal Message-Scheduling Algorithm for the Subtask hi; 2i1 The nodes of the line are divided into 2igroups. The group to which a node mbelongs is denoted by gðmÞand is given by the following expression: gðmÞ¼mmod 2i: Taking into account that nodes can only send and receive one message at a time, a node requires at least two communication steps to exchange messages with its neighbors in dimensions iand iþ1. In the proposed message-scheduling algorithm, a node minitiates the communication in step sðmÞ¼2gðmÞand completes the communication in the next step (that is, it communicates in steps sðmÞand sðmÞþ1). Fig. 3 describes a messagescheduling algorithm for exchanging all the messages involved in a group in only two steps. The communication operation to be performed by a node min each step is determined according to the value of bits iand iþ1in the binary representation of m. These bits are denoted by mi and miþ1, respectively. As an example, nodes such that mi¼miþ1send a message through dimension iþ1and receive a message through dimension iduring the step sðmÞ. Meanwhile, in this communication step, nodes such that mi6¼ miþ1send a message through dimension iand receive a message through dimension iþ1. The value of sðmÞdepends on the group to which node mbelongs, and according to the definition of sðmÞ, a different group exchanges the messages every two communication steps. Fig. 4 shows the case of the subtask h1;2i1on a line of 16 nodes. Since in this case we have that i¼1, the nodes are organized into two groups, denoted by white and gray circles. Nodes belonging to the white group communicate during steps 0 and 1, while nodes belonging to the gray group communicate during steps 2 and 3. D IIAZ DE CERIO ET AL.: HYPERCUBE ALGORITHMS ON MESH CONNECTED MULTICOMPUTERS 1251 Fig. 3. Message-scheduling algorithm for the subtask hi; 2i1. Fig. 4. Communication subtask h1;2i1on a line of 16 nodes.
The communication through dimension 2 is represented by solid arrows and the communication through dimension 1 is represented by dashed arrows. The communication operations in each group are performed following the algorithm described in Fig. 3. Notice that the proposed message-scheduling algorithm is conflict free because, on one hand, all the messages that travel in the same direction in every communication step do not share any link and, on the other hand, each node sends and receives at most one message at a time, as required in a one port line. This also applies for the general case since the value of ionly affects to the communication distance between nodes but not to the communication pattern defined by the algorithm. Since each group spends two communication steps in completing the communication, the total number of communication steps required to perform the subtask hi; 2i1will be twice the number of groups, that is to say: Phi; 2i1¼2iþ1: Note that Phi; 2i1¼LBhi; 2i1, and therefore, the proposed approach is optimal. 3.2.2 An Optimal Message-Scheduling Algorithm for the Subtask hi; 1i1 To describe how the subtask hi; 1i1is performed, let us regard the nodes of the line as divided into 2iþ1groups. The group to which node mbelongs is denoted by g0ðmÞand is given by the following expression: g0ðmÞ¼mmod 2iþ1: Nodes require one communication step to send a message and receive another through dimension i. The communication step in which the node msends and receives the corresponding messages is denoted by s0ðmÞ. We propose that s0ðmÞ¼g0ðmÞ, which means that all nodes belonging to the same group send and receive messages during the same communication step. Fig. 5 shows an example for subtask h2;1i1on a line of 16 nodes. In this case, we have four groups of nodes, represented by different gray levels. Again, it is easy to infer from the figure that the proposed message-scheduling algorithm is conflict free for the general case. Since each group spends one communication step in completing the communication, the total number of communication steps is equivalent to the number of groups: Phi; 1i1¼2i: Notice that Phi; 1i1¼LBhi; 1i1, and therefore, the proposed approach is optimal. 3.3 Communication Cost The execution time of the task hi; Mi1is given by the number of communication steps multiplied by the cost of every communication step: Thi; Mi1¼Phi; Mi1ðþLÞ: The expression for Phi; Mi1can be evaluated as the sum of the communication steps of every subtask in which task hi; Mi1is decomposed: Phi; Mi1 ¼PM=2ÿ1 k¼0Phiþ2k; 2i1;if Mis even; Phi; 1i1þPðMÿ1Þ=2 k¼1Phiþ2kÿ1;2i1;if Mis odd: ( From the message-scheduling algorithms described in the previous section, we have that Phi; 2i1¼LBhi; 2i1and Phi; 1i1¼LBhi; 1i1. According to Lemma 1 and Theorem 2, the previous expression for Phi; Mi1can be rewritten as Phi; Mi1¼LBhi; Mi1¼maxhi; Mi1and, therefore, the execution time of the task hi; Mi1can be expressed as: Thi; Mi1¼maxhi; Mi1ðþLÞ: The total communication cost of the algorithm can be evaluated as the sum of the communication cost of every iteration plus the barrier overhead after each iteration. Since thesizeofeverymessageisL¼N=Q, for shallow pipelining we have that: Tshallowðd; QÞ¼X Qÿ2 k¼0 Th0;kþ1i1þX dÿQ k¼0 Thk; Qi1 þX Qÿ2 k¼0 ThkþdÿQþ1;Qÿkÿ1i1þðdþQÿ1Þb; where bis the cost of a barrier. Likewise, for deep pipelining, we obtain: Tdeepðd; QÞ¼X dÿ2 k¼0 Th0;kþ1i1þðQÿdþ1ÞTh0;di1 þX dÿ2 k¼0 Thkþ1;dÿkÿ1i1þðdþQÿ1Þb: These expressions can be used to derive the optimal degree of pipelining (value of Q). The closed formulas for Tshallow and Tdeep can be found in the Appendix. 4PIPELINED CC-CUBE ON A c-DIMENSIONAL MESH This section extends the approach proposed in the previous section to the execution of a pipelined CC-cube on a c-dimensional mesh. The communication stage of each iteration of a pipelined CC-cube on a c-dimensional mesh can be represented by the communication task hi; Mic. 1252 IEEE TRANSACTIONS ON PARALLEL AND DISTRIBUTED SYSTEMS, VOL. 13, NO. 12, DECEMBER 2002 Fig. 5. Communication subtask h2;1i1on a line of 16 nodes.
4.1 Maximum Load and Lower Bound Theorem 3. The maximum load due to the communication task hi; Micon a (2d=c ::: 2d=c)c-dimensional mesh ðmaxhi; micÞis equivalent to: maxhbðiþðMÿ1Þmod cÞ=cc;dM=cei1: Proof. See Appendix. tu Theorem 4. A lower bound on the number of communication steps required to perform the task hi; Micon a mesh can be expressed as: Phi; Micmaxfmaxhi; Mic;Mg¼LBhi; Mic: Proof. Since only one message can traverse a link in a given direction at the same time, it is obvious that Phi; Mic must be greater than or equal to maxhi; Mic. On the other hand, nodes cannot send (receive) multiple messages at the same time and, therefore, Phi; Micmust also be greater than or equal to M.tu According to Theorem 3 and Theorem 4, we have that: LBhi; Mic¼maxfmaxhbðiþðMÿ1Þmod cÞ=cc;dM=cei1;Mg: 4.2 A Nearly Optimal Message-Scheduling Algorithm The task hi; Miccan be decomposed into a set of smaller subtasks in the following way: hi; Mic[ bM=2cc k¼1 hiþMÿ2kc; 2cic[hi; M mod 2cic: For instance, the task h0;10i2can be decomposed into the subtasks h0;2i2,h2;4i2, and h6;4i2. Lemma 2. The difference between the sum of the lower bounds of the subtasks in the proposed decomposition and LBhi; Micis under the limits given by the following expression: X bM=2cc k¼1 LBhiþMÿ2kc; 2cicþLBhi; M mod 2cicÿ LBhi; Mic 2;if c¼2 and M7 and i1; 4;if c¼3 and M9 and i4; 0;otherwise: 8 > < > : Proof. It is an immediate consequence of the expressions given by Theorem 4, Theorem 3, and Theorem 1. tu According to the above lemma, if it exists a solution in which Phi; xic¼LBhi; xicfor any x2c, a nearly optimal algorithm to perform the task hi; Miccan be obtained by sequentially performing every subtask according that solution. 4.2.1 An Optimal Message-Scheduling Algorithm for the Subtask hi; 2cic Note that the 2cdimensions that are involved in the subtask hi; 2cicare mapped onto the different axes cyclically. In particular, the dimensions kand kþc, such that k2½i; i þcÿ1, are mapped onto the axis kmod c. We divide the nodes of the mesh into different groups depending on their position in each of the axes. A node belongs to cdifferent groups. Each group corresponds to one of the axes. If hmcÿ1;m cÿ2; :::; m0iis the label of node m, the cgroups to which it belongs are given by the following expression: gkmod cðmÞ¼mkmod cmod 2bk=cc;8k2½i; i þcÿ1: As an example, Fig. 6 shows the case of the subtask h3;4i2for a (16 16) mesh. In this example, since i¼3and c¼2, we have that k2½3;4. The node hm1;m 0ibelongs to the groups g1ðmÞ¼m1mod 2 and g0ðmÞ¼m0mod 4 (i.e., node m¼h2;3ibelongstogroupsg1ðmÞ¼0and g0ðmÞ¼3). In the figure, the gray level in the upper part of the node representation corresponds to g0ðmÞ(group corresponding to the horizontal axis) and the lower part corresponds to g1ðmÞ(group corresponding to the vertical axis). Note that, for the proposed group division, nodes must communicate only with nodes that belongs exactly to the same groups in every axis of the mesh (nodes that are identically represented in Fig. 6). We consider now the problem of scheduling the messages to be exchanged in every iteration in such a way that conflicts in the mesh are avoided and the communication time is minimized. When nodes communicate, two restrictions should be taken into account in order to avoid conflicts. First, two nodes belonging to different groups of the same axis should perform the communication through this axis in different communication steps in order to avoid link contention and second, any node should perform the communication D IIAZ DE CERIO ET AL.: HYPERCUBE ALGORITHMS ON MESH CONNECTED MULTICOMPUTERS 1253 Fig. 6. Group partition for the subtask h3;4i2on a (16 16) mesh.
through different axes of the mesh in different communication steps, since we are assuming a one-port model. Dimensions kand kþcare the only dimensions of those involved in the subtask that are mapped onto axis kmod c. Since an axis of a mesh can be considered as a line of 2d=c nodes, the communication along the axis can be performed as it was described for lines (in two communication steps). We propose that node msends and receives the corresponding messages through the dimensions kand kþcduring the steps skmodcðmÞand skmodcðmÞþ1, where: skmod cðmÞ¼2X cÿ1 j¼0 gjðmÞþk ! mod LBhi; 2cic 2 ! ; 8k2½i; i þcÿ1 and where the subindex kmod cdenotes the axis through which the messages are sent. This expression meets the restrictions mentioned before and schedules the activity of the groups using a minimum number of communication steps as it will be shown later. Any other scheduling that satisfies the required restrictions with a minimum number of communication steps would also be an optimal scheduling policy. Fig. 7 shows the result of applying the proposed scheduling to the example of Fig. 6. The table shows the activity of every node as a function of the group which it belongs to in each axis. The upper parts and lower parts of the boxes represent, respectively, the communication step in which communication through axis 0 and axis 1 is initiated (s0ðmÞand s1ðmÞ). As an example, nodes belonging to group 2 in axis 0 and group 0 in axis 1 (shadowed box) communicates along the axis 1 during the communication steps 2 and 3 and communicates along the axis 0 during the communication steps 4 and 5. Property 1. The proposed scheduling algorithm is conflict free and its number of communication steps is Phi; 2cic¼LBhi; 2cic, that is, it is optimal for the subtask hi; 2cic. Proof. Let us first prove that the scheduling algorithm is conflict free. Let mand m0be two different nodes of the mesh. Let jbe an axis of the mesh, such that mj6¼ m0 j. Let us assume that mk6¼ m0 kfor some k6¼ j, that is to say, nodes mand m0do not belong to the same line in the mesh. Due to the fact that the communication between two neighbor processes along a given dimension is performed using a single mesh axis, conflicts between messages from/to node mand messages from/to node m0are not possible. Now, let us assume that mk¼m0 kfor all k6¼ j. In this case, gkðmÞ¼gkðm0Þ.IfgjðmÞ6¼gjðm0Þ, then sjðmÞ6¼sjðm0Þ and, therefore, conflicts between messages from/to node mand messages from/to node m0are not possible. If gjðmÞ¼gjðm0Þ, both nodes belongs to the same group of communication and conflicts are avoided using the scheduling algorithm described for lines. Next, we prove that Phi; 2cic¼LBhi; 2cic.Ifxand y are integers and yis an even number we have that: 02ðxmod ðy=2ÞÞ yÿ2: Therefore, according to the expression for sjðmÞ,we obtain: 0sjðmÞLBhi; 2cicÿ2: If each group performs the communication in two communication steps, then the last groups perform the communication during steps LBhi; 2cicÿ2and LBhi; 2cicÿ1. The first communication step is denoted by 0 so the total number of communication steps is LBhi; 2cic.tu 4.2.2 An Optimal Message-Scheduling Algorithm for the Subtask hi; xicwhen 1xc Note that the xdimensions that are involved in the subtask hi; xicare mapped onto the different axes cyclically. In particular, the dimension k(ik<iþx) is mapped onto the axis kmod c. We divide the nodes of the mesh into different groups. In this case, a node belongs to xdifferent groups. Each group corresponds to one of the axes on which a dimension is mapped. If hmcÿ1;m cÿ2; :::; m0iis the label of node m, the x groups to which it belongs are given by the following expression: gkmod cðmÞ¼mkmod cmod 2bk=cc;8k2½i; i þxÿ1: We propose that node msends and receives the corresponding messages through the dimension kduring the step skmod cðmÞ, where: skmod cðmÞ¼ X iþxÿ1 j¼i gjmod cðmÞþk ! mod LBhi; xic; 8k2½i; i þxÿ1: Among the dimensions that are involved in the subtask, only the dimension kis mapped onto the axis (kmod c). Since one axis of the mesh can be considered as a line of 2d=c nodes, the communication can be performed following the approach described for lines. Property 2. The proposed scheduling algorithm is conflict free and its number of communication steps is Phi; xic¼ LBhi; xicso, it is optimal for the subtask hi; xicwhen 1xc. Proof. Similar to Proof for Property 1. tu 1254 IEEE TRANSACTIONS ON PARALLEL AND DISTRIBUTED SYSTEMS, VOL. 13, NO. 12, DECEMBER 2002 Fig. 7. Scheduling for the solution of the subtask h3;4i2on a (16 16) mesh.
4.2.3 A Nearly Optimal Message-Scheduling Algorithm for the Subtask hi; xicwhen c<x<2c We divide the nodes of the mesh into different groups. In this case, a node belongs to cdifferent groups. Each group corresponds to one of the axes. If hmcÿ1;m cÿ2; :::; m0iis the label of node m, the cgroups to which it belongs are given by the following expression: gkmod cðmÞ¼ 0;ifbk=cc<0; mkmod cmod 2bk=cc;ifbk=cc0; 8k2½iþxÿ2c; i þxÿcÿ1: If k2½iþxÿ2c; i ÿ1, then kþcis the only dimension among those involved in the subtask that is mapped onto the axis kmod c. Otherwise, if k2½i; i þxÿcÿ1, then both dimensions kand kþcare mapped onto the axis kmod c. We propose that the node msends and receives the corresponding messages either through dimensions kand kþcor only kþc, during the steps skmodcðmÞand skmodcðmÞþ1using the approach proposed for lines, where: skmod cðmÞ¼2X cÿ1 j¼0 gjðmÞþk ! mod LBhi; xic 2 ! ; 8k2½iþxÿ2c; i þxÿcÿ1: Property 3. The proposed scheduling algorithm is conflict free and the difference between its number of communication steps and LBhi; xicis: Phi; xicÿLBhi; xic¼1;if LBhi; xicis odd; 0;if LBhi; xicis even: Proof. Similar to Proof for Property 1. tu This scheduling algorithm is optimal for the subtask hi; xicwhen c<x<2cand LBhi; xicis even. For c<x<2c, LBhi; xicis odd only if x> maxhi; xicand xis odd. This is due to the fact that the expression x> maxhi; xicalways returns an even value. 4.3 Execution Time The execution time for the task hi; Micis given by the number of communication steps multiplied by the cost of every communication step: Thi; Mic¼Phi; MicðþLÞ ¼ X bM=2cc k¼1 PhiþMÿ2kc; 2cic þPhi; M mod 2cic!ðþLÞ ¼ X bM=2cc k¼1 LBhiþMÿ2kc; 2cic þLBhi; M mod 2cicþr!ðþLÞ; where: r¼1;if Mmod 2c> maxhi; M mod 2cicand Mis even; 0;other case: The total communication cost of the algorithm can be evaluated as the sum of the communication cost of every iteration plus the barrier overhead after each iteration. Since thesizeofeverymessageisL¼N=Q, for shallow pipelining we have that: Tshallowðd; QÞ¼X Qÿ2 k¼0 Th0;kþ1icþX dÿQ k¼0 Thk; Qic þX Qÿ2 k¼0 ThkþdÿQþ1;Qÿkÿ1icþðdþQÿ1Þb; ; where bis the cost of a barrier. Likewise, for deep pipelining we obtain: Tdeepðd; QÞ¼X dÿ2 k¼0 Th0;kþ1icþðQÿdþ1ÞTh0;dic þX dÿ2 k¼0 Thkþ1;dÿkÿ1icþðdþQÿ1Þb: These expressions can be used to derive the optimal degree of pipelining (value of Q). The closed formulas for Tshallow and Tdeep can be found in the Appendix. 5ANEXAMPLE:THE COMPLETE EXCHANGE PROBLEM In this section, we consider the application of CALMANT to the Complete Exchange (or personalized All-to-All) communication problem. This problem is a global collective communication operation in which every process sends a unique block of data to every other process in the system. Since complete exchange arises in many important problems (i.e., FFT, matrix transposition, sorting), its efficient implementation on current parallel machines is an important research issue. In order to apply CALMANT, we have designed a CC-cube algorithm for the Complete Exchange problem that is described in the next section. The resulting algorithm has been compared with a wide range of proposals specially tuned for the solution of the Complete Exchange: Binary [1], Quadrant [1], Modified Quadrant [14], Store-and-Forward (SAF) [14], Direct [11], Cyclic [12], and Hybrid [13] methods. Some of these proposals are addressed to 2-dimensional meshes and some others to c-dimensional meshes. The comparison is based on analytical models for the communication time and the results show that CALMANT outperforms the previous proposals in many cases. 5.1 A CC-cube Algorithm for Complete Exchange In this section, we describe the CC-cube algorithm for complete exchange which is used as a starting point for the proposed methodology. Fig. 8 shows a particular example for d¼3. Every node initially stores 2dblocks of data in a vector of blocks denoted by M. Each block of data will be identified by the pair ðn; jÞ, where nis the source node and jis the D IIAZ DE CERIO ET AL.: HYPERCUBE ALGORITHMS ON MESH CONNECTED MULTICOMPUTERS 1255