1f0c73cd44a0c29f24b6f03a241456d57430ba72
4 //--------------------------------------------------------------------------
7 // Set HOST_DEBUG to 1 if you are going to compile this for a host
8 // machine (ie Athena/Linux) for debug purposes and set HOST_DEBUG
9 // to 0 if you are compiling with the smips-gcc toolchain.
15 // Set PREALLOCATE to 1 if you want to preallocate the benchmark
16 // function before starting stats. If you have instruction/data
17 // caches and you don't want to count the overhead of misses, then
18 // you will need to use preallocation.
24 // Set SET_STATS to 1 if you want to carve out the piece that actually
25 // does the computation.
33 static void setStats(int enable
) {}
35 extern void setStats(int enable
);
38 static void printArray(const char name
[], int n
, const int arr
[])
42 printf( " %10s :", name
);
43 for ( i
= 0; i
< n
; i
++ )
44 printf( " %3d ", arr
[i
] );
49 static void printDoubleArray(const char name
[], int n
, const double arr
[])
53 printf( " %10s :", name
);
54 for ( i
= 0; i
< n
; i
++ )
55 printf( " %g ", arr
[i
] );
60 static int verify(int n
, const int test
[], const int verify
[])
63 // Unrolled for faster verification
64 for (i
= 0; i
< n
/2*2; i
+=2)
66 int t0
= test
[i
], t1
= test
[i
+1];
67 int v0
= verify
[i
], v1
= verify
[i
+1];
68 if (t0
!= v0
) return i
+1;
69 if (t1
!= v1
) return i
+2;
71 if (n
% 2 != 0 && test
[n
-1] != verify
[n
-1])
76 static int verifyDouble(int n
, const double test
[], const double verify
[])
79 // Unrolled for faster verification
80 for (i
= 0; i
< n
/2*2; i
+=2)
82 double t0
= test
[i
], t1
= test
[i
+1];
83 double v0
= verify
[i
], v1
= verify
[i
+1];
84 int eq1
= t0
== v0
, eq2
= t1
== v1
;
85 if (!(eq1
& eq2
)) return i
+1+eq1
;
87 if (n
% 2 != 0 && test
[n
-1] != verify
[n
-1])
96 static void __attribute__((noinline
)) barrier()
98 static volatile int sense
;
99 static volatile int count
;
100 static __thread
int threadsense
;
102 __sync_synchronize();
104 threadsense
= !threadsense
;
105 if (__sync_fetch_and_add(&count
, 1) == ncores
-1)
110 else while(sense
!= threadsense
)
113 __sync_synchronize();
117 #include "encoding.h"