D.10.1. A Simple Session

Let file sum_vec.mpc contain the following mpC code:

#include <stdio.h> nettype Star(n) {coord I=n;};  #define M 4 /*number of the processors*/ #define N 3 /*dimension of the vectors on the each processor*/ #define NM N*M /*dimension of the source vectors*/ void [*]main() {    int [host]x[NM], [host]y[NM], [host]z[NM], [host]i;     void [*]parsum(),[*]parsum1(); ([host]printf)(“<host input vectors>\n”); for(i=0;i<NM;i++) {    x[i]=i;     y[i]=-i;  } ([host]printf)(“x=“); for(i=0;i<NM;i++)([host]printf)(“ %d”,x[i]);  ([host]printf)(“\ny=“); for(i=0;i<NM;i++)([host]printf)(“ %d”,y[i]);  ([host]printf)(“\n”); parsum((void*)x, (void*)y, (void*)z);  ([host]printf)(“<host result vector>\n z=“); for(i=0;i<NM;i++)([host]printf)(“ %d”,z[i]); ([host]printf)(“\n”); } void [*]parsum(int [host]x[M][N], int [host]y[M][N],                int [host]z[M][N]) {    net Star(M) Sn;     int [Sn]dx[N], [Sn]dy[N], [Sn]dz[N];     int [Sn] i,[host]j,[host]l;     dx[]=x[];    dy[]=y[];    dz[]=dx[]+dy[];    z[]=dz[]; }

xxx xxxxxxx xxxx xx xxx xxxxxxx xx x xxxxxxxx xxxxxxxxxx xxxxx xxxxxxxx xxxxxx. xxxx xxxxxxxx xxxxxxx xx xxx xxxxxxx xxxx x xxxxxxxx xxxxxxxxxx, xxxxxxxx xxxxxxxx xx xxxxxxx, xxxxxxxxxx xxx xxx, xxx xxxxxxx xxxxxxx xx xxx xxxx. xx xxxxxxxx, xxxxxxx xxxx xxx xxxx xxxxx xx x xxxxxxxxxxx xxxx. xx xxxxxx xxxx xxx xxxx xxxxx xx xxxxxxx xxx xxxxxxxxxxx xx xxxx xxxxxx xxxxxxxxxxx xxx xxxx xxx xxxxxxxxxxxxx xxx xxx xxx xxxx xxxxxxx xxx. xxxxxxxxx, xxx xxxx xxxxxx xxxxx xxxxxx xxx xxx. xx xx xxxx, xxx xxxx xxxxxxx xxx xxxxxxxxx xxxxxxxxxxx xxxx xxxxx xx xxx $xxxxxxx xxxxxxxxx:

# my own workstation only_beta 5

Then the user creates the VPM with name beta5:

mpccreate beta5

xx xxx xxxxxxx xx xxxx xxxxxxxxx xxxx

mpccreate: net definition /home/mpc/topo/beta5.def is created.  mpccreate: scheme /home/mpc/topo/beta5.ts is created. LAM 6.0 - Ohio Supercomputer Center mpccreate: wait for creation ‘beta5’_mpccreate: parallel machine ‘beta5’ is created. 

will appear. Note that immediately after the creation, the VPM is opened. Then, the user compiles the mpC file:

mpcc sum_vec.mpc 

xxx xxxxxx xxx xxxxxx xxxx xxx_xxx.x xx xxx $xxxxxxx xxxxxxxxx:

cp sum_vec.c $MPCLOAD

As the user wants to execute the application on the beta workstation only, he can skip the step of broadcasting sum_vec.c. Then the user makes an executable sum_vec:

mpcload -o sum_vec sum_vec.c

xxxxxxx, xxx xxxx xxxx xxx xxxxxxxxxxx:

mpcrun sum_vec

On the console of beta something like

<host input vectors> x= 0 1 2 3 4 5 6 7 8 9 10 11 y= 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 <host result vector> z= 0 0 0 0 0 0 0 0 0 0 0 0

xxxx xxxxxx. xxxx xxx xxxx xxx xxxxx xxx xxxxxx xx xxxxxx


On the console of beta something like

mpctouch: Ready!

xxxx xxxxxx.

D.10.2. More Complicated Session

Let a VPM that will run the application gal-buf.mpc is already opened. The following command produces two target C files—one for the abstract host-processor, with calls to Xlib displaying data in the graphical form, and the other for the abstract processors not involved in graphically displaying data:

mpcc -I/usr/openwin/include -het gal-buf.mpc

xxxxx xxxx xxx xxxxxxxx xxxxxxxxxxx xxxx xxxxxx xx xxxx xx xx xxx xx xxx xxxxxxx xxxxxxxxx. xx x xxxxxxx xxxxxx xxxxxx xxx xxxxxxx xxxxx xx xxx xxxx xxxxxxxxxxx xx x xxxxxxxxx xxxxxxxxx xxxx /xxx/xxxxxxx/xxxxxxx, xxx xxxx xxxxxxxxx xxxxxxx.

The above command will produce files gal-buf_host.c and _gal-buf_node.c in the current directory. To make these files accessible to the mpC programming environment, copy them into the $MPCLOAD _directory:

cp gal-buf_host.c gal-buf_node.c $MPCLOAD

xxxxxxxxx xxxxx xxxxx xxxx xxx xxxx xxxxxxxxxxx xx xxx xxxxx xxxxxxxxx xx xxx xxx:

mpcbcast gal-buf_host.c gal-buf_node.c

Produce executable gal-buf on each computer of the VPM:

mpcload -het -o gal-buf gal-buf.c -lm -host -L/usr/openwin/lib -lX

xxxx xxxx xx x xxxxxxx xxxxxx xxxxxx xxx xxxxxxxxx xx xxx xxxx xxxxxxxxxxx xx x xxxxxxxxx xxxxxxxxx xxxx /xxx/xxxxxxx/xxx, xxx xxxx xxxxxxxxx xxxxxxx. xxx xx xxxxxx xxxxxxxxx xxxx xxx xx xxxxxxxxx (x.x., xxx xxx xxxxxx xxxx xxx xxx x xxxxxxx; xx xxx xx xxxxx xx xxxxxxxxx xxxx).

Launch the application:

mpcrun gal-buf -- input_file

xxx xxxx xxxxx_xxxx xxxxxxxx xxxxx xxxx xxx xxx xxxxxxxxxxx.

Note that the absolute name of the input file should be used if it is stored in a directory different from the directory which was the current directory when you were opening your VPM.

Parallel Computing on Heterogeneous Networks
Parallel Computing on Heterogeneous Networks (Wiley Series on Parallel and Distributed Computing)
Year: 2005
Pages: 95 © 2008-2017.
If you may any questions please contact us: