1. BRIEF DESCRIPTION OF THE APPLICATION

Let us consider an irregular application simulating the evolution
of a system of stars in a galaxy (or set of galaxies) under the
influence of Newtonian gravitational attraction.

Let our system consist of a number of large groups of bodies. It
is known, that since the magnitude of interaction between bodies
falls off rapidly with distance, the effect of a large group of
bodies may be approximated by a single equivalent body, if the
group of bodies is far enough away from the point at which the
effect is being evaluated. Let it be true in our case.

So, we can parallelize the problem, and our application will use
a few virtual processors, each of which updates data
characterizing a single group of bodies. Each virtual processor
holds attributes of all the bodies constituting the corresponding
group as well as masses and centers of gravity of other groups.
The attributes characterizing a body include its position,
velocity and mass.

Let the application display the result of the galaxy evolution on
the host workstation in graphical form. 

Finally, let our application allow both the number of groups and
the number of bodies in each group to be defined in run time and
display their evolution.

The application implements the following scheme:

    Initializing the galaxy on the virtual host-processor

    Creation of network 'g'

    Scattering groups over virtual processors of network 'g'

    Visualization of the galaxy on the virtual host-processor

    Parallel computing masses of groups

    Interchanging the masses among virtual processors of 'g'

    while(1) {

      Parallel computation of centers of gravity of groups

      Interchanging the centers among virtual processors of 'g'

      Parallel updating groups

      Gathering groups on the virtual host-processor

      Visualization of the galaxy on the virtual host-processor

    }


2. DYNAMIC LOAD BALANCING

Automatic network 'g', executing most of computations and
communications, is defined in such a way, that it consists of 'M'
virtual processors (variable 'M' holds the number of groups of
bodies), and the relative performance of each processor is
characterized by the number of bodies in the group which it
computes.

So, the more powerful is the virtual processor, the larger group
of bodies it computes, and the more intensive is the data
transfer between two virtual processors, the shorter link
connects them (length specifier 'length*(-1)' specifies a shorter
link than 'length*1' does).

The mpC programming environment bases on this information to map
the virtual processors constituting network 'g' into the
processes constituting the entire computing space in the most
appropriate way.


3. FORMAT OF THE INPUT FILE

Input data consist of two lines. The first line specifies the
number of groups in the galaxy and has the following format:

Number of groups = <the_number_of_groups_in_the_galaxy>

The second line specifies the number of bodies in each group. The
line has the following format:

Group sizes = <the_number_of_bodies_in_the_first_group> ...

If no file name is passed to the application as a parameter, the
following input file is assumed:

Number of groups = 5
Group sizes = 200 100 400 200 600


4. HOW TO RUN THE APPLICATION

Let the virtual parallel machine to run the application has been
already opened. To produce two target C files - the first for
the virtual host processor executing code displaying the galaxy
in the graphical form, and the second for the rest of virtual
processors not involved in graphical representing the galaxy, it
is necessary to type:

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

Note. Use the absolute application name if 'gal-buf.mpc' is not
in the current directory. Use directory other then
'/usr/openwin/include' if necessary (that is, use the directory
where X Windows system holds its include files on the host
workstation).
 
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, it is necessary to
copy them into the $MPCLOAD directory:

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

To broadcast these files from the host workstation to all
workstations constituting the distributed memory machine, it is
necessary to type:
 
mpcbcast gal-buf_host.c gal-buf_node.c

To produce executable 'gal-buf' on each workstation of the
distributed memory machine, it is necessary to type:

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

Note. Use a directory other then '/usr/openwin/lib' if necessary
(that is, use the directory where X Windows system holds its
libraries on the host workstation). Use an option other then
'-lX' if necessary (that is, use the proper name for the X
library; it may be '-lX11' or something else).

Finally, to run the application, it is necessary to type: 

mpcrun gal-buf -- <input_file>

if you wish to pass your own galaxy to the application

or

mpcrun gal-buf

to use a default galaxy.

Note. Use the absolute name of the input file if it is placed in
a directory other then the directory which was a current
directory when you open your virtual parallel machine.
