int main() { uint64_t u, v, w; uint64_t seed = time(0); RAND_NR_INIT(u, v, w, seed); for (int i = 0; i < 100; i++) printf("rand number = %llx\n", (unsigned long long)RAND_NR_NEXT(u, v, w)); uint64_t h = 0; printf("rand int mix1 = %llx\n", (unsigned long long)RAND_INT_MIX64(h)); printf("rand int mix2 = %llx\n", (unsigned long long)RAND_INT2_MIX64(h)); printf("rand int mix3 = %llx\n", (unsigned long long)RAND_INT3_MIX64(h)); printf("rand int mix4 = %llx\n", (unsigned long long)RAND_INT4_MIX64(h)); uint64_t r = RAND_NR_NEXT(u, v, w); uint64_t s = r; RAND_INT4_MIX64(s); RAND_INT4_MIX64_INV(s); if (s != r) fprintf(stderr, "expected %016llx, acutal %016llx\n", (unsigned long long)r, (unsigned long long)s); else printf("passed\n"); return 0; }
int main(int argc, char *argv[]) { int num = 1000000; tree_root_np *root = NULL; if (argc > 1) num = atoi(argv[1]); uint64_t seed = time(NULL); RAND_NR_INIT(u, v, w, seed); ulib_timer_t timer; timer_start(&timer); for (int i = 0; i < num; ++i) { tree_node *t = new tree_node; t->key = myrand(); if (&t->link != splay_map_np(&t->link, tree_node_cmp, &root)) delete t; } printf("Inserting 1M elems elapsed: %f\n", timer_stop(&timer)); timer_start(&timer); for (int i = 0; i < 1000000; ++i) { tree_node t; t.key = myrand(); splay_search_np(&t.link, tree_node_cmp, &root); } printf("Searching 10M elems elapsed: %f\n", timer_stop(&timer)); printf("passed\n"); return 0; }
int main() { uint64_t u, v, w; uint64_t seed = time(0); RAND_NR_INIT(u, v, w, seed); for (int i = 0; i < 100; i++) printf("rand number = %llx\n", (unsigned long long)RAND_NR_NEXT(u, v, w)); uint64_t r = RAND_NR_NEXT(u, v, w); uint64_t s = BIN_TO_GRAYCODE(r); uint64_t t = BIN_TO_GRAYCODE(r + 1); assert(hweight64(t ^ s) == 1); GRAYCODE_TO_BIN64(s); assert(rev8(5) == 160); assert(rev8_hakmem(5) == 160); uint64_t hi, lo; MULQ(0x1234567887654321ul, 0x77665544332211fful, lo, hi); assert(hi == 611815671993850618UL); assert(lo == 14353276178066116319UL); if (s != r) fprintf(stderr, "expected %016llx, acutal %016llx\n", (unsigned long long)r, (unsigned long long)s); else printf("passed\n"); return 0; }
static inline void __init_seeds(uint64_t *seeds, int nseed) { uint64_t x, y, z; uint64_t seed = lrand48(); int i; RAND_NR_INIT(x, y, z, seed); for (i = 0; i < nseed; i++) seeds[i] = RAND_NR_NEXT(x, y, z); }
int main() { uint64_t seed = rdtsc(); RAND_NR_INIT(u, v, w, seed); hweight64_test(); hweight32_test(); hweight32_hakmem_test(); hweight16_test(); hweight15_test(); printf("passed\n"); return 0; }
void zipf_rng_init(struct zipf_rng *rng, int range, float s) { uint64_t seed = (uint64_t) time(NULL); rng->range = range++; rng->s = s; if (isequalf(s, 1.0)) rng->sum = log(range); else rng->sum = (pow(range, 1.0 - s) - 1.0)/(1.0 - s); RAND_NR_INIT(rng->u, rng->v, rng->w, seed); }
int main() { uint64_t u, v, w; RAND_NR_INIT(u, v, w, 0UL); for (int i = 0; i < 100; i++) printf("rand number = %llx\n", (unsigned long long)RAND_NR_NEXT(u, v, w)); uint64_t h = 0; printf("rand int mix1 = %llx\n", (unsigned long long)RAND_INT_MIX64(h)); printf("rand int mix2 = %llx\n", (unsigned long long)RAND_INT2_MIX64(h)); printf("passed\n"); return 0; }
int main(int argc, char *argv[]) { long ins = 1000000; long get = 50000000; uint64_t seed = time(NULL); if (argc > 1) ins = atol(argv[1]); if (argc > 2) get = atol(argv[2]); RAND_NR_INIT(u, v, w, seed); register_sig_handler(); constant_insert(ins, get); printf("passed\n"); return 0; }
int main(int argc, char *argv[]) { int num = 1000000; avl_root *root = NULL; if (argc > 1) num = atoi(argv[1]); uint64_t seed = time(NULL); RAND_NR_INIT(u, v, w, seed); ulib_timer_t timer; timer_start(&timer); for (int i = 0; i < num; ++i) { avl_node *t = new avl_node; t->key = myrand(); if (&t->link != avl_map(&t->link, avl_node_cmp, &root)) delete t; } printf("Inserting 1M elems elapsed: %f\n", timer_stop(&timer)); printf("Height: %d\n", TREE_HEIGHT(root)); timer_start(&timer); for (int i = 0; i < 1000000; ++i) { avl_node t; t.key = myrand(); TREE_SEARCH(&t.link, avl_node_cmp, root); } printf("Searching 10M elems elapsed: %f\n", timer_stop(&timer)); avl_node *pos, *tmp; timer_start(&timer); avl_for_each_entry_safe(pos, tmp, root, link) { avl_del(&pos->link, &root); delete pos; }
int main(int argc, char *argv[]) { int num = 1000000; avl_table *root; if (argc > 1) num = atoi(argv[1]); uint64_t seed = time(NULL); RAND_NR_INIT(u, v, w, seed); root = avl_create(node_cmp, NULL, &avl_allocator_default); ulib_timer_t timer; timer_start(&timer); for (int i = 0; i < num; ++i) { node *t = new node; t->key = myrand(); avl_insert(root, t); } printf("Inserting 1M elems elapsed: %f\n", timer_stop(&timer)); timer_start(&timer); for (int i = 0; i < 1000000; ++i) { node t; t.key = myrand(); avl_find(root, &t); } printf("Searching 10M elems elapsed: %f\n", timer_stop(&timer)); timer_start(&timer); avl_destroy(root, node_destroy); printf("Deleting 1M elems elapsed: %f\n", timer_stop(&timer)); return 0; }