Re: GNAT compiler switches and optimization



On Mon, 23 Oct 2006 19:11:51 +0200, Warner BRUNS wrote:

Georg Bauhaus wrote:
On Mon, 2006-10-23 at 14:40 +0200, Warner BRUNS wrote:

A problem with Ada is that the memory layout of multidimensional arrays
is not specified in the standard. If you want to have the same memory
layout for all Ada compilers, you have to specify that a multimensional
array should follow the convention of a foreign language, eg. Fortran.

Will a memory layout cast in source really help with e.g. all
Ada X Fortran combinations of compilers and libraries?
It might disallow "knowledgeable" compilers to choose a layout
that suits the current setup, I'd think, and require touching
the sources.

-- Georg

It will help with all Ada/ Fortran Compiler combinations,
but the really strange thing is that the memory layout is not
definitely known from the Ada source alone, if it is not specified
as being the layout as required by a different language, eg. Fortran.
If one wants to code a cache aware algorithm for eg. multiplying
matrices, one cannot do this in Ada without enforcing the memory
layout of the matrices via PRAGMA CONVENTION.

A agree that it seems like an omission from the Ada standard.
This specification should be available using a representation
clause. Telling the compiler to allocate it like Fortran
would is the wrong way, logically.

Of course, if it really mattered, you could use an array of arrays
(like in C), or an array of array accesses. With appropriate
use of pragma representation you have a very high degree of flexibility.

Compare this to almost any other language, and you find Ada leads
the field by a mile. What if you wanted an alternative layout
in Fortran? Or C++?

Sometimes I'd like to see some intermingling of row/column ordering,
so a page in memory holds a square sub-array of a 2-D array.
The approach I'll take (if I get around to it!) is to use a
2-D array of acceses, allocated (by a pool allocator) with the
desired pattern. Moral of the story: One Size does not Fit All...
--
Adrian

.



Relevant Pages

  • Memory limits in Ada where Fortran has none
    ... How do I increase the heap size, if at all possible, or the main memory ... In GNU f77, the array allocates and works fine, so I thought to import ... Overall, Ada being the language for large systems, I found it ... surprising that Fortran can allocate enough arrays to fill in my ...
    (comp.lang.ada)
  • Re: RX4640
    ... > layout is sparse. ... > because currently we allocate a vm_page array that needs to be ... When a machine has only 2BG of memory, ... I think I'm gonna wait for some time until you guys will fix it ...
    (freebsd-hackers)
  • Re: GNAT compiler switches and optimization
    ... If you want to have the same memory ... Ada X Fortran combinations of compilers and libraries? ... It might disallow "knowledgeable" compilers to choose a layout ...
    (comp.lang.ada)
  • Re: C array to ada record interface
    ... > memory) as the original C array. ... > will get a Constraint_Error if you try to use the Ada array. ... > Ada compiler will manage the memory for the Ada array for you, ...
    (comp.lang.ada)
  • Re: Size of any Data Type?
    ... >> over-write uninitialized memory, causing a buffer overflow. ... Ada provides automatically defined attributes for data types. ... an array containing 8 boolean elements ...
    (comp.programming)