We have already demonstrated that applying Fortran 90 and object-oriented programming techniques to large, and complex, scientific supercomputing applications is beneficial [1,4]. Such applications become more modular, readable, and efficient, compared to implementations in languages like C++ and Fortran 77.
Nevertheless, since using object-oriented programming techniques in Fortran 90 introduces new kinds of advanced data structures, measuring how these structures affect performance becomes important. Additionally, many applications now need to work with libraries and systems that are written in different languages, such as C++ [2], where the data structures may be organized differently yet they need to interact. Our objective is to understand these important issues since they directly affect advanced software development.
To examine the performance effect of using data abstraction features in Fortran 90 we developed a set of benchmarks (based on an electromagnetics code from Gunnar Ledfelt of KTH, Sweden) that model the 3-D field in Maxwell's Equations in a variety of ways. These include: (1) parameter passing each field component separately to the field solver (standard method), (2) bundling multiple field components into a single type that is dereferenced directly by the field solver (adt method), and (3) modifying the abstract data type (adt) method where the components are dereferenced and then passed to the field solver (adt_layer method).
To understand interlanguage communication issues, we developed codes that allow Fortran 90 objects to interact with libraries and programs written in C and C++. The applications included scientific visualization and parallel unstructured adaptive mesh refinement [3,5].
Regarding the performance of Fortran 90 advanced abstract data types, the chart below shows (with the exception of the SUN compiler) that using pointers to bundle together all features of a type into one component does not perform very well. In the worst case the performance loss is 16 times, compared to using a standard Fortran 77 approach, when the advanced data type is used. This technique adds more abstraction to the program, but the chart shows that the performance varies significantly among major compilers.
One explanation for this involves aliasing (multiple pointers referring to the same memory location). Since the compiler cannot always determine if two pointers are aliased, it must assume the worst and generate safer slower code. In Fortran 77 all memory references are unique, so compilers can generate more efficient code. This issue is well-known to users of the C programming language since the use of pointers can degrade performance.
| Fortran 90 ADT with Array Pointers | |
|
Ratio of using the F90 abstract data type (ADT) versus
the standard F77 way of passing array components
One way to address the aliasing problem, while retaining the abstraction, is to build a layer. In the layer approach the data type is passed to the layer, but the components are dereferenced within the layer. This allows the compiler to infer that ADT components don't overlap. In theory, this approach should perform as well as the Fortran 77 approach.
As seen below, the IBM, Cray T3E, Cray C90, and Absoft (Linux) compilers performed as expected when the layer was applied, but some did not perform well (the NAG (Linux) compiler produced a core dump).
| Fortran 90 ADT_Layer with Array Pointers | |
|
|
| Vendor | ADT_Layer/Standard |
| NAG/Linux | *** Core Dumped *** |
Ratio of passing components of the F90 abstract data type (ADT) versus
the standard F77 way of passing array components
Although the Fortran 90 performance with abstract data types can sometimes be poor, we decided to compare this performance to an equivalent implementation in C++ (for machines where C++ was available). We see that in this case, the Fortran 90 performance still outperforms C++ in this application, sometimes significantly.
| C++ Abstraction Performance Compared to Fortran 90 | |
|
Ratio of C++ performance to Fortran 90 performance using
both the passing approach and abstract data types
Regarding interlanguage communication of Fortran 90 and C++ objects, we have determined how to handle: (1) simple parameter passing of variables and standard types, (2) advanced parameter passing of user defined objects/structures and techniques for handling objects with virtual functions, (3) parameter passing with library codes where the source is not accessible (such as MPI, and X-Windows), and (4) construction of interfaces for interlanguage communication (such as visualization systems in collaboration with Joan Slottow, UCLA).
Visit this Web site for more detailed information on these topics.
Understanding the performance implications of using abstract data types in Fortran 90 is extremely important. If using abstractions to model sophisticated scientific programs introduces serious performance penalties, then techniques must be introduced to improve performance. This work is the first time that such issues have been identified regarding Fortran 90 and abstraction modeling in scientific computing. These results directly impact how compiler developers implement the standard and how Fortran 90 will be used by application scientists.
Many applications must now rely on features provided by systems written in other languages. Therefore, understanding interlanguage communication issues for object interaction among Fortran 90, C, and C++ has become essential. We demonstrated how objects can be parameter passed and used in a multi-language context between software and libraries where the source may not always be accessible. This extends the ways in which Fortran 90 can interact with other software systems.
We will continue to investigate constructs that cause performance penalties because; while this is often vendor-dependent, a complete understanding of this issue is critical to applying advanced data structures to large application development. Additionally, we will study and suggest techniques to enhance performance when abstract data types are used. The interlanguage communication issues between Fortran 90 and C have been defined as part of the Fortran 2000 standard, but understanding the performance implications of communication between Fortran 90 and C++ objects will be investigated further. These results will be applied to the performance analysis of projects that are using Fortran 90 and interlanguage communication, such as 2-D and 3-D parallel unstructured adaptive mesh refinement.
Viktor K. Decyk
NASA Jet Propulsion Laboratory
vdecyk@olympic.jpl.nasa.gov
818-393-2690
Charles D. Norton
NASA Jet Propulsion Laboratory
Charles.D.Norton@jpl.nasa.gov
818-393-3920