comp.lang.ada
 help / color / mirror / Atom feed
From: Dale Stanbrough <dale@goanna.cs.rmit.EDU.AU>
Subject: Re: Ada-95 for numerics?
Date: 1996/04/02
Date: 1996-04-02T00:00:00+00:00	[thread overview]
Message-ID: <4jqcqp$mpk@goanna.cs.rmit.edu.au> (raw)
In-Reply-To: 4jocek$h5h@rigel.rz.uni-ulm.de

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.




  parent reply	other threads:[~1996-04-02  0:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-04-01  0:00 Ada-95 for numerics? Joerg Rodemann
1996-04-01  0:00 ` Robert Dewar
1996-04-02  0:00   ` michael
1996-04-01  0:00 ` Ted Dennison
1996-04-01  0:00   ` Robert Dewar
1996-04-02  0:00 ` Dale Stanbrough [this message]
1996-04-03  0:00 ` Robert I. Eachus
  -- strict thread matches above, loose matches on Subject: below --
1996-04-02  0:00 Jean-Pierre Rosen
1996-04-03  0:00 ` Robert I. Eachus
1996-04-02  0:00 Joerg Rodemann
1996-04-02  0:00 ` Robert Dewar
1996-04-05  0:00  Dr J Parker
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox