Technical: Hardware: G4
Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Support

MultiplyData

This program loads in a cacheline as two vectors, then adds the vectors to themselves some number of times to simulate work being done before the next load. It is used as a test program to benchmark function performance with varying amounts of work done per data loaded.

vector unsigned char MultiplyData
(

vector unsigned char *data,
int datasize,
long prefetchConstant,
int constantMultiplier

)
{

vector unsigned char sum1, sum2;

vec_dst( data, prefetchConstant, 0 );

sum1 = sum2 = vec_splat_u8(0);
datasize /= 2;

while(datasize--)
{

vec_dst( data, prefetchConstant, 0 );

//Load in 32 bytes of data
vector unsigned char temp = data[0];
vector unsigned char temp2 = data[1];
long count = constantMultiplier;

//Do some amount of work on the data
while( count-- )
{

sum1 = vec_add( sum1, temp );
sum2 = vec_add( sum2, temp2 );

}

#if DO_STORE

//Store it back out to the same address if
//DO_STORE is true
data[0] = sum1;
data[1] = sum2;

#endif

data += 2;

}

vec_dss(0);

return vec_add( sum1, sum2 );

}