Memory alignment

D

Detlef Reichl

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
 
T

Timothy Hunter

Detlef said:
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.
 
P

Patrick Hurley

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,240
Messages
2,571,211
Members
47,849
Latest member
RoseannKoz

Latest Threads

Top