1 /************************************************************************
3 * Function: Add 2 vectors (lying in memory) and store the result in
4 * a another vector in memory.
5 * Used as a test for the simd optimization.
6 * Author: Andreas Schoesser
8 ************************************************************************/
17 //void array_test(int *a[]);
27 printf("1. vload -> vadd -> vstore\n===================\n\n");
30 printf("2. vload -> vadd -> vstore, multi dimensional array, in loop\n==========================================\n\n");
40 float a[4], b[4], c[4], d[4];
47 for(i = 0; i < 4; i++)
58 sp1 = a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
61 sp2 = b[0] * d[0] + b[1] * d[1] + b[2] * d[2] + b[3] * d[3];
63 // Usage to prevent optimizations other than SIMD opt
64 for(i = 0; i < 4; i++)
65 printf("%f %f %f %f\n", a[i], b[i], c[i], d[i]);