Vector programming doesn’t stop with PowerPC. Learn how to do SIMD vector programming for MacOS X for Intel. This page provides an overview of the hardware and programming interfaces involved, and provides detailed translation help information for leveraging your investment in AltiVec forward to the SSE world.
The page points to
http://gcc.gnu.org/onlinedocs/gcc-4.0.0/gcc/Vector-Extensions.html
Which isn’t very helpful. (e.g. how to populate an v4si or how to extract the components of it for e.g. I/O)
Anyone knows of some more definitve guides to these extensions in gcc ?
Here’s an example:
http://ds9a.nl/gcc-simd/example.html
It uses unions, very ugly. There must be a better way, surely?
What’s wrong with unions ?
What’s wrong with unions ?
Nothing, it’s the way they’re used in that example that is wrong.
Basically, there’s no guarantee that fields of the float[4] array in there actually correspond to the elements of the v4sf vector, because it’s up to the compiler how it lays out things in memory.
So unless there’s a proper specification for those vector types somewhere, this is dodgy code.
And another thing. The union with an array forces the compiler to put the vector in memory, rather than simply into a SSE register.
The universal binary pdf that was available the day the switch was mentioned had an entire appendix that mapped altivec instructions to their sse equivalents. In some cases (where sse lacked a direct correlation) they even provided full sample code to get the same results with sse.
I fail to see how this is “OS” news. It should be under the title “unobservant rehashed dribble.”
>Here’s an example:
>http://ds9a.nl/gcc-simd/example.html
Thank you.
It does depend a bit on size though, what if I need to load 128 bits floats for simd use, does a long double fit the layout.
I’d like to see this documented 🙂
put hair on my chest?
Isnt this the job of compilers?
How about SMARTER compilers no?