Guest User

Test

a guest
Mar 25th, 2016
86
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <sys/time.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <math.h>
  5. #include <strings.h>
  6. #include "test2.h"
  7.  
  8. double gettime ()
  9. {
  10.     struct timeval tv;
  11.     gettimeofday (&tv, NULL);
  12.     return (double)tv.tv_sec + (0.000001 * (double)tv.tv_usec);
  13. }
  14.  
  15. #define N 400000000
  16.  
  17. int main ()
  18. {
  19.     float z = sqrtf(2)/2;
  20.     float a[4] __attribute__((aligned(16))) = {z,z,0,0};
  21.     float (*b)[4] = aligned_alloc (16, 4*N*sizeof(float));
  22.     int i;
  23.  
  24.     for (i=0; i<N; i++)
  25.     {
  26.         bzero (b[i], 16);
  27.         b[i][i%3] = 4;
  28.     }
  29.  
  30.     double time = gettime();
  31.     for (i=0; i<N; i++)
  32.     {
  33. #if 0
  34.         b[i][0] = 0;
  35. #endif
  36.         rotate_vector (a,b[i],b[i]);
  37.     }
  38.     time = gettime() - time;
  39.     printf ("%f %f %f\n", b[0][0], b[0][1], b[0][2]);
  40.     printf ("%f\n", time);
  41.     return 0;
  42. }
RAW Paste Data