% $OpenXM: OpenXM/doc/Papers/rims-2003-12-16-ja-ohp.tex,v 1.10 2003/12/13 02:09:30 takayama Exp $
%% xdvi -paper a4r rims-2003-12-16-ja-ohp
%% dvips -f -t landscape  rims-2003-12-16-ja-ohp| psnup -8 -r | lpr -Pxerox6
%% dvipdfm -l rims-2003-12-16-ja-ohp
\documentclass{slides}
\usepackage{color}
\usepackage{rgb}
\usepackage{epsfig}
%\def\color#1{ }
%\def\epsffile#1{ Picture File: #1 }
%\def\epsfxsize{ }
%% Sample:
%% \epsfxsize=17cm
%% \epsffile{cz.ps}

\textwidth 9.2in
\textheight 7.2in
\columnsep 0.33in
\topmargin -1in

\def\nnn{ {\color{red} $\bullet$}\ }    %% $B;v<B(B
\def\eee{ {\color{magenta} Example}:\ } %% $BNc(B
\def\ttt{ {\color{red} $\bullet$}\ }   %% $BDjM}(B
\def\ppp{ {\color{blue} $\bullet$}\ }

\def\pagetitle#1{ \fbox{{\color{magenta} #1 }}}

\newenvironment{FRAME}{\begin{trivlist}\item[]
  \hrule
  \hbox to \linewidth\bgroup
  \advance\linewidth by -30pt
  \hsize=\linewidth
  \vrule\hfill
  \vbox\bgroup
    \vskip15pt
    \def\thempfootnote{\arabic{mpfootnote}}
    \begin{minipage}{\linewidth}}{%
    \end{minipage}\vskip15pt
  \egroup\hfill\vrule
 \egroup\hrule
\end{trivlist}}

\begin{document}
\noindent
\begin{center}
{\color{magenta} OpenXM $B$N?7%5!<%P(B, $B?7%W%m%H%3%k(B}
\end{center}
%% 2003, 12/16 (Tue), 
\begin{center}
{\color{SlateGray} OpenXM $B3+H/%0%k!<%W(B (committers):  http://www.openxm.org }
\end{center} 
\begin{enumerate}
\item $B?7$7$$%5!<%P(B ntl
\item $B?7$7$$%5!<%P(B polymake $B$H(B oxshell.
\item OX-RFC 103 ( 100, 101 $BJd0d(B)
\item OX-RFC 102 --- $BK\3JE*$J%5!<%P4VDL?.(B
\end{enumerate}
\newpage

%C OpenXM $B$O(B ... $B$NN,$G$3$3$K=q$$$F$"$k$h$&$J$3$H$rL\I8$K?tG/A0$+$i(B
%C $B%Q%C%1!<%8$N3+H/(B, $B%W%m%H%3%k$N3+H/$r$7$F$$$^$9(B.
\noindent  \quad \\
\ppp $B?t3X$G$NJBNs7W;;(B,  \\
\ppp $B?t3X%=%U%H%&%(%"$NE}9g2=(B $B$^$?$O(B Conglomerate $B2=(B (A.Solomon) \\
\ppp $B?t3XE*CN<1$N%^%M!<%8%a%s%H(B (Mathematical Knowledge Management) \\
\ppp $B<B:]$K?t3X$N8&5f$d?t3X$N1~MQ$K;H$($k%Q%C%1!<%8$N3+H/(B 

\noindent  \quad \\
\nnn OpenXM 1.1.1 (January 24, 2000): $B:G=i$N<B83HG(B. \\
\nnn OpenXM 1.1.2 (March 20, 2000): $B$H$j$"$($:;H$($kHG(B. \\
\nnn OpenXM 1.1.3 (September 26, 2000): 1.1 $B7O$N:G=*HG(B. OpenXM RFC 100 $B7A<0(B
   $B$N%W%m%;%9LZ(B. 1077 $B8D$N?t3X4X?t$rDs6!(B. 
   $BDs6!$7$F$$$k%5!<%P$O(B {\tt ox\_asir}, {\tt ox\_sm1},
   {\tt ox\_phc}, {\tt ox\_gnuplot}, {\tt ox\_m2}, {\tt ox\_tigers},
   {\tt ox\_math}(ematica), {\tt OMproxy}. \\
\nnn OpenXM 1.2.1 (March 2, 2002): Cygwin (Windows) $B$X$NBP1~3+;O(B. 
       $B%^%K%e%"%k<+F0@8@.(B(gentexi)$B$J$I(B. \\
\nnn OpenXM 1.2.2 (May 13, 2003):  RFC 103 ($BItJ,E*(B), autoconf\\ 
(\nnn) Digital formula book, OpenMath, tfb, CD (hypergeo*, weylalgebra*, intpath*),
 $B?tCM7W;;(B.

\newpage

\noindent
\pagetitle{ 1. {\color{blue} $B?7$7$$%5!<%P(B ntl}}
http://www.shoup.net/ntl,
{\footnotesize
NTL is a high-performance, portable C++ library providing data structures and algorithms for manipulating signed, arbitrary length integers, and for vectors,
matrices, and polynomials over the integers and over finite fields. 
}

{\color{blue} ox\_toolkit $+$ NTL $B%i%$%V%i%j(B}
$\Rightarrow$ {\color{red} ox\_ntl}
{\footnotesize
\begin{verbatim}
[1145]= ox_launch_nox(0,"/home/taka/OX4/OpenXM/bin/ox_ntl");
[1028] F=ntl.ex_data(4)$
[1029] F = F * subst(F, x, x + 1)$
[1030] ntl.factor(PID, F);  /* NTL $B$N(B knapsac factorizer */
[[1,1],
 [x^16+16*x^15-16*x^14-1344*x^13-4080*x^12+32576*x^11+157376*x^10-255232*x^9-2062624*x^8-249088*x^7+10702080*x^6+9126912*x^5-18643712*x^4-24167424*x^3+2712576*x^2+10653696*x+2324736,1],
[x^16-136*x^14+6476*x^12-141912*x^10+1513334*x^8-7453176*x^6+13950764*x^4-5596840*x^2+46225,1]]
\end{verbatim}
}

$B<BAu$K$h$jL@$i$+$K$J$C$?$3$H(B: \quad ox\_toolkit $B$NM-8z@-(B,
ox\_toolkit $B$NLdBjE@$N2~A1(B, LLL $B$r$h$V$?$a$K(B CMO array $B$bI,MW(B.

\rightline{$B3+H/(B: $B4d:,(B ($B>.86(B)}
\newpage


\noindent
\pagetitle{2. {\color{blue} $B?7$7$$%5!<%P(B polymake $B$H(B oxshell}}

{\color{red} Polymake } : $BB?LLBNMQ%=%U%H%&%(%"(B. \\
{\tt http://www.math.tu-berlin.de/polymake},
by Ewgenji Gawrilow, Michael Joswig. \\
% polemake logo
Facets, Convex hull, Triangulation, $B9=@.(B, polytope data,
Visualization by JavaView and Povray.

\newpage
\eee
$BE@(B $(1,0,0)$, $(1,1,0)$, $(1,0,1)$, $(1,1,1)$ $B>e$N(B cone $B$N(B facet $B$r5a$a$h(B. \\
{\tt polymake} $B$G$O$D$.$h$&$JF~NO%U%!%$%k(B {\tt square.poly} $B$r$^$::n@.$9$k(B.

\begin{minipage}{10cm}
{\footnotesize \color{blue} 
\begin{verbatim}
POINTS 
1 0 0 
1 1 0 
1 0 1 
1 1 1 
\end{verbatim}
}
\end{minipage}
\epsfxsize=8cm
\epsffile{rims-2003-12-16-sq.eps}

{\color{red} \verb@ polymake square.poly FACETS @ } \\
$B7k2L(B:
{\footnotesize \begin{verbatim}
FACETS
0 0 1
0 1 0
1 0 -1
1 -1 0
\end{verbatim} }

\newpage

\pagetitle{ Polymake $B$N(B OX 100, 101 $B%5!<%P2=$G2?$,LdBj$G$"$C$?$+(B?}
%C $B>\$7$$$3$H$O$3$3$K=q$$$F$k$3$H$rFI$s$G$b$i$&$3$H$K$7$F(B, $B0l8@$G$$$($P(B
%C C $B$N30It%W%m%0%i%`8F$S=P$7%7%9%F%`%3!<%k(B system $B$N5!G=$r6/2=$7$h$&$H$$$&$3$H(B

$B?7$7$$(B OX RFC 100 $B=`5r$N%5!<%P$r:n$k>l9g$K$O(B
$B%?!<%2%C%H$H$9$k?t3X%=%U%H%&%(%"%7%9%F%`$N%=!<%9%3!<%I$K(B OX RFC 100 $BBP1~ItJ,(B
$B$r2C$($k:n6H$r$7$J$$$H$$$1$J$$(B.
$B$3$N:n6H$O%=!<%9%3!<%I$NM}2r$H$+$J$j$N<j4V$rMW$9$k(B.
C++ $B$G=q$+$l$?(B polymake $B$N%=!<%9$O@hC<E*$J(B C++ $B$N5!G=$r(B
$BMxMQ$7$F$*$j%3%s%Q%$%k$,MF0W$G$J$$(B.


Polymake $B$O$"$i$+$8$a%U%!%$%k$K%3%^%s%I$d%G!<%?$r=q$-=P$7$F$*$/$3$H$K$h$j(B
unix $B$N(B shell ($B$d(B Windows $B$N%3%^%s%I%W%m%s%W%H(B) 
$B$+$iMxMQ2DG=$J$h$&$K:n$i$l$F$$$k(B: {\color{red} $B%P%C%A=hM}BP1~%"%W%j%1!<%7%g%s(B}.
$B%5!<%P$H$NDL?.$NIQEY$OLdBj$K$h$k$,$"$kDxEYBg$-$$7W;;$N>l9g$ODL?.;~4V$OL5;k$G$-$k(B.
Polymake $B$OBPOCE*MxMQ$OA[Dj$7$F$*$i$:%5!<%P$N7W;;$rCfCG$7$F(B, $B:FEY3+;O$9$k$J$I$NI,MW$,$J$$(B.
$\Rightarrow$ {\tt system} $B4X?t(B. $BLdBjE@(B: $B%U%!%$%k(B, OS $B$N0c$$(B, $B%W%m%;%94IM}(B
$\Rightarrow$ {\tt system} $B$N6/2=HG(B {\color{blue} oxshell}
\newpage

\pagetitle{ Oxshell $B$H$O(B }
Oxshell $B$O>e5-$N$h$&$J%P%C%A=hM}BP1~%"%W%j%1!<%7%g%s$r%=!<%9%3!<%I$N2~JQ$J$/(B 
OX RFC 100 $B=`5r$K$9$k$?$a$N$$$o$f$k%i%C%Q!<7?$N(B OX $B%5!<%P$r=q$/$?$a$NJd=u5!G=$r(B
$BDs6!$9$k(B sm1 $B$X$NAH$_9~$_4X?t$G$"$k(B.

Oxshell $B$rMQ$$$F(B OX $B%5!<%P$r<B8=$9$k$N$,E,@Z$J?t3X%=%U%H%&%(%"$O0J2<$N$h$&$JFCD'$r$b$D$b$N$G$"$m$&(B. \\
\nnn $B%P%C%A=hM}BP1~%"%W%j%1!<%7%g%s$G$"$k(B. \\
\nnn $B%=!<%9%3!<%I$NJQ99$,$G$-$J$$$+:$Fq(B. \\
\nnn $B%5!<%P$H$NDL?.$,IQHK$K$*$-$J$$(B. \\
\nnn $B%5!<%P$N7W;;$rCfCG$7$F(B, $B:FEY3+;O$9$k$J$I$NI,MW$,$J$$(B. \\
\nnn Windows $B$G$b(B unix $B$G$bF0$+$7$?$$(B.  \\

\pagetitle{ OX RFC 100 $B$NI|=,(B}

$B%/%i%$%"%s%H(B-$B%5!<%P%b%G%k(B.
$B%5!<%P$O(B stackmachine. 
(1) $B%9%?%C%/%^%7%s$X$N%a%C%;!<%8$rAw$k$3$H$K$h$j7W;;$,?J9T$9$k(B.
(2) $B7W;;$NCfCG$J$I$N%a%C%;!<%8$b$"$k(B.
(3) $B%5!<%P$O%(%s%8%s$H%3%s%H%m!<%k%W%m%;%9$h$j$J$k(B.

\newpage

\noindent OX RFC 100 $B$K$O(B\underline{$B%U%!%$%k$N35G0$,$J$$(B}. $B$7$?$,$C$F(B, \\
\verb@ polymake $B%U%!%$%kL>(B $BF0:n(B @ \\
$B$_$?$$$J%W%m%0%i%`$O(B OX $B%9%?%C%/%^%7%s$N>e$N%G!<%?$r%U%!%$%k$K=q$-=P$7$F$+$i(B
$B<B9T$7$F(B, $B$=$l$+$i$^$?%9%?%C%/%^%7%s$N>e$N%G!<%?$KJQ49$7$J$$$H$$$1$J$$(B.
($BC1=c;E;v(B, $B$7$+$7(B,  ZPG $B$N6KCW(B; unix $B$H(B windows $B0c$$(B,
/bin/sh $B$NB8:_(B, $B%W%m%0%i%`$,BgJQFI$_$K$/$/J]<i$b$7$K$/$$(B)

%C $B%"%$%G%#%"$O0l8@$G$$$($P<!$N0l9T$N$_(B.
{\tt oxshell} $B$G$O$3$N;E;v$O<!$N(B 1 $B9T$G=q$/(B. \\
{\color{red} \verb@[(polymake) (stringInOut://$B%9%?%C%/%^%7%sJQ?tL>(B.poly) $BF0:n(B] oxshell@}\\
$B%9%?%C%/%^%7%s$NJQ?t$r%U%!%$%k$r$_$J$7$F$$$k(B.

$B$3$N$h$&$J9M$(J}$O(B, $B$J$K$b?7$7$$$b$N$G$O$J$$(B. \\
$BNc(B: Java $B$N(B io.StringReader ( io.InputStreamReader $B$NBe$o$j(B). \\
$BNc(B: $B%9%/%j%W%H8@8l$G$"$k(B Python
  \verb@ x=os.popen("abc","r").read(); @
%C netscape $B$N(B plugin $B$J$I$bFbItE*$K$O;w$?%"%$%G%#%"$rMQ$$$F$$$k$H;W$o$l$k(B. 

\noindent
{\color{blue} $B?7$7$$ItJ,(B}:
$B$3$N9M$($r?t3X%=%U%H%&%(%"$NE}9g2=$N$?$a$K;H$&$?$a$N<BAu$OB8:_$7$F$$$J$+$C$?(B.
$B$3$l$,(B oxshell $B%3%^%s%I$NF3F~$K$h$C$F2r7h$5$l$kE@$N0l$D$G$"$k(B.
$B9M$(J}$,@0M}$5$l%W%m%0%i%`$NJ]<i@-$,BgJQ$h$/$J$j(B, $B$^$??7$7$$%P%C%A7?%"%W%j%1!<%7%g%s$N(BOX $B%5!<%P2=$,3Z$K$J$C$?(B.

\newpage

\eee
$BJ8;zNs(B {\tt S} $B$K3JG<$5$l$?C18l(B dog, cat, lion $B$r(B unix $B$N%D!<%k(B sort $B$G(B
$BJB$YJQ$($k$K$O<!$N$h$&$K=q$/(B.
$BF~NO$O(B oxshell $B$r<B9T$7$F$$$k%9%?%C%/%^%7%s$NJQ?t(B {\tt S} $B$K3JG<$5$l$F$$$k(B.

\begin{verbatim}
[1163]:= S="dog\ncat\nlion\n";
[1164]:= oxshell.set_value("S",S);
[1165]:= T=oxshell.oxshell(["sort","stringIn://S"]);
[cat
dog
lion
,]
\end{verbatim}
\newpage

\pagetitle{ oxshell.facets() $B$N<BAu(B, $B?t3X4X?t$N<BAuNc(B }

%C $B$b$&0l$D$N%]%$%s%H$O(B tfb, OpenMath $B$NM-8z@-$N<B>Z(B.
%C $BEv$jA0$@$,L5$/$F$O$J$i$J$$8&5f$@$C$?(B.
\nnn $B%G!<%?JQ49$K$O(B tfb/2 ($BEDB<(B)format $B$rMxMQ(B, OpenMath $B%"!<%-%F%/%A%c$rMxMQ(B.
{\color{blue}$B@.2L(B}: $B$=$NM-8z@-$r<B>Z$G$-$?(B.)
%% $B$3$l$b?7$7$$E@$G$"$m$&(B.
{\footnotesize \begin{verbatim}
[ $polymake.data(polymake.POINTS([[1,0,0],[1,1,0],[1,0,1],[1,1,1]]),
   polymake.FACETS([[0,0,1],[0,1,0],[1,0,-1],[1,-1,0]]),
   polymake.AFFINE_HULL())$
  CMO tree expression of the data above
  Outputs to stdout and stderr ]
\end{verbatim} }

%C $B?t3XE*$K$O<!$NF05!(B.  D-module $B$N7W;;$G(B facet $B$@$;$k(B.
%C ($B:XF#$`$D$_$N(B) $b$ function $B$r(B polytope algorithm $B$G5a$a$k=i$a$F$N<BAu(B.
{\color{red} taka\_ahg.b(A,Idx)}(OpenXM/src/asir-contrib/packages/src/taka\_ahg.rr)
oxshell $B$K$h$k(B polymake $B8F$S=P$75!G=$rMQ$$$??t3X4X?t(B.
$B$3$N4X?t$O(B $B9TNs(B {\tt A} $B$KIU?o$7$?(B $BJ}8~(B {\tt Idx} $B$N$"$k(B $b$ $B4X?t$r7W;;$9$k(B.
$B$3$l$O(B {\tt A} $B$NDj5A$9$k(B cone $B$N%U%!%;%C%H$r$"$i$o$90l<!<0$N@Q$GI=8=$5$l$k$3$H$,(B,
$BCN$i$l$F$$$k(B
(Saito, Mutsumi; Sturmfels, Bernd; Takayama, Nobuki; Hypergeometric polynomials and integer programming. Compositio Math. 115 (1999), no. 2, 185--204
$B$*$h$S(B
Saito, Mutsumi; Parameter shift in normal generalized hypergeometric systems. Tohoku Math. J. (2) 44 (1992), no. 4, 523--534
$B$r$_$h(B.)

\newpage

\begin{minipage}{13cm}
{\footnotesize
\begin{verbatim}
[1163]:= load("oxshell.rr");
[1164]:= load("taka_ahg.rr");
[1165]:=  A=[[1,0,0],[1,1,0],[1,0,1],[1,1,1],[1,2,0]];
[1166]:= fctr(taka_ahg.b(A,0,[s1,s2,s3]));
[[1,1],[s1-s3,1],[2*s1-s2-s3,1],[2*s1-s2-s3-1,1]]
\end{verbatim}

\begin{verbatim}
def b(A,Idx,V) {
  F = oxshell.facets(A);    /* Computing all the facets by polymake server.*/
  F = F[1];                 /* F is the set of the facets */
  P = A[Idx];
  Nfacets = length(F);
  F = toPrimitive2(P,F);   /* Translate into primitive supporting function */
  Bf = 1;
  for (I=0; I<Nfacets; I++) {
    H = matrix_inner_product(P,F[I]);
    if (H != 0) {
      B = matrix_inner_product(P,V);
      for (J=0; J<H; J++) {
        Bf = Bf*(B-J);  /* See the papers above. */
      }
    }
  } 
  return(Bf);
}
\end{verbatim}
}
\end{minipage}
\epsfxsize=12cm
\epsffile{rims-2003-12-16-sq2.eps}

\rightline{$B3+H/(B: $B9b;3(B}
\newpage


\noindent
\pagetitle{3. {\color{blue} OX-RFC 103 ( 100, 101 $BJd0d(B)}}

$B$3$N(B RFC $B$O(B OpenXM RFC 100 ($B$*$h$S(B 101) $B$N<BAu$K$h$jL@$i$+$K$J$C$?<o!9$NLdBjE@$r$b$H$K(B
RFC 100 $B%W%m%H%3%k$X$N4v$D$+$NDI2C$rDs0F$9$k(B.

\nnn $B%U%!%$%k$X$NFI$_=q$-(B \\
\nnn $B?7$7$$(B CMO \\
\nnn  $B%(%s%8%sG'>Z<jB3$-(B \\
\nnn $BCfCG$*$h$SJQ?t$NEAGE(B \\
1. $B<+J,$N;R6!%W%m%;%9$r$9$Y$F%j%9%H$9$k(B
  (asir$B$N>l9g(B:{\tt ox\_get\_serverinfo()}) \\
2. $B;R6!%W%m%;%9$K=gHV$K(B OpenXM-RFC 100 $B$NCfCG%a%C%;!<%8$rAw$k(B.

\noindent
{\color{red} ox103\_set\_shared\_variable(} CMO string {\tt Name}, CMO object {\tt
value}{\tt )}
$B%(%s%8%s%9%?%C%/%^%7%s$NJQ?t(B {\tt Name} $B$KCM(B
{\tt value} $B$,@_Dj(B,
$B$5$i$K;R$I$b$N%W%m%;%9$9$Y$F$N%(%s%8%s4X?t(B
 {\tt ox103\_set\_shared\_variable}
$B$r$h$V(B.

\rightline{$B3+H/(B: $B9b;3(B}
\newpage

\noindent
\pagetitle{4. {\color{blue} OX-RFC 102 --- $BK\3JE*$J%5!<%P4VDL?.$rMQ$$$?J,;67W;;(B}}
\parskip 5pt

OX-RFC-100, 101 : master-server $B4VDL?.$rMQ$$$?J,;67W;;(B

OX-RFC-102 : server-server $B4VDL?.(B

\underline{$BL\I8(B} : $BK\3JE*J,;6JBNs7W;;$r2DG=$K$9$k$3$H(B

\underline{$B1~MQNc(B}
\begin{itemize}
\item broadcast $B$r8zN(2=$9$k(B

N $B8D$N(B server $B$X$N(B broadcast $B$,(B $O(\log_2 N)$ $B$G$G$-$k(B

\item LU $BJ,2r$NJ,;6JBNs7W;;(B

ScaLAPACK $BIw$K(B, $B9TNs$rJ,;6J];}$7$FJBNs7W;;(B
\end{itemize}

\underline{$B;EMM(B}

MPI-2 $B$N(B, $BF0E*%W%m%;%9@8@.(B, $B%W%m%;%9%0%k!<%W4V(B broadcast $B$N;EMM$r(B
$B;29M$K$9$k(B.  {\tt http://www-unix.mcs.anl.gov/mpi}

\underline{$B?7$7$$E@(B}

OX RFC 100 $B$rA0Ds(B $\Rightarrow$ $B%G!<%?7?$N4IM}$NI,MW$,$J$$(B,
100 $B$NCfCG%W%m%H%3%k$N3HD%(B,
$B$J$I(BMPI $B$h$jMF0W$KMxMQ2DG=(B. 
%C $B$^$?(B, $B%7%9%F%`$N@_7W$G4sM?$G$-$J$/$F$b(B, $B<BNc$G$NM-8z@-(B, $B$"$kFCDj$NLdBj$G$N(B
%C $B@_7W$N2~A1Ey$r9M$($k(B.  $B2f!9$O(B Shoup $B$N(B $B%"%k%4%j%:%`$,8zN(NI$/<BAu$G$-$k(B
%C $B$3$H$r<($7$?(B.


\newpage

\noindent
\pagetitle{server $B$N5/F0(B, server $B4VDL?.O)$N3+@_(B}

server $B$O(B OX RFC-100, 101 $B$K$h$j5/F0$9$k(B. $B$3$NDL?.O)$K0J2<$N(B SM
$B%3%^%s%I$rAw$k(B.

\begin{itemize}
\item {\tt SM\_set\_rank\_102} $nserver$ $rank$

server $B$K(B, $B%0%k!<%WFb$N(B server $B$NAm?t(B $nserver$ $B$H(B, $B$=$NCf$G$N(B
$B<1JL;R(B $rank$ ($0 \le rank \le nserver$) $B$rDLCN$9$k(B.

\item {\tt SM\_tcp\_accept\_102} $port$ $peer$

$B%]!<%HHV9f(B $port$ $B$N(B TCP $B%]!<%H$G(B, bind, listen, accept $B$r<B9T(B
$B$7$F(B connect $B$rBT$D(B. $BDL?.$,@.N)$7$?$i(B, byte order negotiation
$B$r9T$$(B, $BAj<j@h%F!<%V%k$KEPO?$9$k(B.

\item {\tt SM\_tcp\_connect\_102} $peerhost$ $port$ $peer$

$B%[%9%H(B $peerhost$ $B$N%]!<%HHV9f(B $port$ $B$N(B TCP $B%]!<%H$K(B connect $B$9$k(B. 
$BDL?.$,@.N)$7$?$i(B, byte order negotiation $B$r9T$$(B, $BAj<j@h%F!<%V%k$KEPO?(B
$B$9$k(B.

\end{itemize}

\newpage

\noindent
\pagetitle{server $B4VDL?.(B, broadcast, reduction}

server $B4VDL?.$O(B, $BAj8_$N?.Mj$K4p$E$-9T$&(B --- $BAw$j<j$,Aw?.$7$?$i(B, $B<u$1<j$O(B
$B$A$c$s$H<u?.F0:n$KF~$k$3$H(B

$B%G!<%?$O(B OX $B%?%0IU$-$G(B --- {\tt OX\_SYNC\_BALL} $B$K$h$kDL?.O)%j%;%C%H$KI,MW(B

$B0J2<$N(B SM $B%3%^%s%I$O(B collective $BA`:n$G$"$k(B. $B$9$J$o$A(B, $BF10l0z?t$G(B
$B%0%k!<%WFb$NA4$F$N(B server $B$G<B9T$5$l$J$1$l$P$$$1$J$$(B.

\begin{itemize}
\item {\tt SM\_bcast\_102} $root$

$B<1JL;R(B $root$ $B$N(B server $B$N%9%?%C%/>e$N%G!<%?$r(B pop $B$7(B, $B%0%k!<%WFb$K(B
broadcast $B$9$k(B. $B3F(B server $B$N%9%?%C%/$K(B broadcast $B$5$l$?%G!<%?$,(B push
$B$5$l$k(B.

\item {\tt SM\_reduce\_102} $root$ $opname$

$B3F(B server $B$N%9%?%C%/>e$N%G!<%?$,(B pop $B$5$l(B, $opname$ $B$G;XDj$5$l$k(B
$BFs9`1i;;(B($B7k9gB'$,I,MW(B) $B$r=g$K9T$$(B, $B7k2L$r(B $root$ $B$G;XDj$5$l$k(B server
$B$N%9%?%C%/$K(B push $B$9$k(B. $BB>$N(B server $B$K$O(B $0$ $B$,(B push 
$B$5$l$k(B.
\end{itemize}

\newpage

\noindent
\pagetitle{broadcast $B$N<jB3$-(B}

{SM\_bcast\_102} $B$N<B9T(B 

$root=0$ $B$G(B, $B<1JL;R$,(B $b2^k$ ($b$ $B$O4q?t(B) $B$N(B server $B$NF0:n(B

\vskip\baselineskip
\begin{tabbing}
$data \leftarrow$ $B<1JL;R$,(B $(b-1)2^k$ $B$N(B server $B$+$i$N%G!<%?(B\\
for \= $i=k-1$ down to $0$\\
    \> $B<1JL;R$,(B $b2^k+2^i$ $B$N(B server $B$K(B $data$ $B$rAw?.(B\\
end for
\end{tabbing}
\vskip\baselineskip
2 $B$G3d$j@Z$l$k2s?t$,B?$$<1JL;R$r;}$D(B server $B$,@h$K%G!<%?Aw?.(B

$\Rightarrow$ $B%G%C%I%m%C%/$K$J$i$J$$(B

$BFHN)$J%Z%"$I$&$7$NDL?.$,F1;~$K9T$($k$J$i!"9b!9(B $\lceil \log_2 N\rceil$ $B%9%F%C%W(B
($N$ $B$O(B server $B$NAm?t(B) $B$G(B broadcast $B40N;(B.

\newpage

%C $B:YIt$O>JN,(B. $B$"$H$G(B 16 $B8D$N%5!<%P$N<BNc$G@bL@(B.
\noindent
\pagetitle{reduction $B$N<jB3$-(B}

{SM\_reduce\_102} $B$N<B9T(B 

server $B?t(B $N$, $root=0$ $B$G(B, $B<1JL;R$,(B $b$ $B$N(B server $B$NF0:n(B

$B<j;}$A$N%G!<%?$r(B $data$ $B$H$9$k(B

\vskip\baselineskip
\begin{tabbing}
for \= $i=0$ to $\lfloor \log_2 N \rfloor$\\
    \> if \= ( $b$ $B$K(B $2^i$ $B$N(B bit $B$,$"$k(B) then\\
    \>    \> $B<1JL;R(B $b-2^i$ $B$N(B server $B$K(B $data$ $B$rAw?.$7$F=*N;(B\\
    \> else if ( $b+2^i < N$ ) then \\
    \>     \> $data_0 \leftarrow$ $B<1JL;R(B $b+2^i$ $B$N(B server $B$+$i$N%G!<%?(B\\
    \>      \> $data \leftarrow data$ $B$H(B $data_0$ $B$NFs9`1i;;7k2L(B \\
    \> end if\\
end for
\end{tabbing}
\vskip\baselineskip

$B$3$N>l9g$b(B, $BFHN)$J%Z%"$I$&$7$NDL?.$,F1;~$K9T$($k$J$i!"9b!9(B $\lceil \log_2 N\rceil$ $B%9%F%C%W(B
($N$ $B$O(B server $B$NAm?t(B) $B$G(B reduction $B40N;(B. $B7k2L$O(B root $B$K;D$k(B.
\newpage

\noindent
\pagetitle{broadcast $B;~$N%G!<%?$NN.$l(B}


$N=16$, $root=0$ $B$N>l9g(B

\begin{center}
\begin{tabular}{|c|c|c|c|}
step 1 & step 2 & step 3 & step 4 \\ \hline
$0\rightarrow 8$&$0\rightarrow 4$ &$0\rightarrow 2$  &$0\rightarrow 1$ \\
                &$8\rightarrow 12$&$8\rightarrow 10$  &$8\rightarrow 9$ \\
                &                 &$4\rightarrow 6$ &$4\rightarrow 5$ \\
                &                 &$12\rightarrow 14$&$12\rightarrow 13$ \\
                &                 &                  &$2\rightarrow 3$ \\
                &                 &                  &$10\rightarrow 11$ \\
                &                 &                  &$6\rightarrow 7$ \\
                &                 &                  &$14\rightarrow 15$
\end{tabular}
\end{center}

reduction $B$N>l9g(B, $B%G!<%?$NN.$l$O5U$K$J$k(B (step 4 $\rightarrow$ step 1,
$BLp0u$,5U(B)
\newpage

%C $B$3$l$O%*%j%8%J%k(B.
\noindent
\pagetitle{$B%(%i!<=hM}(B}

master-server $B4VDL?.O)$O(B, OX RFC-100 $B$G5,Dj$5$l$F$$$k(B.

server-server $B4VDL?.O)$r6u$K$9$k$?$a$N(B, $B<1JL;R(B $i$ $B$N(B server $B$G$NA`:n(B

\begin{tabbing}
for \= $j = 0$ \= to $i-1$ do\\
    \> do\\
    \>         \>$data$ $\leftarrow$ $B<1JL;R(B $j$ $B$N(B server $B$+$i$N(B OX $B%G!<%?(B\\
    \> while $data \neq$ {\tt OX\_SYNC\_BALL}\\
end for\\
for $j = i+1$ to $nserver-1$ do\\
    \> {\tt OX\_SYNC\_BALL} $B$r(B $B<1JL;R(B $j$ $B$N(B server $B$KAw?.(B\\
end for
\end{tabbing}

master-server $B%j%;%C%H8e(B : $B3F(B server $B$O%3%^%s%IBT$A>uBV(B

$\Rightarrow$ $B<!$N(B SM $B%3%^%s%I$r3F(B server $B$KAw?.$9$l$P$h$$(B

\begin{itemize}
\item {\tt SM\_reset\_102} ($B0z?t$J$7(B, collective)
\end{itemize}

\newpage

\noindent
\pagetitle{Asir (master) $B>e$G$N(B API}

\begin{itemize}
\item {\tt ox\_set\_rank\_102($Server$,$Nserver$,$Rank$)}

$Server$ $B$K(B {\tt SM\_set\_rank\_102} $B$rAw$k(B.

\item {\tt ox\_tcp\_accept\_102($Server$,$Port$,$Rank$)}

$Server$ $B$K(B {\tt SM\_tcp\_accept\_102} $B$rAw$k(B.

\item {\tt ox\_tcp\_connect\_102($Server$,$Host$,$Port$,$Rank$)}

$Server$ $B$K(B {\tt SM\_tcp\_connect\_102} $B$rAw$k(B.

\item {\tt ox\_reset\_102($Server$)} (collective)

$Server$ $B$K(B {\tt SM\_reset\_102} $B$rAw$k(B

\end{itemize}

\newpage

\noindent
\pagetitle{Asir (server) $B>e$G$N(B API}

\begin{itemize}
\item {\tt ox\_send\_102($Rank$,$Data$)}

$B<1JL;R(B $Rank$ $B$N(B server $B$K(B $Data$ $B$r(B OX $B%G!<%?$H$7$FAw?.$9$k(B.
$B<1JL;R(B $Rank$ $B$N(B server $B$OBP1~$9$k<u?.$r3+;O$7$J$1$l$P$J$i$J$$(B.

\item {\tt ox\_recv\_102($Rank$)}

$B<1JL;R(B $Rank$ $B$N(B server $B$+$i(B OX $B%G!<%?$r<u?.$9$k(B.
$B<1JL;R(B $Rank$ $B$N(B server $B$OBP1~$9$kAw?.$r3+;O$7$J$1$l$P$J$i$J$$(B.

\item {\tt ox\_bcast\_102($Root$[,$Data$])} (collective)

$B<1JL;R(B $Root$ $B$N(B server $B$r(B root $B$H$7$F(B, $B%0%k!<%WFb$G(B broadcast $B$9$k(B.
$Data$ $B$,;XDj$5$l$?>l9g(B, $B%9%?%C%/$K%W%C%7%e$5$l$k(B.
$B<1JL;R$,(B $Root$ $B$KEy$7$$(B server $B$G(B, $B%9%?%C%/(B
$B$+$i%G!<%?$,%]%C%W$5$l(B, $B$=$N%G!<%?$,(B, $B3F8F$S=P$7$NLa$jCM$H$J$k(B.

\item {\tt ox\_reduce\_102($Root$,$Operation$[,$Data$])} (collective)

$B%0%k!<%WFb$N3F(B server $B$N%9%?%C%/$+$i%]%C%W$7$?%G!<%?$KBP$7(B
$Operation$ $B$G;XDj$5$l$kFs9`1i;;$r9T$$(B,
$B7k2L$r(B $Root$ $B$G;XDj$5$l$k(B server $B$G$N4X?t8F$S=P$7$NLa$jCM$H$7$F(B
$BJV$9(B.
$Data$ $B$,;XDj$5$l$?>l9g(B, $B%9%?%C%/$K%W%C%7%e$7$F$+$i>e5-$NA`:n$r(B
$B<B9T$9$k(B. $Root$ $B0J30$N(B server $B$G$NLa$jCM$O(B 0 $B$G$"$k(B.
\end{itemize}


\newpage

\noindent
\pagetitle{$B<B9TNc(B : $B0lJQ?tB?9`<0$N@Q(B (master $BB&(B)}

\begin{verbatim}
def d_mul(F1,F2)
{
    Procs = getopt(proc);
    /* process $B;XDj$,$J$$>l9g$K$O(B, $B<+J,$G7W;;(B */
    if ( type(Procs) == -1 ) return umul(F1,F2);
    if ( !var(F1) || !var(F2) ) return F1*F2;
    NP = length(Procs);
    /* $B0z?t$r(B server 0 $B$KAw$k(B */
    ox_push_cmo(0,[F1,F2]);
    /* $B3F(B server $B$K(B, server 0 $B$r(B root $B$H$7$F;E;v$r;O$a$k$h$&0MMj(B */
    for ( I = 0; I < NP; I++ ) 
        ox_cmo_rpc(I,"d_mul_main",0);
    /* server 0 $B$+$i7k2L$r<u$1<h$k(B */
    R = ox_pop_cmo(0);
    return R;
}
\end{verbatim}

\newpage

\noindent
\pagetitle{$B<B9TNc(B : $B0lJQ?tB?9`<0$N@Q(B (server $BB&(B; collective)}
\begin{verbatim}
def d_mul_main(Root)   /* Shoup's algorithm */
{
    /* server $B$NAm?t(B, $B<+J,$N(B id $B$rCN$k(B */
    Id = ox_get_rank_102(); NP = Id[0]; Rank = Id[1];
    /* Root $B$K$"$k0z?t$r(B broadcast $B$G6&M-(B */
    Arg = ox_bcast_102(Root); F1 = Arg[0]; F2 = Arg[1];
    L = setup_modarrays(F1,F2,NP);
    Marray = L[0]; MIarray = L[1]; M = L[2];
    R = umul_chrem(F1,F2,MIarray[Rank],Marray[Rank],M);
    Arg = 0; F1 = 0; F2 = 0;
    /* $B3F(B server $B$N7k2L$rB-$79g$o$;$F(B, Root $B$KCV$/(B */
    R = ox_reduce_102(Root,"+",R);
    /* Root $B$N$_(B, $B7k2L$r(B normalize $B$9$k(B */
    if ( Rank == Root )
        R = uadj_coef(R%M,M,ishift(M,1));
    return R;
}
\end{verbatim}

\rightline{$B3+H/(B: $BLnO$(B}

\end{document}

%%$Id: rims-2003-12-16-ja-ohp.tex,v 1.4 2003/12/11 05:40:59 taka Exp $ at misc-2003/12/RIMS
