comp.lang.ada
 help / color / mirror / Atom feed
From: gautier_niouzes@hotmail.com
Cc: nma@12000.org
Subject: Re: is having a complex type as built-in the languages vs. being in standard package makes performance difference?
Date: Wed, 16 May 2012 12:26:03 -0700 (PDT)
Date: 2012-05-16T12:26:03-07:00	[thread overview]
Message-ID: <20740926.1138.1337196363119.JavaMail.geo-discussion-forums@vbyg17> (raw)
In-Reply-To: <jp0rf3$5kq$1@speranza.aioe.org>

Le mercredi 16 mai 2012 20:25:38 UTC+2, Nasser M. Abbasi a écrit :

> Just a basic question for the experts.
> 
> Ada provides complex data types by a package:
> 
> http://progopedia.com/language/ada/
> 
> "Ada provides complex datatype, which requires using
> packages Generic_Complex_Types and Generic_Complex_Elementary_Functions
> and instantiating them with the type of complex number to use"
> 
> While a language like Fortran, complex type is 'built-in' the
> language, i.e. part of the language intrinsic data types.
> 
> What I wondered about is: would this makes a difference when it comes
> to the performance of generated code that uses these types in
> computations?
> 
> i.e. Would the code generated by the compiler by more 'efficient'
> somehow if complex was built-in vs. being provided by a package,
> or do you think by the time the compiler is done with the code
> generation and optimization, then this all becomes irrelevant
> 'similar' compiler backend generated code will eventually
> result in terms of efficiency of the computation?

The chances are better to have efficient machine code when operations on those types are built-in. The good news is that is is possible even by having to reference a package, thanks to the pragma Intrinsic; see GNAT's package Interfaces. The fact that a type is immediatly visible or not doesn't change things.
For what matters the Complex types, the pragma Inline on the operators, plus the optimizations, are probably sufficient. Did you try to time the same algorithms with gfortran and gnat (with -gnatpn) and switch on -O3, the SSE options etc. on both ?

> (It might be possible actually to see this using gcc since
> it supports both gnat and gfortran as front end?).

Sure: compile with -S compile option to keep the assembler output.
_________________________ 
Gautier's Ada programming 
http://sf.net/users/gdemont



  parent reply	other threads:[~2012-05-16 19:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-16 18:25 is having a complex type as built-in the languages vs. being in standard package makes performance difference? Nasser M. Abbasi
2012-05-16 19:23 ` Georg Bauhaus
2012-05-16 21:08   ` Jerry
2012-05-16 21:33     ` georg bauhaus
2012-05-17  1:48       ` Isaac Gouy
2012-05-16 19:26 ` gautier_niouzes [this message]
2012-05-17  0:19 ` Randy Brukardt
replies disabled

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