[Radiance-dev] vectorization data types

Lars O. Grobe grobe at gmx.net
Sun Feb 26 21:14:15 CET 2006


Hi!

> I don't know quite understand how changing the struct's to union's 
> would help in vectorizing the code -- you'll have to give me an 
> explicit example, and this is probably one for radiance-dev.

This is the altivec way, I am not sure about other vector processors.

A common approach to integrate altivec in conventional code is to keep 
using arrays. The problem is that data has to be aligned for altivec. 
If it isn't, one has to do quite a lot of operations before the actual 
computation. As on altivec machines, I hace a type "vector", I can 
enforce alignment of data in an array by the following:

typedef union { float arrayData[4]; vector float vectorData; } myVector;

Now, I can still access elements in the array, but the compiler will 
align the data, and for altivec, I can use the vector directly without 
any shifts.

I came across this when I found an old posting from Georg, who proposed 
that someone could take a look at multmat, which is perfect for 
altivec. But as mat4 and fvect are not aligned, the overhead is too 
large to really optimize code without changing data outside those 
functions.

Finally, I feel I really HAVE to say that I am not a programmer, if, 
the lousiest c and c++ "scripter" out there... ;-)

CU, Lars.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2134 bytes
Desc: not available
Url : http://radiance-online.org/pipermail/radiance-dev/attachments/20060226/05f1911d/smime.bin


More information about the Radiance-dev mailing list