A Permutation Network
ABRAHAM W A K S M A N
Stanford Research Institute, Menlo Park, California
,~BS'rm~CT. In this p a p e r the c o n s t r u c t i o n of a switching network capable of n ! - p e r m u t a t i o n of its n is:put terminals to its n o u t p u t terminals is described. The building blocks for this net- work are binary cells capable of p e r m u t i n g their two i n p u t terminals to their two o u t p u t termi- nals.
The number of cells used by the network is (n.log2 n - n + 1} = ~,~1 (loge k), It 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: p e r m u t a t i o n , signal set, network, network design, flipflop
fOR CATEGORIES: 6.1, 6.39, 6.9
Definition 1. Definition 2. Definition 3. some v~ for all Definition 4. (,~/2).
Definition 5. (~'/2).
"I'~EO~EM 1.
In many a p p l i c a t i o n s of c o m p u t e r design it is d e s i r a b l e to efficiently c o n s t r u c t a network which p e r m u t e s u set of signals. L e t t h e " e l e n m n t a I T cell" be the basic building block of s u c h a n e t w o r k , which b y itself is a p e r m u t a t i o n n e t w o r k on t w o inputs and p r e s u m a b l y can be c o n s t r u c t e d using a single flipflop (see F i g u r e 1). Clearly, the lower b o u n d on t h e n u m b e r of e l e m e n t a r y cells r e q u i r e d for a p e r m u t a - tion network on N signals is log,2 ( N ! ) .
We describe a c o n s t r u c t i o n which utilizes F ( N ) cells, where N is a p o w e r of two, such t h a t
N ~ \ l o g , ( N : ) /
u~, u~, . . . , uu a r e the N inlets to t h e p e r m u t a t i o n n e t w o r k s . v~, v2, .. - , vu a r t t h e N o u t l e t s from t h e p e r m u t a t i o n n e t w o r k . {~r(u~) --, v~ : i, j = 1, - - . , N} is a p e r m u t a t i o n assigning u~ to i a n d j .
X i is a v a r i a b l e r a n g i n g o v e r t h e p a i r (u2i, u2i-1) for i = 1, . . . , Yj is a v a r i a b l e r a n g i n g o v e r t h e p a i r (v2j, v~j_:) f o r j = 1, . . . , There exists a permutation {Tr(Xi) --~ Yj : i, j = 1, " " , ( N / 2 ) } Under the permutation [Tr(ul) - ~ vi : i , j = 1, • • • , N } .
Paoo~. L e t K i = ~ ' ( X 0 - + Y i , u n d e r {rr(ui) ~ v ~ : i , j = 1, - . . , N } . T h a t is: K~ is a m a p p i n g of some u, u C X~, o n t o s o m e v, v C Y i . F o r each K~ t h e r e This research was s u p p o r t e d by the Office of Naval Research under C o n t r a c t Nonr-4833(00).
160 A B R A t I A M WAKS~i~ ,~
u 2 . . . ~ v 2 u 2 L , L - - - V 2 b F[m. 1. a, r e s e t s t a t e ; b , s e t s t s t e
FIG. 2
a r t at most two such mappings where the two elements of X i do not m a p onto t~ ::~ elements of a single Yj. T h u s 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 t h a t ] U K, ... N / 2 , 1 < i < N / 2 . But 1 U X~[ = N / 2 , 1 < i < N / 2 , so t h a t b y 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~ ..
• .. , I N / 2 ) } which is one-to-one; hence a permutation. Q . E . D .
COROLLARY 1. { T r ( X i ) - * Yj} is a subassignment of the assignmcnt under ~ ~L permulali~m {~r(ui) --~ vj} that involves exactly one u ~ X i a n d 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 f o r {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
I n Figure 2, I 1 , . . . , I~v/2 a n d 0 t , - . . , O~e/~_l represent eLementary cells, and F~,~ ~ P~ represent permutation networks oil N / 2 inputs each. B y T h e o r e m 1 and Co r~:~ lary 1, the subassignment {rr(X,) ~ Yj} ca~t be made t h r o u g h P a so t h a t each f and Oi has a single link to P~.~ and a single link to P , for aLL i and j.
B y 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 p e r m u t a t i o n networks ({~
Permutation Network
161N/2
inputs each. Clearly the process of decomposition can be c o n t i n u e d until the complete n e t w o r k is d e c o m p o s e d into linked e l e m e n t a r y cells.For N = 2 r there are r such decompositions, which result in the following n u m b e r of elementary cells:
F(N)
= (2 ~ - 1) + 2(2 ~-~ - 1) -t- 22(2 ~-2 -- 1) + . . . -t- 2~'-~(2 - 1)= r 2 ~ - - ( 1 + 2' -I- 2 2 -1- 2 3 -k- "'" -t- 2 ~-~)
= r2 ~ - (2 ~ - 1) = r2 " - 2 ~ + 1,
F(N) = N l o g 2 N -
N + 1.A constructive proof ~ showing t h a t t h e n e t w o r k of Figm'e 2 is indeed a p e r m u t a - tion network is as follows.
Consider a n e t w o r k as in Figure 2 where the links between P ~ , P 8 a n d the input- output cells are omitted. N o w let it be desired to realize a given a r b i t r a r y p e r m u t a - tion by establishing t h e links one b y one as d i c t a t e d b y the p e r m u t a t i o n assign- ment.
Start with Vl a n d establish a link t h r o u g h P x to some u~ t h r o u g h its correspond- ing I, Let state b of F i g u r e 1 be t h e set state. Set I if u is even. Proceed next with the second u associated with this I a n d establish a link t h r o u g h P~ to its correspond- ing v t h r o u g h t h e 0 associated with it. Set this 0 if v is even. R e p e a t the process until all i n p u t - o u t p u t pairs have been m a t c h e d and the a p p r o p r i a t e input and out- put cells have been set.
Note t h a t in case a specific p e r m u t a t i o n involves m o r e t h a n a single cycle, a link will be established to v2 via PB before all assignments are m a d e h i this case a n y inlet or outlet t e r m i n a l n o t y e t linked can be used as a s t a r t i n g point. :
Now, since b y c o n s t r u c t i o n P~ a n d P , are each associated with exactly
N/2
inputs andN/2
o u t p u t s , and since b y a s s u m p t i o n P a a n d PB are p e r m u t a t i o n net- works, the a s s i g n m e n t {u~ --~ vi : i, j = 1, • • • , N} is complete and t h e link p a t t e r n is as in Figure 2. Q . E . D .An algorithm can n o w be established for setting t h e decomposed cells of a net- work as well as t h e p e r m u t a t i o n required of PA a n d P . at a n y 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. Identify the entries in the N X N matrix which correspond to the entries in the matrix of PA.
5. Identify the coordinates in the N X N matrix which correspond to the entries identified in step 4.
6. Identify 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.
1 6 2 A . B R A H A M WAKSMAN U I - 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 FIG. 3 Ui., r---~-I . . . F~----J . v I u2 ~ vz u3 ---F-,x-F "1-'Y-'F " I " - - ' , ~ ' - ~ ~ 6 10 13 Fro. 4 UI ' ~ E ~ - ~ r _ _ . ~ _ ~ X m -- vl U2 ' , __ V 2 ~3 t I V3 8 12 14 FIG. 5 u I ,, . vi U2 ~ v2 u 4 • v 4 U5 ~ v5 u6 ~ V 6 U8 V 8 4 8 i2 14 17 FIG. 6Example
Let N = 8 and the required
The partition matrix is
12845678~
permutatioIl 27e84315). The permutation matrix is
, i 2 3 ,4 5 6 7 1 8 i I [ I P i 3 (Z)
5
Q
6 I7 Q
s i I I 1,2 YI I Y2 Y3 # Xi I I I -- ! x2 I x~, 2 X4i I[~,. :'~:~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 ~ q u i r e d b y PA, and P2 corresponds to i.l:e porn::.:tati<>:: ::<tuired of .P~. T h e e~:t.ries in ~he 8 X 8 matrix corresponding {o P., :re oh'clod. Thus since u=,, v.:, and v: are e v e n , we set the cells 1, 15, attd 16
in Fig:~ro 3.
We are loft with the task of decomposing a n d s e t t i n g the permutation networks P~ a~:d P~,. The p~:rmutation a:~d p~rtition m a t r i c e s for P~ are
The corr(,sp<)ndi~g permt~tatioa networks P : a n d P2 of P<, are
Pl P2
;%~e:~ the <.yea eooali::a~es in the 4 X 4 P a m a t r i x identified with P: are u4 and
~, we s~:.t, celL< 6 ~md 13 in Figure 4. l>~ a n d P~ also represent the permutation r~,<iuir~d ef eeil:~ 9 a~d 10 ~:spectively in F i g u r e 4, which call for setting these cells.
By h:,ihr¢d~:g a similar pr<)cedure we arrive at F i g u r e 5, which represents the net- w~)rk required for ~.}:w r~ alizatiott of P , .
VigI~re ~i repr(',~ont~ the c<m~plete network which realizes the required permuI;ation. A pp~<:.nd iz
}t ~* ~,'s T,~;()~:a:. ]/,el A be any ,set, and let A t , 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 , o f A ~ , . . , , A ~ , i . e . , e l e m e n t s a ~ , . . . , a~ o f A s u c h that a~ ~ A ~ , i = 1 , . . . , r; ~,, ~ a~ j)~r i ~ j , il i:s "neee~'sary a n d sufliciez~t that ] b r each K in the range 1 <. K < r
~£e unh>n of a n y K o f # w sets A~ , .... , A~ have at least K elements.
}~2;:FER EN CIi:S
} H ~:~:~, P ()~: rep~'euen~ives of subsets. J. London M a t h . Soe. 10 (1965), 26-30.
2, B~:x~:s, V. E. Mathemal@al Theory of onnectzng hretworks and C Telephone Tra~c. Aea-
h ~ : c Press Ne,,v- York, 1935,