comp.lang.ada
 help / color / mirror / Atom feed
* AW: GNAT compiler switches and optimization
@ 2006-10-23 12:46 Grein, Christoph (Fa. ESG)
  2006-10-23 17:06 ` Warner BRUNS
  0 siblings, 1 reply; 5+ messages in thread
From: Grein, Christoph (Fa. ESG) @ 2006-10-23 12:46 UTC (permalink / raw)
  To: Warner BRUNS, comp.lang.ada

Warner BRUNS claimed:

> A problem with Ada is that the memory layout of a twodimensional array
is
> not specified in the Ada Standard.

That's wrong:
  Ada is row-first order         (1, 1) (1, 2) etc.,
  Fortran specifies column-first (1, 2) (2, 1) etc.

This is what the pragma Convention is for.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: AW: GNAT compiler switches and optimization
  2006-10-23 12:46 AW: GNAT compiler switches and optimization Grein, Christoph (Fa. ESG)
@ 2006-10-23 17:06 ` Warner BRUNS
  2006-10-23 17:42   ` tmoran
  0 siblings, 1 reply; 5+ messages in thread
From: Warner BRUNS @ 2006-10-23 17:06 UTC (permalink / raw)


Grein, Christoph (Fa. ESG) wrote:
> Warner BRUNS claimed:
> 
>> A problem with Ada is that the memory layout of a twodimensional array
> is
>> not specified in the Ada Standard.
> 
> That's wrong:
>   Ada is row-first order         (1, 1) (1, 2) etc.,
>   Fortran specifies column-first (1, 2) (2, 1) etc.
> 
> This is what the pragma Convention is for.
I might be wrong, but my understanding is that the memory layout is not specified
in the standard. Can you point me to the section of the standard which specifies
the memory layout of a multidimensional array?
To me it seems as if you can only count on a specific memory layout if you
specify it to be the layout of a non-Ada languag, eg Fortran.
Strange indeed for a standard.

Warner



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: AW: GNAT compiler switches and optimization
  2006-10-23 17:06 ` Warner BRUNS
@ 2006-10-23 17:42   ` tmoran
  2006-10-23 19:14     ` Robert A Duff
  0 siblings, 1 reply; 5+ messages in thread
From: tmoran @ 2006-10-23 17:42 UTC (permalink / raw)


>I might be wrong, but my understanding is that the memory layout is not specified
>in the standard. Can you point me to the section of the standard which specifies
>the memory layout of a multidimensional array?
  ARM 3.6.2(11) "An implementation should normally represent a
multidimensional array in row-major order, consistent with the notation
used for multidimensional array aggregates (see 4.3.3).  However, if a
Pragma Convention(Fortran, ...) applies to a multidimensional array type,
then column-major order should be used instead ..."
  It would be strange to include powerful rep spec capabilities to define
everything about layouts, but not how an array is stored.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: AW: GNAT compiler switches and optimization
  2006-10-23 17:42   ` tmoran
@ 2006-10-23 19:14     ` Robert A Duff
  2006-10-23 20:29       ` Jeffrey R. Carter
  0 siblings, 1 reply; 5+ messages in thread
From: Robert A Duff @ 2006-10-23 19:14 UTC (permalink / raw)


tmoran@acm.org writes:

>   ARM 3.6.2(11) "An implementation should normally represent a
> multidimensional array in row-major order, ...

Ah, I had forgotten that.  Thanks.

When the RM says "should", you can usually count on it being true in all
serious Ada compilers.  So why doesn't it say "shall"?  Well, it's not
really a formal requirement -- you can't write a test case that can
tell for sure which way arrays are stored.  Nonetheless, I think you
can count on this rule being obeyed -- compiler writers don't
deliberately go out of their way to cause trouble for their customers.

I certainly do not think you should start putting Convention(Fortran) on
all your performance-critical arrays, just to make sure!

- Bob



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: AW: GNAT compiler switches and optimization
  2006-10-23 19:14     ` Robert A Duff
@ 2006-10-23 20:29       ` Jeffrey R. Carter
  0 siblings, 0 replies; 5+ messages in thread
From: Jeffrey R. Carter @ 2006-10-23 20:29 UTC (permalink / raw)


Robert A Duff wrote:
> 
> I certainly do not think you should start putting Convention(Fortran) on
> all your performance-critical arrays, just to make sure!

In the case of records, the representation is up to the compiler unless 
there is a representation clause. I don't find it surprising that the 
same is true of arrays. However, as with records, there should be some 
way to specify the representation for arrays other than a pragma 
Convention for another language.

-- 
Jeff Carter
"Blessed are they who convert their neighbors'
oxen, for they shall inhibit their girth."
Monty Python's Life of Brian
83



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-10-23 20:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-23 12:46 AW: GNAT compiler switches and optimization Grein, Christoph (Fa. ESG)
2006-10-23 17:06 ` Warner BRUNS
2006-10-23 17:42   ` tmoran
2006-10-23 19:14     ` Robert A Duff
2006-10-23 20:29       ` Jeffrey R. Carter

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