Home/Ada Projects

Ada Flyer Supercomputing in
Astrophysics with
Ada 95

Combining Object-Orientation and Parallel Computing

by Dr. Martin J. Stift, Associate Professor
Institut für Astronomie Wien, Austria
Astrophysical Computing: A Study in FORTRAN Dominance
For more than three decades, astrophysics has lived under the almost undisputed domination of Fortran. Many of the astrophysical codes developed in early times and written in the most archaic Fortran versions are still in use for large-scale computations; the latest revision and the impending update of the Fortran standard have hardly influenced the programming habits of most astronomers. In the field of computational astrophysics, modern software-engineering concepts are widely unknown as are most modern programming languages (ask the average astronomer about Ada, Eiffel, Smalltalk ...) and high-performance computing in any programming language has had little impact so far. A vast abyss separates the Grand Challenge codes from the bulk of the programs used in astrophysical modelling.

Astronomers take pride in strange habits: they measure distances in parsecs or astronomical units, wavelengths in Angströms, energy output in magnitudes, etc. Astronomers revel in those practically uncommented and unstructured line synthesis codes full of computed and assigned "goto's", arithmetic "if's" and Hollerith constants. Their collective memory is stuffed with the weirdest experiences of minor modifications of large (and unstructured) Fortran codes resulting in inexplicable errors propagating throughout seemingly unmodified parts. Astronomers mostly accept this as an integral part of life.

The Need for Change
Even Fortran hardliners realise that progress in computer hardware makes it advisable to abandon some of the most venerable language constructs such as the COMMON. And rumour has it that for the first time in history the Fortran standard revision will lead to the abandonment of language features. (Will it be the Hollerith constant?) The mounting complexity of (astro)physical models makes methods and languages of the 50's and 60's become obsolete rapidly. Should one continue to cling to increasingly outdated computing tools?

Working in the field of polarised radiative transfer in stellar atmospheres, I was faced with the bleak prospect of ending up with an unreadable and increasingly unmodifiable Fortran77 code whose constituent parts would be unfit for reuse. I considered Fortran90 not powerful enough and C++ too unsafe, so I chose Ada.

The Transition to Ada
At the time I adopted Ada for my future work (early 1994), the features of the Ada 9X standard, that was to become Ada 95, had begun to emerge. Unlike Fortran90, Ada 83 already offered genericity, concurrency, and exception handling; Ada 95 promised inheritance, polymorphism, programming by extension, distribution. I was seduced by the rigour of this language and by its elegance. Still, would Ada really be advantageous for scientific programming with codes of the typical size of a few thousand lines of code (kLOC)? You need a lot of courage (and tenure) to embark on this adventure.

Of course, it worked out splendidly. A code modification that I had had to abandon in Fortran after weeks of hard work, took just about two days in Ada. It would almost appear that Jean Ichbiah and the countless people who have contributed to the Ada standard had exactly identified my needs. The Zeeman Feautrier formal solver, a nightmare for the Fortran programmer, was written and tested by a student in just one day. The transition to Ada was smooth, painless, and highly rewarding -- rather than disruptive and counterproductive, as expected by some collegues. And gratifyingly, the Ada code performed as well in speed as the Fortran code.

The transition from Ada 83 to Ada 95 involved even less effort. I could convert my codes to Ada 95 at a rate of several kLOCs per hour! Of course, I later took advantage of the new features of Ada 95 to improve the existing codes. Software reuse is at the centre of my efforts, made possible by the extensive use of generics and of child libraries.

Parallel Computing with Ada 95
Most (astro)physicists believe that, despite its shortcomings, you have to use Fortran on present and future massively parallel computers because of the parallel capabilities of High Performance Fortran (HPF). (Until recently, you could not find Ada on the Web sites dedicated to parallel computing, but this has changed.) People are not aware of the power of the concurrent features of the Ada language, i.e., task objects and protected objects, and nobody seems to have realised that, with the GNU Ada 95 Translator (GNAT) compiler on a Silicon Graphics Power Challenge or Origin server, you can actually carry out parallel computations with Ada 95.

Coming back to my field of research, there have been few if any attempts at parallelisation of existing stellar atmosphere and (polarised) line synthesis codes. Indeed, it is not obvious how to take full advantage of the data-parallel HPF features for these kinds of problems when you don't have large arrays on which to apply standard operations. Ada tasks, however, are eminently suitable because when you synthesise a stellar spectrum at some wavelength point, you can do it independently from the neighbouring point -- there is no coupling.

So it is quite natural to put the whole sequence of operations involved in the calculation of the emerging spectrum -- opacity sampling, solving the equation of radiative transfer, 2D integration over the visible hemisphere of the star -- into a task. On a symmetric multiprocessing machine, several tasks attached to different processors access a common passive memory and execute a loop in which the procedure is called to calculate continuum intensity and Stokes parameters at some wavelength. There is an absolute minimum of communication between the tasks, which is done with the help of protected objects. One has merely to keep track of the wavelength position and its running number to make sure that each position is calculated only once and to detect the end-of-profile condition. Varying load on the different processors is no problem, but will result in out-of-order execution and necessitates a final sort.

For a sequential code to become a parallel one, very little change is required. In a code of 3.5 kLOC size, just 14 expressions (localised in two places) have to be changed, with a concomitant increase in the code size by some 16 expressions! Two small reusable (generic) packages containing the protected types have to be added (some 100 expressions). With only two compiler pragmas deleted, the SGI Power Challenge version of the code runs on any PC -- that's transportability at its best, and you get the compiler for free! Would anyone be prepared to claim the same for HPF?

A number of people have contributed to this first successful large-scale application of Ada to (astro)physical problems. In particular I want to thank G. Könighofer (Swing Informationssysteme GmbH, A-1130 Wien) for introducing me to the world of Ada and putting the large Swing Ada class library at my disposal. Mag. R.M. Fensl has contributed elegant astrophysical code, demonstrating that students can do better with Ada than with Fortran. And, of course, thanks are due to Prof. Strohmeier (Laboratoire de Génie Logiciel, EPF Lausanne) for advice and encouragement. Lack of funding made me appreciate these two splendid compilers, even more than I already did: the free GNAT compiler under Linux and Irix, and a free sample of the Aonix Academic AdaMagic compiler.
For More Information
Dr. Martin J. Stift
Associate Professor
Institut für Astronomie
Türkenschanzstrasse 17
A-1180 Wien, Austria
Tel: 43 (1) 470 68 00 35
Fax: 43 (1) 470 68 00 15
Email: stift@astro.ast.univie.ac.at

Dr. Stift's original publication, "High Performance Scientific Computing with Ada 95," is available at http://amok.ast.univie.ac.at/~stift/parallel.html.

Copyright 1996. IIT Research Institute
All rights assigned to the US Government (Ada Joint Program Office). Permission to reprint this flyer, in whole or in part, is granted, provided the AdaIC is acknowledged as the source.
Form U226 astro.txt

Home Webmaster Last Updated: 08/11/98