5 #define LIBNAME UNKNOWN
8 #define LIBSTRING LIBSTRINGX(LIBNAME)
9 #define LIBSTRINGX(a) LIBSTRINGXX(a)
10 #define LIBSTRINGXX(a) #a
12 double __floatundidf(uint64_t x
);
14 int main(int argc
, char *argv
[]) {
15 #define INPUT_SIZE 512
16 uint64_t input
[INPUT_SIZE
];
21 // Initialize the input array with data of various sizes.
22 for (i
=0; i
<INPUT_SIZE
; ++i
)
23 input
[i
] = (((uint64_t)rand() << 32) | (uint64_t)rand()) >> (rand() & 63);
25 double bestTime
= __builtin_inf();
27 for (j
=0; j
<1024; ++j
) {
29 uint64_t startTime
= mach_absolute_time();
30 for (i
=0; i
<INPUT_SIZE
; ++i
)
31 __floatundidf(input
[i
]);
32 uint64_t endTime
= mach_absolute_time();
34 double thisTime
= intervalInCycles(startTime
, endTime
);
35 bestTime
= __builtin_fmin(thisTime
, bestTime
);
37 // Move the stack alignment between trials to eliminate (mostly) aliasing effects
41 printf("%16s: %f cycles.\n", LIBSTRING
, bestTime
/ (double) INPUT_SIZE
);