[BACK]Return to homogeneous-network.tex CVS log [TXT][DIR] Up to [local] / OpenXM / doc / ascm2001p

Annotation of OpenXM/doc/ascm2001p/homogeneous-network.tex, Revision 1.5

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>