comp.lang.ada
 help / color / mirror / Atom feed
From: "John B. Matthews" <nospam@nospam.invalid>
Subject: Re: Basic question on Ada multi-dimensional arrays, are they true (contiguous) arrays? aliasing rules?
Date: Wed, 21 Dec 2011 14:11:40 -0500
Date: 2011-12-21T14:11:40-05:00	[thread overview]
Message-ID: <nospam-C0D037.14114021122011@news.aioe.org> (raw)
In-Reply-To: jcrbhs$9q6$1@speranza.aioe.org

In article <jcrbhs$9q6$1@speranza.aioe.org>,
 "Nasser M. Abbasi" <nma@12000.org> wrote:

> Sorry for such a basic question on Ada, it has been a while since I 
> used Ada (but it remains my most favorite computer language).
> 
> We know that Fortran stores multi-dimensional arrays in a contiguous 
> sequence of memory, and Fortran has strong aliasing rules which 
> allows the compiler to more generate more efficient code when it 
> comes to Matrices access and manipulation and such. This is one 
> reason that Fortran code is fast for number crunching.
> 
> How is the situation in Ada when it comes to this issue? I am almost 
> sure that Ada 2D/3D matrices are also contiguous in memory (as 
> compared to say Java for example).

I'm not sure the standard [1] says exactly how array components (§3.6) 
must be stored, only that "all have the same subtype." Unchecked type 
conversion (§13.9) suggests contiguous representation of components 
for meaningful use. I'm not an implementor, so I'd welcome correction.

> If so, how is the issue with aliasing rules? I read that c99 has now 
> a keyword called 'restrict' which is supposed to tell the compiler 
> that some arrays do not overlap in memory and the compiler can 
> generate efficient code like Fortran.
> 
> So my question really is: Is Ada generated code now for 2D/3D 
> matrices operations as efficient and Fast as Fortran?  Are there 
> switches for Gnat that one can use to improve this aspect of the code 
> generation?
> 
> Are there are benchmarks comparing Ada for Fortran in this specific 
> area?

This response [2] to a similar question has a few relevant links. At 
least one Ada compiler implements parts of its standard library by 
linking to well-know Fortran libraries. I'm sure there are others.

> Sorry if my question might be too general and not specific, but I am 
> just only wondering on how Ada number crushing with matrices compares 
> to Fortran there days.

[1] <http://www.adaic.org/resources/add_content/standards/05rm/html/RM-TOC.html>
[2] <http://stackoverflow.com/a/2662805/230513>

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>



  reply	other threads:[~2011-12-21 19:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-21  1:08 Basic question on Ada multi-dimensional arrays, are they true (contiguous) arrays? aliasing rules? Nasser M. Abbasi
2011-12-21 19:11 ` John B. Matthews [this message]
2011-12-22  2:49   ` Jeffrey Carter
2011-12-23  7:34     ` John B. Matthews
2011-12-21 21:11 ` Adrian-Ken Rueegsegger
2011-12-21 21:13 ` Adrian-Ken Rueegsegger
replies disabled

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