4 #define INPUT_TYPE int64_t
6 #define FUNCTION_NAME __divdi3
9 #define LIBNAME UNKNOWN
12 #define LIBSTRING LIBSTRINGX(LIBNAME)
13 #define LIBSTRINGX(a) LIBSTRINGXX(a)
14 #define LIBSTRINGXX(a) #a
16 INPUT_TYPE
FUNCTION_NAME(INPUT_TYPE input1
, INPUT_TYPE input2
);
18 int main(int argc
, char *argv
[]) {
19 INPUT_TYPE input1
[INPUT_SIZE
];
20 INPUT_TYPE input2
[INPUT_SIZE
];
25 // Initialize the input array with data of various sizes.
26 for (i
=0; i
<INPUT_SIZE
; ++i
) {
27 input1
[i
] = (((int64_t)rand() << 36) | (uint64_t)rand()) >> (rand() & 63);
28 input2
[i
] = ((((int64_t)rand() << 36) | (uint64_t)rand()) >> (rand() & 63)) + 1LL;
31 int64_t fixedInput
= INT64_C(0x1234567890ABCDEF);
33 double bestTime
= __builtin_inf();
35 for (j
=0; j
<1024; ++j
) {
37 uint64_t startTime
= mach_absolute_time();
38 for (i
=0; i
<INPUT_SIZE
; ++i
)
39 FUNCTION_NAME(input1
[i
], input2
[i
]);
40 uint64_t endTime
= mach_absolute_time();
42 double thisTime
= intervalInCycles(startTime
, endTime
);
43 bestTime
= __builtin_fmin(thisTime
, bestTime
);
45 // Move the stack alignment between trials to eliminate (mostly) aliasing effects
49 printf("%16s: %f cycles.\n", LIBSTRING
, bestTime
/ (double) INPUT_SIZE
);