comp.lang.ada
 help / color / mirror / Atom feed
From: "jimmaureenrogers@worldnet.att.net" <jimmaureenrogers@worldnet.att.net>
Subject: Re: Allocated aligned arrays
Date: 18 Nov 2005 14:06:00 -0800
Date: 2005-11-18T14:06:00-08:00	[thread overview]
Message-ID: <1132351560.528877.151360@g49g2000cwa.googlegroups.com> (raw)
In-Reply-To: 1132349753.719540.119910@g44g2000cwa.googlegroups.com

ldb wrote:
> I'm trying to allocate two floating point (4 bytes each) arrays that
> are both address-aligned to 16. Ideally, the first element of each
> array is aligned on 16 (ie, the address mod 16 = 0), but that's not
> really necessary, as long as they are both aligned to the same mod 16
> (i don't care if the first element is 8 or 12 or whatever, as long as
> both arrays have the same).
>
> I'm trying to set up these arrays so I can use aligned SSE instructions
> in assembly.
>
> I have tried something along the lines of:
>
> type Matrix is array (INTEGER range <>, INTEGER range <>) of float;
> for Matrix'Alignment use 16;
>
>
> and then, for an input of 0..200 by 0..200
>
> sam := new Matrix(0..200,2..198)
> bob := new Matrix(2..198,2..198);
>
>
> These are the actual indicies I would use (it's an image processing
> algorithm that trims the edges). I'm not sure if the strange indices
> could be causing the problem, but I cannot imagine it is.
>
> However, the three matricies, input, sam, and bob aren't necessarily
> aligned (for certain input index ranges they are, by default, and some
> times they are not. The alignment statement I am using seems to have no
> effect).

You may specify alignment only for the first subtype of a base type.
Thus, you may want to define a new type:

type Real is new float;
for Real'Alignment use 16;

The AARM contains the following bit of wisdom:

"The Alignment of a composite object is always equal to the least
common multiple of the Alignments of its components, or a multiple
thereof."

Jim Rogers




  reply	other threads:[~2005-11-18 22:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-18 21:35 Allocated aligned arrays ldb
2005-11-18 22:06 ` jimmaureenrogers [this message]
2005-11-18 22:31   ` ldb
2005-11-20 11:21     ` Martin Krischik
2005-11-18 22:51   ` Simon Wright
2005-11-18 23:03     ` ldb
2005-11-19  7:36 ` Simon Wright
2005-11-19 13:12   ` Jeff Creem
2005-11-23  0:17   ` Randy Brukardt
2005-11-23 14:28     ` ldb
2005-11-24  1:39       ` Frank J. Lhota
2005-11-27 20:49       ` Robert A Duff
replies disabled

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