int main(){ int A[64]; int N; int capacity = 64; N = readInts(A, capacity); sortInts(A, N); printf("\n"); printInts(A, N); return 0; }
/* ************************************************************************* NAME: test2_float2char USAGE: test2_float2char(); returns: void DESCRIPTION: convert floats to ints to shorts to chars to test rounding/truncating REFERENCES: Ian Ollmann's Altivec Tutorial LIMITATIONS: GLOBAL VARIABLES: accessed: none modified: none FUNCTIONS CALLED: fprintf vec_st - store a vector to memory vec_ctu - convert to fixed point vec_pack - narrow 2 vectors and pack them into one vector REVISION HISTORY: STR Description of Revision Author 08-Feb-2011 Based off of test_float2char but kaj changing set of vec functions called ************************************************************************* */ void test2_float2char(void) { vector float floatVec1 = {0.0, -50.14455, 21.7790, 100.0 }; vector float floatVec2 = {-100.4567, 250.14455, -210.7790, 170.0 }; vector float floatVec3 = {0.09876, -150.55, 1.7790, -120.0 }; vector float floatVec4 = {-90.234, -30.9455, -205.90, 199.9 }; vector unsigned int intVec1, intVec2, intVec3, intVec4; vector unsigned short shortVec1, shortVec2; vector unsigned char charVec; unsigned char printchar[CHAR_ARRAYSIZE] __attribute__ ((aligned (16))); float printfloat[FLOAT_ARRAYSIZE] __attribute__ ((aligned (16))); unsigned short printshort[SHORT_ARRAYSIZE] __attribute__ ((aligned (16))); unsigned int printint[INT_ARRAYSIZE] __attribute__ ((aligned (16))); int i; fprintf(stderr, "--- function %s ------\n", __FUNCTION__); /* print out floats */ vec_st(floatVec1,0,printfloat); printFloats(printfloat); vec_st(floatVec2,0,printfloat); printFloats(printfloat); vec_st(floatVec3,0,printfloat); printFloats(printfloat); vec_st(floatVec4,0,printfloat); printFloats(printfloat); /* convert from float to unsigned int and print */ intVec1 = vec_ctu(floatVec1,0); vec_st(intVec1,0,printint); printUInts(printint); intVec2 = vec_ctu(floatVec2,0); vec_st(intVec2,0,printint); printUInts(printint); intVec3 = vec_ctu(floatVec3,0); vec_st(intVec3,0,printint); printUInts(printint); intVec4 = vec_ctu(floatVec4,0); vec_st(intVec4,0,printint); printInts(printint); /* convert from unsigned int to unsigned short and print */ shortVec1 = vec_pack(intVec1,intVec2); vec_st(shortVec1,0,printshort); printUShorts(printshort); shortVec2 = vec_pack(intVec3,intVec4); vec_st(shortVec2,0,printshort); printUShorts(printshort); /* convert from unsigned short to unsigned char and print */ charVec = vec_pack(shortVec1, shortVec2); vec_st(charVec,0,printchar); printChars(printchar); } /* test2_float2char */