From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,35ed85a9d92a025 X-Google-Attributes: gid103376,public From: Dale Stanbrough Subject: Re: Ada-95 for numerics? Date: 1996/04/02 Message-ID: <4jqcqp$mpk@goanna.cs.rmit.edu.au> X-Deja-AN: 145358000 distribution: world references: <4jocek$h5h@rigel.rz.uni-ulm.de> content-type: text/plain; charset=ISO-8859-1 x-xxmessage-id: organization: Royal Melbourne Institute of Technology mime-version: 1.0 newsgroups: comp.lang.ada Date: 1996-04-02T00:00:00+00:00 List-Id: Joerg Rodemann writes: "My questions now are the following: a.) Has anybody out there used/tested Ada for similar problems? What were the results? b.) What is the reason for the slow down? Especially if suppressing all checks still leaves a factor of 2...what is the runtime system doing with the extra time? c.) Is this a GNAT specific result or do the commercial compilers show the same behaviour? d.) Is there a way to speed up the program? Perhaps without suppressing all checks? (It seems somewhat brute to take away a lot of those things that are real advantages of Ada...)" ---------------------------------------------------- The following was posted by Bevin Brett, a long time Ada-83'er at Digital... (Bevin, come back, all is forgiven! :-) Hope it helps. Dale -------------------------------------------------- From: brett@ada9x.enet.dec.com (Bevin R. Brett) Newsgroups: comp.lang.ada Subject: Fortran and Ada, a partial answer Date: 14 JUL 94 15:26:21 EST I have been asked to comment on the relative performance of algorithms coded in Ada and in Fortran. This question has come up repeatedly over the years, and deserves a complete answer, rather than a simplistic one. There are many factors which influence the size and execution speed of the running program, and they all play together to get a full answer. I shall then discuss an exact Ada v. Fortran comparison that Digital was involved in. First, a position statement: The variation between Ada and Fortran is less than the variation within the language caused by the exact implementation details. A person versed in the Ada issues should do as well in Ada as a person versed in the Fortran issues will do in Fortran. The size and execution speed of the result should be within a few percent of each other. (a) Differences due to the compiler In the case of the DEC Ada and Fortran compilers, the optimizer and code generator are the same. Never-the-less, the exact inputs into the optimizer and code generator may differ slightly when the same algorithm is compiled by the Ada and Fortran compilers, and this can result in major differences in the generated code. In these cases the compiler front ends can usually be modified to correct the slower one. We have not observed any major differences in generated code quality between the DEC Ada and DEC Fortran compilers caused by such issues. (b) Differences due to the language It is very important that the same algorithm be written in the two languages. The biggest differences we have observed are i. Having the wrong dimension varying fastest, since it is desireable to have the first dimension changing fastest in Fortran, and the last dimension in Ada. Thus when an algorithm is transliterated, the array indexes must be reversed. ii. Using compile-time-known bounds for arrays in Fortran, and using unconstrained arrays in the Ada code. Knowing the exact values of the dimensions at compile-time results in much better code. iii.Not suppressing all the runtime checks in Ada. The Fortran compiler assumes all array bounds are in range, and all arithmetic operations do not overflow. You must use a pragma Suppress to tell this to the Ada compiler as well. iv. Don't use arrays of Ada Booleans to match arrays of Fortran Integers, because accessing bytes on a RISC system might be much worse than accessing fullwords. (c) Differences due to the bindings The biggest bindings differences are related to Fortran's built-in support for complex types, and for various math routines such as SQRT and SIN, compared with Ada code that often uses hand-coded or ISO standardised versions of these functions with different requirements than are imposed on the Fortran versions. DEC Ada has built-in support for complex types, and also has bindings directly to the same primitives that Fortran uses for its math routines and so gets the same performance as Fortran does. (d) Differences due to the author The use of good Ada and Fortran style can also effect the generated code. Provided the author writes in good Ada style, and follows the above guidelines, the generated code should do as well as Fortran.