Annotation of OpenXM/doc/ascm2001p/homogeneous-network.tex, Revision 1.6
1.6 ! noro 1: % $OpenXM: OpenXM/doc/ascm2001p/homogeneous-network.tex,v 1.5 2001/06/20 03:08:05 takayama Exp $
1.1 noro 2:
3: \subsection{Distributed computation with homogeneous servers}
4: \label{section:homog}
5:
6: One of the aims of OpenXM is a parallel speedup by a distributed computation
1.5 takayama 7: with homogeneous servers.
8: %As the current specification of OpenXM does
9: %not include communication between servers, one cannot expect
10: %the maximal parallel speedup. However it is possible to execute
11: %several types of distributed computation as follows.
1.1 noro 12:
1.3 noro 13: \subsubsection{Competitive distributed computation by various strategies}
1.1 noro 14:
1.3 noro 15: SINGULAR \cite{Singular} implements {\it MP} interface for distributed
16: computation and a competitive Gr\"obner basis computation is
17: illustrated as an example of distributed computation.
1.6 ! noro 18: Such a distributed computation is also possible on OpenXM.
1.3 noro 19:
20: \begin{verbatim}
1.6 ! noro 21: extern Proc1,Proc2$ Proc1 = -1$ Proc2 = -1$
1.3 noro 22: /* G:set of polys; V:list of variables */
23: /* Mod: the Ground field GF(Mod); O:type of order */
24: def dgr(G,V,Mod,O)
25: {
26: /* invoke servers if necessary */
27: if ( Proc1 == -1 ) Proc1 = ox_launch();
28: if ( Proc2 == -1 ) Proc2 = ox_launch();
29: P = [Proc1,Proc2];
30: map(ox_reset,P); /* reset servers */
31: /* P0 executes Buchberger algorithm over GF(Mod) */
32: ox_cmo_rpc(P[0],"dp_gr_mod_main",G,V,0,Mod,O);
33: /* P1 executes F4 algorithm over GF(Mod) */
34: ox_cmo_rpc(P[1],"dp_f4_mod_main",G,V,Mod,O);
35: map(ox_push_cmd,P,262); /* 262 = OX_popCMO */
36: F = ox_select(P); /* wait for data */
37: /* F[0] is a server's id which is ready */
38: R = ox_get(F[0]);
39: if ( F[0] == P[0] ) { Win = "Buchberger"; Lose = P[1]; }
40: else { Win = "F4"; Lose = P[0]; }
41: ox_reset(Lose); /* reset the loser */
42: return [Win,R];
43: }
44: \end{verbatim}
1.6 ! noro 45: In the above Asir program, the client creates two servers and it requests
! 46: Gr\"obner basis comutations by the Buchberger algorithm the $F_4$ algorithm
! 47: to the servers for the same input.
! 48: The client watches the streams by {\tt ox\_select()}
! 49: and the result which is returned first is taken. Then the remaining
! 50: server is reset.
1.1 noro 51:
1.4 noro 52: \subsubsection{Nesting of client-server communication}
53:
54: Under OpenXM-RFC 100 an OpenXM server can be a client of other servers.
55: Figure \ref{tree} illustrates a tree-like structure of an OpenXM
56: client-server communication.
57: \begin{figure}
58: \label{tree}
59: \begin{center}
60: \begin{picture}(200,70)(0,0)
61: \put(70,70){\framebox(40,15){client}}
62: \put(20,30){\framebox(40,15){server}}
63: \put(70,30){\framebox(40,15){server}}
64: \put(120,30){\framebox(40,15){server}}
65: \put(0,0){\framebox(40,15){server}}
66: \put(50,0){\framebox(40,15){server}}
67: \put(150,0){\framebox(40,15){server}}
68:
69: \put(90,70){\vector(-2,-1){43}}
70: \put(90,70){\vector(0,-1){21}}
71: \put(90,70){\vector(2,-1){43}}
72: \put(40,30){\vector(-2,-1){22}}
73: \put(40,30){\vector(2,-1){22}}
74: \put(140,30){\vector(2,-1){22}}
75: \end{picture}
76: \caption{Tree-like structure of client-server communication}
77: \end{center}
78: \end{figure}
79: Such a computational model is useful for parallel implementation of
80: algorithms whose task can be divided into subtasks recursively.
81:
1.1 noro 82: %A typical example is {\it quicksort}, where an array to be sorted is
83: %partitioned into two sub-arrays and the algorithm is applied to each
84: %sub-array. In each level of recursion, two subtasks are generated
85: %and one can ask other OpenXM servers to execute them.
86: %Though it makes little contribution to the efficiency in the case of
87: %quicksort, we present an Asir program of this distributed quicksort
88: %to demonstrate that OpenXM gives an easy way to test this algorithm.
89: %In the program, a predefined constant {\tt LevelMax} determines
90: %whether new servers are launched or whole subtasks are done on the server.
91: %
92: %\begin{verbatim}
93: %#define LevelMax 2
94: %extern Proc1, Proc2;
95: %Proc1 = -1$ Proc2 = -1$
96: %
97: %/* sort [A[P],...,A[Q]] by quicksort */
98: %def quickSort(A,P,Q,Level) {
99: % if (Q-P < 1) return A;
100: % Mp = idiv(P+Q,2); M = A[Mp]; B = P; E = Q;
101: % while (1) {
102: % while (A[B] < M) B++;
103: % while (A[E] > M && B <= E) E--;
104: % if (B >= E) break;
105: % else { T = A[B]; A[B] = A[E]; A[E] = T; E--; }
106: % }
107: % if (E < P) E = P;
108: % if (Level < LevelMax) {
109: % /* launch new servers if necessary */
110: % if (Proc1 == -1) Proc1 = ox_launch(0);
111: % if (Proc2 == -1) Proc2 = ox_launch(0);
112: % /* send the requests to the servers */
113: % ox_rpc(Proc1,"quickSort",A,P,E,Level+1);
114: % ox_rpc(Proc2,"quickSort",A,E+1,Q,Level+1);
115: % if (E-P < Q-E) {
116: % A1 = ox_pop_local(Proc1);
117: % A2 = ox_pop_local(Proc2);
118: % }else{
119: % A2 = ox_pop_local(Proc2);
120: % A1 = ox_pop_local(Proc1);
121: % }
122: % for (I=P; I<=E; I++) A[I] = A1[I];
123: % for (I=E+1; I<=Q; I++) A[I] = A2[I];
124: % return(A);
125: % }else{
126: % /* everything is done on this server */
127: % quickSort(A,P,E,Level+1);
128: % quickSort(A,E+1,Q,Level+1);
129: % return(A);
130: % }
131: %}
132: %\end{verbatim}
1.3 noro 133: %
1.4 noro 134: A typical example is a parallelization of the Cantor-Zassenhaus
135: algorithm for polynomial factorization over finite fields.
136: which is a recursive algorithm.
137: At each level of the recursion, a given polynomial can be
138: divided into two non-trivial factors with some probability by using
139: a randomly generated polynomial as a {\it separator}.
140: We can apply the following simple parallelization:
141: When two non-trivial factors are generated on a server,
142: one is sent to another server and the other factor is factorized on the server
143: itself.
1.1 noro 144: %\begin{verbatim}
145: %/* factorization of F */
146: %/* E = degree of irreducible factors in F */
147: %def c_z(F,E,Level)
148: %{
149: % V = var(F); N = deg(F,V);
150: % if ( N == E ) return [F];
151: % M = field_order_ff(); K = idiv(N,E); L = [F];
152: % while ( 1 ) {
153: % /* gererate a random polynomial */
154: % W = monic_randpoly_ff(2*E,V);
155: % /* compute a power of the random polynomial */
156: % T = generic_pwrmod_ff(W,F,idiv(M^E-1,2));
157: % if ( !(W = T-1) ) continue;
158: % /* G = GCD(F,W^((M^E-1)/2)) mod F) */
159: % G = ugcd(F,W);
160: % if ( deg(G,V) && deg(G,V) < N ) {
161: % /* G is a non-trivial factor of F */
162: % if ( Level >= LevelMax ) {
163: % /* everything is done on this server */
164: % L1 = c_z(G,E,Level+1);
165: % L2 = c_z(sdiv(F,G),E,Level+1);
166: % } else {
167: % /* launch a server if necessary */
168: % if ( Proc1 < 0 ) Proc1 = ox_launch();
169: % /* send a request with Level = Level+1 */
170: % /* ox_c_z is a wrapper of c_z on the server */
171: % ox_cmo_rpc(Proc1,"ox_c_z",lmptop(G),E,
172: % setmod_ff(),Level+1);
173: % /* the rest is done on this server */
174: % L2 = c_z(sdiv(F,G),E,Level+1);
175: % L1 = map(simp_ff,ox_pop_cmo(Proc1));
176: % }
177: % return append(L1,L2);
178: % }
179: % }
180: %}
181: %\end{verbatim}
182: %
183: %
184: %
185: %
186: %
187: %
188: %
1.2 noro 189:
190: \subsubsection{Product of univariate polynomials}
191:
192: Shoup \cite{Shoup} showed that the product of univariate polynomials
193: with large degrees and large coefficients can be computed efficiently
194: by FFT over small finite fields and Chinese remainder theorem.
195: It can be easily parallelized:
196:
197: \begin{tabbing}
198: Input :\= $f_1, f_2 \in {\bf Z}[x]$ such that $deg(f_1), deg(f_2) < 2^M$\\
199: Output : $f = f_1f_2$ \\
200: $P \leftarrow$ \= $\{m_1,\cdots,m_N\}$ where $m_i$ is an odd prime, \\
201: \> $2^{M+1}|m_i-1$ and $m=\prod m_i $ is sufficiently large. \\
202: Separate $P$ into disjoint subsets $P_1, \cdots, P_L$.\\
203: for \= $j=1$ to $L$ $M_j \leftarrow \prod_{m_i\in P_j} m_i$\\
204: Compute $F_j$ such that $F_j \equiv f_1f_2 \bmod M_j$\\
205: \> and $F_j \equiv 0 \bmod m/M_j$ in parallel.\\
206: \> (The product is computed by FFT.)\\
207: return $\phi_m(\sum F_j)$\\
208: (For $a \in {\bf Z}$, $\phi_m(a) \in (-m/2,m/2)$ and $\phi_m(a)\equiv a \bmod m$)
209: \end{tabbing}
210:
211: Figure \ref{speedup}
212: shows the speedup factor under the above distributed computation
213: on Risa/Asir. For each $n$, two polynomials of degree $n$
214: with 3000bit coefficients are generated and the product is computed.
215: The machine is FUJITSU AP3000,
216: a cluster of Sun workstations connected with a high speed network
217: and MPI over the network is used to implement OpenXM.
218: \begin{figure}[htbp]
219: \epsfxsize=8.5cm
220: \epsffile{speedup.ps}
221: \caption{Speedup factor}
222: \label{speedup}
223: \end{figure}
224:
225: If the number of servers is $L$ and the inputs are fixed, then the cost to
226: compute $F_j$ in parallel is $O(1/L)$, whereas the cost
227: to send and receive polynomials is $O(L)$ if {\tt ox\_push\_cmo()} and
228: {\tt ox\_pop\_cmo()} are repeatedly applied on the client.
229: Therefore the speedup is limited and the upper bound of
230: the speedup factor depends on the ratio of
231: the computational cost and the communication cost for each unit operation.
232: Figure \ref{speedup} shows that
233: the speedup is satisfactory if the degree is large and $L$
234: is not large, say, up to 10 under the above environment.
235: If OpenXM provides collective operations for broadcast and reduction
236: such as {\tt MPI\_Bcast} and {\tt MPI\_Reduce} respectively, the cost of
237: sending $f_1$, $f_2$ and gathering $F_j$ may be reduced to $O(\log_2L)$
238: and we can expect better results in such a case. In order to implement
239: such operations we need new specifications for inter-sever communication
240: and the session management, which will be proposed as OpenXM-RFC 102.
241: We note that preliminary experiments show the collective operations
242: work well on OpenXM.
243:
244: %\subsubsection{Competitive distributed computation by various strategies}
245: %
246: %SINGULAR \cite{Singular} implements {\it MP} interface for distributed
247: %computation and a competitive Gr\"obner basis computation is
248: %illustrated as an example of distributed computation.
249: %Such a distributed computation is also possible on OpenXM as follows:
250: %
251: %The client creates two servers and it requests
252: %Gr\"obner basis comutations from the homogenized input and the input itself
253: %to the servers.
254: %The client watches the streams by {\tt ox\_select()}
255: %and the result which is returned first is taken. Then the remaining
256: %server is reset.
257: %
258: %\begin{verbatim}
259: %/* G:set of polys; V:list of variables */
260: %/* O:type of order; P0,P1: id's of servers */
261: %def dgr(G,V,O,P0,P1)
262: %{
263: % P = [P0,P1]; /* server list */
264: % map(ox_reset,P); /* reset servers */
265: % /* P0 executes non-homogenized computation */
266: % ox_cmo_rpc(P0,"dp_gr_main",G,V,0,1,O);
267: % /* P1 executes homogenized computation */
268: % ox_cmo_rpc(P1,"dp_gr_main",G,V,1,1,O);
269: % map(ox_push_cmd,P,262); /* 262 = OX_popCMO */
270: % F = ox_select(P); /* wait for data */
271: % /* F[0] is a server's id which is ready */
272: % R = ox_get(F[0]);
273: % if ( F[0] == P0 ) {
274: % Win = "nonhomo"; Lose = P1;
275: % } else {
276: % Win = "homo"; Lose = P0;
277: % }
278: % ox_reset(Lose); /* reset the loser */
279: % return [Win,R];
280: %}
281: %\end{verbatim}
282:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>