The Cogito tools are object-oriented. The implementation is in Fortran 90, using MPI for the message passing. Code based on the Cogito routines is portable over a wide range of computers, serial and parallel. The tools raise the level of abstraction in the code considerably. Moreover, they make it fairly straightforward to write a composite-grid code which can be executed e.g. on a multicomputer.
Cogito can execute on all platforms that support MPI. Code based on Cogito has been executed (without modification) on a cluster of DEC Alpha Server 8200, on IBM SP/2 and on Cray T3D & T3E.
Cogito handles structured grids, individual grids as well as composite ones. It also handles grid functions on such grids. Moreover, there are operations that make it possible to express finite difference methods. The parallelism is of SPMD type, i.e., all processors execute the same code, but asynchronoulsy and on different subsets/partitions of the data. Cogito contains tools for automatic partitioning and distribution of composite (and individual) structured grids. Each grid function automatically gets the same distribution as the corresponding grid.
Cogito has an object-oriented design. This has several advantages. In the present context, information-hiding--leading to portable and easily maintainable code--should be mentioned. Moreover, this kind of design tends to yield a good modularization, and fairly small software parts (operations on classes) that can be combined in a flexible way. Finally, object-oriented software focusses on concepts in the application domain. This increases the readability of the code.
A Grid object represents a single, structured grid. A Composite grid is a union of a number of such grids. Finally, when a Grid Function object is created, the corresponding grid (single or composite) will be given as a parameter. The grid function will automatically have the same structure as the related grid.
In order to distribute a grid, a Distribution object is attached to it. All its grid functions will then be distributed in the same way as the grid itself.
Each class has a number of operations defining its public interface. For example, difference operators can be applied to objects of the class Grid Function. Other operations on this class are Number of variables, Copy, Add, Scale, Saxpy, etc.
All classes have operations Create and Delete, for the creation and deletion of an object, respectively.
include `cogito.h' integer SIZE parameter(SIZE=10000) integer memory(SIZE)
The first executable statement in a program using Cogito should be a call to the routine SetupCogito:
call SetupCogito(memory,SIZE,fileName)
There are three parameters: an array representing the dynamic memory, an integer, which is the size of this memory, and the name of the executable file. The size of the memory vector must be chosen so that all data in the objects created with Cogito can reside within the memory vector. Some extra space must also be allocated so that the descriptions of the objects can be stored. Remember that, for example, a double precision number occupies the same space as two integers.
Before a program using Cogito ends, the routine ExitCogito should be called:
call ExitCogito(memory)
At present, three platforms are supported: Intel's NX message passing library (Intel iPSC/2, iPSC/860, Paragon), IBM's MPL message passing library (IBM SP1, SP2), and PVM. The parameter fileName is at present only used by the PVM version.
In the PVM version, SetupCogito starts the virtual machine, by spawning the required number of processes. The program to spawn is located in the file given by the parameter fileName.
The user only needs to create a file PVMmachines containing the number of hosts, the number of tasks, and a listing of the computers that are to be included in the virtual machine. The first computer must be the one where the program starts. This file can also work as a PVM hostfile (see the PVM documentation for further information). We illustrate this by an example.
Example. Assume that the PVM-based Cogito library is to be executed on a cluster of work stations. The work stations in question are referred to by the following names: electra, dabih, toliman, heze, gredi, rana. The program should be started on the work station electra. The file PVMmachines could then have the following contents:
#hosts=6 #tasks=6 electra dabih toliman heze gredi rana
(See the PVM documentation for further information on alternative ways of specifying which computers to include in the virtual machine.) The first executable statement in the user's program is:
call SetupCogito(memory,SIZE,fileName)This initializes both Cogito and PVM.
To exit Cogito and PVM:
call ExitCogito(memory)N.B.: Because SetupCogito simplifies the initialization of PVM, calling this routine could be useful also to persons who intend to use PVM directly.
subroutine SetupCogito(memory,size,fileName)
integer memory(*)
integer size
character*(*) fileName
memory IN/OUT The memory vector.
size IN The declared size of the memory vector.
fileName IN The name of the executable file to spawn when
using PVM.
subroutine ExitCogito(memory)
integer memory(*)
memory IN/OUT The memory vector.