A Permutation Network ABRAHAM WAKSMAN Stanford Research nstitute, Menlo Park, California,~BS'rm~CT. n this paper the construction of a switching network capable of n!-permutation of its n is:put terminals to its n output terminals is described. The building blocks for this network are binary cells capable of permuting their two input terminals to their two output terminals. The number of cells used by the network is (n.log2 n - n + 1} = ~,~1 (loge k), t could be argued that for such a network this number of cells is a lower bound, by noting th:tt binary decision trees in the network can resolve individual terminal assignments only and not the partitioning of the permutation set itself which requires only (log2 n!) = (~=~ log2 k) binary dedsions. An algorithm is also given for the sel~ting of the binary cells in the network according to any specified permutation. KEY WORDS AND PHRASES: permutation, signal set, network, network design, flipflop for CATEGORES: 6.1, 6.39, 6.9 n many applications of computer design it is desirable to efficiently construct a network which permutes u set of signals. Let the "elenmntat cell" be the basic building block of such a network, which by itself is a permutation network on two inputs and presumably can be constructed using a single flipflop (see Figure 1). Clearly, the lower bound on the number of elementary cells required for a permutation network on N signals is log,2 (N!). We describe a construction which utilizes F(N) cells, where N is a power of two, such that N~ \log, (N:)/ Definition 1. Definition 2. u~, u~,..., uu are the N inlets to the permutation networks. v~, v2,.. -, vu art the N outlets from the permutation network. Definition 3. {~r(u~) --, v~ : i, j = 1, --., N} is a permutation assigning u~ to some v~ for all i and j. Definition 4. Xi is a variable ranging over the pair (u2i, u2i-1) for i = 1,..., (,~/2). Definition 5. Yj is a variable ranging over the pair (v2j, v~j_:) forj = 1,..., (~'/2). "'~EO~EM 1. There exists a permutation {Tr(Xi) --~ Yj : i, j = 1, "", (N/2)} Under the permutation [Tr(ul) -~ vi : i,j = 1,, N}. Paoo~. LetKi = ~'(X0-+ Yi,under {rr(ui) ~v~:i,j = 1, -.., N}.That is: K~ is a mapping of some u, u C X~, onto some v, v C Yi. For each K~ there This research was supported by the Office of Naval Research under Contract Nonr-4833(00). J~amal of the Association for Computing Machinery, Vol. 15, No. 1, January 1968, pp. 159-163.
160 ABRAtAM WAKS~i~,~ u 2... ~ v 2 u 2 L,L-------V 2 F[m. 1. a, resetstate;b, setstste b FG. 2 art at most two such mappings where the two elements of Xi do not map onto t~ ::~ elements of a single Yj. Thus the set, {Ki} contains at most two elements. N~)'~:,~,. under the permutation{at(u,) -~ v i : i,j : 1,..., N}, no two elements of {u,: i... 1, - -, N} are mapped onto a single element of {vj : j = 1, -, N} so that ] U K,... N/2, 1 < i < N/2. But 1 U X~[ = N/2, 1 < i < N/2, so that by P. Hall's theoretic, [1] on distinct representatives of sets (set Appendix), each X~ has a distinct reprv sentative ia U K~, 1 < i < N/2. Consequently there is a set {Tr(X~) + Y~ : i, j : i~...., N/2)} which is one-to-one; hence a permutation. Q.E.D. COROLLARY 1. {Tr(Xi) -* Yj} is a subassignment of the assignmcnt under ~ ~L permulali~m {~r(ui) --~ vj} that involves exactly one u ~ Xi and one v C Y ~, for ~>:';" i and j. CO~mLLARY 2. VK, an element of the,set { vi : i = l,., N}, can be selected (~.~'5~ trarily as a fixed representative of its corresponding Y j, where v~ ~ Y j for {rr(x~)... Yi} under all the permulations of {rr(ui) --~ v~ : i,j = 1,..., N}. PROOF. Since [ U K,] = N/2, 1 < i< Y/2, there arc always two sets of represent, atives which exhaust {ul} and {vi}. Thus, h.~.,~' any given permutation, we select the set that includes v~-. Networt~ Ctmstruction n Figure 2, 1,..., ~v/2 and 0t, -.., O~e/~_l represent elementary cells, and F~,~ ~ P~ represent permutation networks oil N/2 inputs each. By Theorem 1 and Co r~:~ lary 1, the subassignment {rr(x,) ~ Yj} ca~t be made through Pa so that each f and Oi has a single link to P~.~ and a single link to P, for all i and j. By Corollary 2 we can fix one Y variable, i.e., eliminate one cell, and we cho ~.>~ to eliminate the cell associated with vt and v~. Thus Figure 2 is a permutation ~e~ work decomposed into N - 1 elementary cells and two permutation networks ({~ Journal of the Association for Computing Machinery, Vol. 15, No. 1, January 1968
Permutation Network 161 N/2 inputs each. Clearly the process of decomposition can be continued until the complete network is decomposed into linked elementary cells. For N = 2 r there are r such decompositions, which result in the following number of elementary cells: F(N) = (2 ~ - 1) + 2(2 ~-~ - 1) -t- 22(2 ~-2 -- 1) +... -t- 2~'-~(2-1) = r2 ~ -- (1 + 2' -- 2 2-1- 2 3 -k- "'" -t- 2 ~-~) = r2 ~- (2 ~- 1) = r2 "- 2 ~+ 1, F(N) = Nlog2N- N+ 1. A constructive proof ~ showing that the network of Figm'e 2 is indeed a permutation network is as follows. Consider a network as in Figure 2 where the links between P~, P8 and the inputoutput cells are omitted. Now let it be desired to realize a given arbitrary permutation by establishing the links one by one as dictated by the permutation assignment. Start with Vl and establish a link through Px to some u~ through its corresponding, Let state b of Figure 1 be the set state. Set if u is even. Proceed next with the second u associated with this and establish a link through P~ to its corresponding v through the 0 associated with it. Set this 0 if v is even. Repeat the process until all input-output pairs have been matched and the appropriate input and output cells have been set. Note that in case a specific permutation involves more than a single cycle, a link will be established to v2 via PB before all assignments are made hi this case any inlet or outlet terminal not yet linked can be used as a starting point. : Now, since by construction P~ and P, are each associated with exactly N/2 inputs and N/2 outputs, and since by assumption Pa and PB are permutation networks, the assignment {u~ --~ vi : i, j = 1,, N} is complete and the link pattern is as in Figure 2. Q.E.D. An algorithm can now be established for setting the decomposed cells of a network as well as the permutation required of PA and P. at any decomposition stage. Algorithm 1. Express the given permutation to be realized by the network in an N X N permutation matrix. 2. Rewrite the N X N permutation matrix a.s an (N/2) X (N/2) partition matrix by merging coordinates corresponding to each common input or output cell. 3. Decompose the partition matrix into the sum of two (N/2) X (N/2) permutation matrices by letting vl be a coordinate in one (corresponding to P~) and letting v~ be a coordinate in the other (corresponding to PB). 4. dentify the entries in the N X N matrix which correspond to the entries in the matrix of PA. 5. dentify the coordinates in the N X N matrix which correspond to the entries identified in step 4. 6. dentify the cells associated with the coordinates identified in step 5. 7. Set (that is, put in state b, Figure 1) any cell identified in step 6 which is associated with an even coordinate identified in step 5. This proof is due to H. Stone. Journal of the Association for Computing Machinery, Vol. 15, No. 1, January 1968
162 A.BRAHAM WAKSMAN U - Vl u 2 ~ PA ] F -v2 t ~j./]~ncludes CELLS r~.. /,~ --F----~'#k/1 NO, ~,6,7,,o,,3 N.,~--;~ U6 v 6 16 U7 - v7 U8 V 8 4 17 FG. 3 Ui.,. r---~-.. F~----J. v u2 ~ vz u3 ---F-,x-F "1-'Y-'F ""--',~'- ~ ~ 6 10 13 Fro. 4 U U2 ' ~ E ~ X - ~ r. ~ _, m -- V vl 2 ~3 t V3 8 12 14 FG. 5 u,,. vi U2 ~ v2 u 4 v 4 U5 ~ v5 u6 ~ V 6 Example U8 V 8 4 8 i2 14 17 FG. 6 Let N = 8 and the required permutatiol 12845678~, i 2 3,4 5 6 718 i [ P 27e84315). The permutation matrix is i 3 (Z) 5 Q 6 7Q s i The partition matrix is 1,2 Y Y2 Y3 Xi --! x2 x~, 2 X4i # Journal of the Association for Computing Machinery, Vol. 15, No, 1~ January 1968
[~,.:'~:~la~ i~<~,: ivch~,t: 163 the two correspo::di::g pe::muta,tio:: n::strices are Pl P2,;~h{:.rc P: corr{~pol~d~ to tho pormutation ~quired by PA, and P2 corresponds to i.l:e porn::.:tati<>:: ::<tuired of.p~. The e~:t.ries in ~he 8 X 8 matrix corresponding {o P., :re oh'clod. Thus since u=,, v.:, and v: are even, we set the cells 1, 15, attd 16 in Fig:~ro 3. We are loft with the task of decomposing and setting the permutation networks P~ a~:d P~,. The p~:rmutation a:~d p~rtition matrices for P~ are The corr(,sp<)ndi~g permt~tatioa networks P: and P2 of P<, are Pl ;%~e:~ the <.yea eooali::a~es in the 4 X 4 Pa matrix identified with P: are u4 and ~, we s~:.t, cell< 6 ~md 13 in Figure 4. l>~ and P~ also represent the permutation r~,<iuir~d ef eeil:~ 9 a~d 10 ~:spectively in Figure 4, which call for setting these cells. By h:,ihr d~:g a similar pr<)cedure we arrive at Figure 5, which represents the netw~)rk required for ~.}:w r~ alizatiott of P,. Vig~re ~i repr(',~ont~ the c<m~plete network which realizes the required permu;ation. A pp~<:.nd iz }t ~* ~,'s T,~;()~:a:. ]/,el A be any,set, and let At, A~,.., A, be any r subsels of A. nz :~ neeese~ary and a~flici):~nt cvnditic~n that there exists a set of distinct representatives a, ",a, ofa~,..,,a~,i.e.,elementsa~,..., a~ of A such that a~ ~ A ~, i = 1,..., r; ~,, ~ a~ j)~r i ~ j, il i:s "neee~'sary and sufliciez~t that ]br each K in the range 1 <. K < r ~ e unh>n of any K of #w sets A~,..., A~ have at least K elements. }~2;:FER EN Ci:S } H ~:~:~, P ()~: rep~'euen~ives of subsets. J. London Math. Soe. 10 (1965), 26-30. 2, B~:x~:s, V. E. Mathemal@al Theory of C h~:c Press Ne,,v- York, 1935, onnectzng hretworks and Telephone Tra~c. Aea- P2 Jo:u~nal of the Association for Computing Machinery, Vol. 15, No., January 1968