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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no 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: eachus@spectre.mitre.org (Robert I. Eachus) Subject: Re: Ada-95 for numerics? Date: 1996/04/03 Message-ID: #1/1 X-Deja-AN: 145510747 references: <4jocek$h5h@rigel.rz.uni-ulm.de> organization: The Mitre Corp., Bedford, MA. newsgroups: comp.lang.ada Date: 1996-04-03T00:00:00+00:00 List-Id: In article <4jocek$h5h@rigel.rz.uni-ulm.de> rodemann@mathematik.uni-ulm.de (Joerg Rodemann) writes: > 6.) Using pragma Suppress (All_Checks) in the tred2 routine still left > the Ada program a factor of 2 behind the other ones. First a caution. Remember to check that the suppression is really valid on the actual data sets. If your matrices are, by their nature well conditioned you don't have a problem. But in the FORTRAN, C and Ada with suppression cases you will get junk answers with no warning for some inputs. Okay, now to the "fun stuff." > a.) Has anybody out there used/tested Ada for similar problems? What were > the results? That factor of two is probably real, and is often seen. The issue is a residue of the exception checking. The Ada code for matrix operations often has to create a matrix value as a temporary, then copy it to the final location. If you know how, you can design this out, sometimes at the cost of more storage space. The problem is that Ada code is not allowed to ignore aliasing among parameters and results. Partial results can only be written to an out variable of a scalar type if the compiler can verify that for all calls there is no aliasing to in parameters and no exceptions can be raised. Most Ada compilers just ignore the opportunity for optimization in these cases. > 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? Copying values from here to there. > c.) Is this a GNAT specific result or do the commercial compilers show the > same behaviour? I've seen it on a lot of Ada 83 compilers, including for various Crays. > 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 solution is to use intrinsics, but I don't know that GNAT supports them. In any case they would likely be hardware specific. (What you want is a machine level vector inner product operation which is indetermininate in where the overflow occurs. With hardware support and if implemented right, you can get FORTRAN speed with Ada overflow checking, even on a Cray.) > For now I will do the global program structure with Ada and call > some Fortran routines with pragma Import. By the way: I was really > surprised how easy it is to import Fortran routines. IMHO if more > languages provide such an easy to use interface perhaps there > would not be any language wars anymore. Just use the language > that is best suited for each single problem and build the whole > thing together... (Just thinking...) See above, but be very careful about the shape of your data, especially if the matrices are large. The other thing to watch is the accuracy of your results. For seriously large matrices I use fixed point with multiple precision intermediate operations to provide greater ranges. It is often very SLOW, but I have this thing about knowing that I can trust at least the first three digits of the answer. (The old saw about testing with single and double precision arithmetic sometimes works well, other times you just get two different junk results.) Another good idea, besides conditioning the matrices, is to check the values of all pivots and other divisors. If they get distant from 1.0, your accuracy goes away fast. (In one version of simplex code, i allowed the user to set the check limits on the pivots. If the pivot fell out of range, rebuild the basis. If that doesn't fix it, stop and print an error message.) Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is... -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...