next up previous
Next: The listing of Up: The LAM companion to Previous: Summary

Lesson 6 -- Datatype constructors and collective communications

Amongst the greatest conveniences provided by modern programming languages such as C, C++, or Common Lisp, is the ability to structure data. This is particularly useful in codes which deal with ensembles of structurally rich items characterised by some degree of irregularity.

In modern AI programs a single richly structured data item may represent an autonomous identity, an agent, equipped with its own reasoning engine, its own data base, and a variety of sensors and communication channels. Agents may interact with one another, and well documented examples exist of agents turning against their own programmer and taking over computer systems and networks. Not even pulling the plug on a single machine can quell the mutiny, if agents have been clever enough to distribute themselves over a number of CPUs and sites.

Particle codes are a good and simple enough example of the use of elementary data structures in scientific computing. In particle codes, it is convenient, although not necessarily most efficient, to represent each particle by a structure, which contains information about a position, velocity, mass, and some other field parameters associated with the particle. If particles are to be ordered, for example, to form a linked list, the structure may also contain a pointer to the next particle in the list. Here is an example of a particle structure from one of my codes:

typedef struct {
   float x, y, z;
} SPH_Vector;
 
typedef struct SPH_List *SPH_Pointer;
 
typedef struct SPH_List {
   SPH_Vector r;      /* position */
   SPH_Vector v;      /* velocity */
   float f;           /* scalar field */
   SPH_Vector df;     /* scalar field gradient */
   float m;           /* mass */
   float rho;         /* density */
   float f_by_rho_2;  /* f / rho^2 */
   SPH_Pointer next;  /* pointer to the next particle */
   int my_box;        /* a box number in configuration space */
} SPH_Particle;
This particle is actually a rather simple one. It does not have a spin, isospin, colour, fermion number, wave function, or any of the other attributes that make working with elementary particles such fun.

Nevertheless, in context of parallel programming, and especially in context of programming a heterogeneous farm, an important issue arises: how to transmit such a structure between CPUs. This problem is further complicated by the possibility that various slots in the structure may have different size on different machines.

MPI provides a rich set of primitives, described in section 3.12 of ``MPI: A Message-Passing Interface Standard'', which assist in construction and transmission of richly structured data items between MPI nodes, even if the nodes themselves have a varied architecture.

In this lesson we shall demonstrate how to evaluate gravitational interactions between about a 1000 particles. Apart from flagging the issues mentioned above we shall also demonstrate the use of some new collective communication functions.

This lesson is based on a program discussed in chapter 5, ``Advanced Message Passing in MPI'', of ``Using MPI...''.

The program used in this lesson is a little simpler: we only evaluate the force and exit. It can be obtained by ftp anonymous from cisr.anu.edu.au, directory pub/papers/meglicki/mpi/advanced, file ninth.c. You will also have to transfer a file preamble.c from the same directory, if you don't have it yet. That file is also listed in section 4.1.





next up previous
Next: The listing of Up: The LAM companion to Previous: Summary



Zdzislaw Meglicki
Tue Feb 28 15:07:51 EST 1995