[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Memory alignment

Detlef Reichl

4/22/2007 1:08:00 PM

Hi,

in an C extension i need to generate ruby strings, where str->ptr is
aligned to a 16 byte boundary. This is necessary so that the data can be
used with simd engines (AltiVec, SSE, ...).

Is there a way to do this?

Cheers
detlef


2 Answers

Tim Hunter

4/22/2007 1:50:00 PM

0

Detlef Reichl wrote:
> Hi,
>
> in an C extension i need to generate ruby strings, where str->ptr is
> aligned to a 16 byte boundary. This is necessary so that the data can be
> used with simd engines (AltiVec, SSE, ...).
>
> Is there a way to do this?
>
> Cheers
> detlef
>
>
There's no way to tell Ruby to align its strings this way. Your only option is to make a copy aligned to your needs.


Patrick Hurley

4/24/2007 12:42:00 AM

0

On 4/22/07, Timothy Hunter <TimHunter@nc.rr.com> wrote:
> Detlef Reichl wrote:
> > Hi,
> >
> > in an C extension i need to generate ruby strings, where str->ptr is
> > aligned to a 16 byte boundary. This is necessary so that the data can be
> > used with simd engines (AltiVec, SSE, ...).
> >
> > Is there a way to do this?
> >
> > Cheers
> > detlef
> >
> >
> There's no way to tell Ruby to align its strings this way. Your only option is to make a copy aligned to your needs.
>
>
>

Without looking at the ruby source code to see if there is a hack for
alignment, one thought that occurs is to create your string 16 bytes
larger than required -- find the correct offset that is aligned, do
the work and then adjust the string as necessary to the correct start.

pth