/*** Run a bunch of random transactions */ void bench_test(uintptr_t, uint32_t* seed) { // cache the seed locally so we can restore it on abort // // NB: volatile needed because using a non-volatile local in conjunction // with a setjmp-longjmp control transfer is undefined, and gcc won't // allow it with -Wall -Werror. volatile uint32_t local_seed = *seed; TM_BEGIN(atomic) { if (CFG.running) { local_seed = *seed; for (uint32_t i = 0; i < SET->trees_per_tx; ++i) { // pick a tree, a value, and a read-only ratio int tree_idx = rand_r_32(&local_seed) % SET->total_trees; int val = rand_r_32(&local_seed) % SET->keydepths; uint32_t act = rand_r_32(&local_seed) % 100; // do a lookup? if (act < SET->roratio) SET->trees[tree_idx]->lookup(val TM_PARAM); else if (act < SET->insratio) SET->trees[tree_idx]->insert(val TM_PARAM); else SET->trees[tree_idx]->remove(val TM_PARAM); } } } TM_END; *seed = local_seed; }
/*** Run a bunch of random transactions */ void bench_test(uintptr_t, uint32_t* seed) { uint32_t val = rand_r_32(seed) % CFG.elements; TM_BEGIN(atomic) { SET->modify(val TM_PARAM); } TM_END; }
/*** Run a bunch of random transactions */ void bench_test(uintptr_t id, uint32_t* seed) { uint32_t act = rand_r_32(seed) % 100; // NB: volatile needed because using a non-volatile local in conjunction // with a setjmp-longjmp control transfer is undefined, and gcc won't // allow it with -Wall -Werror. volatile uint32_t start = rand_r_32(seed) % Disjoint::DJBUFFER_SIZE; TM_BEGIN(atomic) { // RO or RW transaction? if (act < CFG.lookpct) SET->ro_transaction(id, start TM_PARAM); else SET->r_rw_transaction(id, start TM_PARAM); } TM_END; }
/*** Run a bunch of random transactions */ void bench_test(uintptr_t, uint32_t* seed) { // cache the seed locally so we can restore it on abort // // NB: volatile needed because using a non-volatile local in conjunction // with a setjmp-longjmp control transfer is undefined, and gcc won't // allow it with -Wall -Werror. volatile uint32_t local_seed = *seed; TM_BEGIN(atomic) { for (uint32_t i = 0; i < CFG.ops; ++i) { uint32_t loc = rand_r_32(&local_seed) % CFG.elements; TM_WRITE(matrix[loc], 1 + TM_READ(matrix[loc])); } } TM_END; *seed = local_seed; }