#include #include "cln/cln.h" using namespace cln; typedef struct { unsigned long t[2]; } timing; #define timing_now(x) asm volatile(".byte 15;.byte 49" : "=a"((x)->t[0]),"=d"((x)->t[1])) #define timing_diff(x,y) (((x)->t[0] - (double) (y)->t[0]) + 4294967296.0 * ((x)->t[1] - (double) (y)->t[1])) #define SIZES 88 #define TIMINGS 6 int b[SIZES] = { 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56 , 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 640, 768, 896 , 1024, 1280, 1536, 1792, 2048, 2560, 3072, 3584, 4096, 5120, 6144, 7168 , 8192, 10240, 12288, 14336, 16384, 20480, 24576, 28672 , 32768, 40960, 49152, 57344, 65536, 81920, 98304, 114688 , 131072, 163840, 196608, 229376, 262144, 327680, 393216, 458752 , 524288, 655360, 786432, 917504, 1048576, 1310720, 1572864, 1835008 , 2097152, 2621440, 3145728, 3670016, 4194304, 5242880, 6291456, 7340032 , 8388608 } ; timing t[SIZES][TIMINGS + 2]; int main(void) { cl_I x; cl_I y; cl_I z; int i; int j; for (i = 0;i < SIZES;++i) { x = 1; x = x << b[i]; x = x - 1; y = x; timing_now(&t[i][0]); for (j = 0;j < TIMINGS;++j) { z = x * y; timing_now(&t[i][j + 1]); } } for (i = 0;i < SIZES;++i) { printf("%8d: ",b[i]); for (j = 0;j < TIMINGS;++j) printf("%10.0f ",timing_diff(&t[i][j + 1],&t[i][j])); printf("\n"); } return 0; }