Ada-MPI-3.1

Copyright notice.

Permission to use, copy, modify and distribute this software and its documentation is hereby granted without fee. The author and Southampton University disclaim all warranties with regard to this software, including all implied warranties of merchantability and fitness. In no event shall the author or Southampton University be liable for any special, indirect or consequential damages whatsoever resulting from loss of use, data or profits arising out of or in connection with the use or performance of this software.

Introduction.

These pages describe a binding from MPI to Ada95. There are in fact two bindings: thin and thick. The thin binding is dependent on the machine architecture, the operating system and the version of MPI used. It represents a translation of the C header file.  The design goals for the thin binding are:

q       It should represent a complete translation of the MPI 1.1 standard.

q       It should be easy to adapt to implementation dependent features

q       Additional features, such as those in MPI2 can be added.

 Implementers differ widely in the way they define the fundamental MPI abstractions such as communicators and datatypes. In C they are defined as opaque types and this naturally translates to the private type. We produce a thin binding for each target. The visible part is identical in each instance and only the private part is customized. Thus we have a standard API and the price of portability is recompilation. We have produced bindings for the following targets:

Machine Compiler Operating System MPI version Thin binding directory
Pentium gnat-3.13 Linux mpich Linux-mpich
Pentium gnat-3.13 Windows NT wmpi-2.0 wmpi
IBM SP2 gnat-3.10 AIX IBM SP2
Meiko-CS2 gnat-3.10 solaris mpich meiko

The thick binding is intended to give the Ada programmer a natural interface to the facilities of MPI.  To this end, we produced the following design goals:

q       To use the Object-Oriented features of Ada95 and define classes for the fundamental abstractions communicators and datatypes.

q       To provide two main tools for communication, direct with the Address attribute and by using the Ada stream attributes.

q       To give the user the choice of using the Ada exception mechanism to handle errors or to rely on the messages of the implementer.

Installation

The distribution is obtained as a zipped file and unpacking is a standard process.

The thin bindings are contained in the subdirectories shown in the above table. The subdirectory lib is for the thick binding and the first step of installation is to copy the thin binding (mpi_thin.ads) into lib.

#! /bin/bash
echo ${ADA_MPI_ARCH}
# copy machine dependent files
cp ${ADA_MPI_ARCH}/mpi_thin.ads lib/mpi_thin.ads
cd lib
echo "Compiling"
gnatgcc -O3 -c *.ads
gnatgcc -c -O3 *.adb
echo "Installation Complete"

The above script summarises the installation.

Hello World

"Hello world" is the most important program to get working because it is a rehearsal of the development system. It also shows some of the features of the thick binding.

with Mpi, Mpi.Communicators.Intra;

use Mpi, Mpi.Communicators.Intra;

procedure Hello is

Moi,

No : Integer;

begin

Mpi.Init;

-- find out rank

Moi := Rank(Comm_World);

-- find out no of processors in system

No := Size(Comm_World);

-- Prints a string preceded by the processor rank

Output(Comm_World, "Hello world");

Output(Comm_World, "My rank " & Integer'Image(Moi));

Output(Comm_World, "No of processes " & Integer'Image(No));

Mpi.Finalize;

end Hello;

Compilation is straightforward however linking requires experimentation to discover what libraries are needed by MPI.

For the mpich system, the command mpicc -show File.c gives useful clues. For the linux implementation, we used

gnatmake -I${HOME}/Ada-MPI-3.1/lib hello -largs -L/usr/lib/mpich/lib -lmpich

Running the code uses mpirun (or a similar method).