[Dspforum] Double word data aligning
O'Connor, Sean R.
Sean.OConnor at jhuapl.edu
Thu Oct 8 19:29:03 MDT 2009
Joseph and Doug,
Thanks for the responses, it makes sense now.
-Sean
________________________________________
From: dspforum-bounces at echelonembedded.com [dspforum-bounces at echelonembedded.com] On Behalf Of Doug Wenstrand [doug at echelonembedded.com]
Sent: Thursday, October 08, 2009 7:26 PM
To: dspforum at echelonembedded.com
Subject: Re: [Dspforum] Double word data aligning
When you declare an array of floats:
float samples[1024]
and then use the DATA_ALIGN(samples,8) -- note the 8, not 64 as it is in bytes, not bits
it does exactly as you guessed : samples[0] is on an 8 byte boundary, and every next element comes 4 bytes later since float is a 4-byte type.
dspf_sp_dotprod doesn't do any skipping though. It presumes that the data it is operating on is aligned at a double word boundary. It doesn't presume that every element is on a double word boundary. So, as long as the first element that it gets is on a double word boundary, it works as expected on single precision floating point data. The reason it requires this restriction is that it uses a load double-word instruction to load two pieces of data at once. That instruction needs to have a double-word address to load.
Note though that aligning samples[1024] on a double-word boundary allows you to call dspf_sp_dotprod(samples,...)
but this would cause a problem :
dspf_sp_dotprod(&samples[1],...)
what I'm saying is that the aligment that is important is the alignment of the pointer that it gets. It doesn't necessarily know anything about the beginning of your array
does that make sense?
On Thu, Oct 8, 2009 at 6:19 PM, O'Connor, Sean R. <Sean.OConnor at jhuapl.edu<mailto:Sean.OConnor at jhuapl.edu>> wrote:
I have a few questions about data aligning. For the DSP Lib function dspf_sp_dotprod, it requires pointers to two single precision floating point arrays which must be double word aligned. So when you declare an array of floats, call it samples[], and then use DATA_ALIGN(samples, 64) to align it on a double word boundary (I think that is correct), will it place the first element on the boundary and then every 32 bits after place another array element? If this is the case, will dspf_sp_dotprod skip over every other element in the array?
Thanks,
Sean
_______________________________________________
Dspforum mailing list
Dspforum at echelonembedded.com<mailto:Dspforum at echelonembedded.com>
http://echelonembedded.com/mailman/listinfo/dspforum_echelonembedded.com
More information about the Dspforum
mailing list