1*156cd587Sjoerg #include "timing.h" 2*156cd587Sjoerg #include <stdio.h> 3*156cd587Sjoerg 4*156cd587Sjoerg #define INPUT_TYPE int 5*156cd587Sjoerg #define INPUT_SIZE 512 6*156cd587Sjoerg #define FUNCTION_NAME __ashrdi3 7*156cd587Sjoerg 8*156cd587Sjoerg #ifndef LIBNAME 9*156cd587Sjoerg #define LIBNAME UNKNOWN 10*156cd587Sjoerg #endif 11*156cd587Sjoerg 12*156cd587Sjoerg #define LIBSTRING LIBSTRINGX(LIBNAME) 13*156cd587Sjoerg #define LIBSTRINGX(a) LIBSTRINGXX(a) 14*156cd587Sjoerg #define LIBSTRINGXX(a) #a 15*156cd587Sjoerg 16*156cd587Sjoerg int64_t FUNCTION_NAME(int64_t input, INPUT_TYPE count); 17*156cd587Sjoerg main(int argc,char * argv[])18*156cd587Sjoergint main(int argc, char *argv[]) { 19*156cd587Sjoerg INPUT_TYPE input[INPUT_SIZE]; 20*156cd587Sjoerg int i, j; 21*156cd587Sjoerg 22*156cd587Sjoerg srand(42); 23*156cd587Sjoerg 24*156cd587Sjoerg // Initialize the input array with data of various sizes. 25*156cd587Sjoerg for (i=0; i<INPUT_SIZE; ++i) 26*156cd587Sjoerg input[i] = rand() & 0x3f; 27*156cd587Sjoerg 28*156cd587Sjoerg int64_t fixedInput = INT64_C(0x1234567890ABCDEF); 29*156cd587Sjoerg 30*156cd587Sjoerg double bestTime = __builtin_inf(); 31*156cd587Sjoerg void *dummyp; 32*156cd587Sjoerg for (j=0; j<1024; ++j) { 33*156cd587Sjoerg 34*156cd587Sjoerg uint64_t startTime = mach_absolute_time(); 35*156cd587Sjoerg for (i=0; i<INPUT_SIZE; ++i) 36*156cd587Sjoerg FUNCTION_NAME(fixedInput, input[i]); 37*156cd587Sjoerg uint64_t endTime = mach_absolute_time(); 38*156cd587Sjoerg 39*156cd587Sjoerg double thisTime = intervalInCycles(startTime, endTime); 40*156cd587Sjoerg bestTime = __builtin_fmin(thisTime, bestTime); 41*156cd587Sjoerg 42*156cd587Sjoerg // Move the stack alignment between trials to eliminate (mostly) aliasing effects 43*156cd587Sjoerg dummyp = alloca(1); 44*156cd587Sjoerg } 45*156cd587Sjoerg 46*156cd587Sjoerg printf("%16s: %f cycles.\n", LIBSTRING, bestTime / (double) INPUT_SIZE); 47*156cd587Sjoerg 48*156cd587Sjoerg return 0; 49*156cd587Sjoerg } 50