11 #ifndef BMHARNESS_HPP__
12 #define BMHARNESS_HPP__
52 <<
", ALG=" << GET_ALGNAME()
53 <<
", B=" << CFG.bmname <<
", R=" << CFG.lookpct
54 <<
", d=" << CFG.duration <<
", p=" << CFG.threads
55 <<
", X=" << CFG.execute <<
", m=" << CFG.elements
56 <<
", S=" << CFG.sets <<
", O=" << CFG.ops
57 <<
", txns=" << CFG.txcount <<
", time=" << CFG.time
59 << (1000000000LL * CFG.txcount) / (CFG.time)
68 std::cerr <<
"Usage: CounterBench -C <stm algorithm> [flags]\n";
69 std::cerr <<
" -d: number of seconds to time (default 1)\n";
70 std::cerr <<
" -X: execute fixed tx count, not for a duration\n";
71 std::cerr <<
" -p: number of threads (default 1)\n";
72 std::cerr <<
" -N: nops between transactions (default 0)\n";
73 std::cerr <<
" -R: % lookup txns (remainder split ins/rmv)\n";
74 std::cerr <<
" -m: range of keys in data set\n";
75 std::cerr <<
" -B: name of benchmark\n";
76 std::cerr <<
" -S: number of sets to build (default 1)\n";
77 std::cerr <<
" -O: operations per transaction (default 1)\n";
78 std::cerr <<
" -h: print help (this message)\n\n";
89 while ((opt = getopt(argc, argv,
"N:d:p:hX:B:m:R:S:O:")) != -1) {
91 case 'd': CFG.duration = strtol(optarg, NULL, 10);
break;
92 case 'p': CFG.threads = strtol(optarg, NULL, 10);
break;
93 case 'N': CFG.nops_after_tx = strtol(optarg, NULL, 10);
break;
94 case 'X': CFG.execute = strtol(optarg, NULL, 10);
break;
95 case 'B': CFG.bmname = std::string(optarg);
break;
96 case 'm': CFG.elements = strtol(optarg, NULL, 10);
break;
97 case 'S': CFG.sets = strtol(optarg, NULL, 10);
break;
98 case 'O': CFG.ops = strtol(optarg, NULL, 10);
break;
100 CFG.lookpct = strtol(optarg, NULL, 10);
101 CFG.inspct = (100 - CFG.lookpct)/2 + strtol(optarg, NULL, 10);
116 if (CFG.nops_after_tx)
117 for (uint32_t i = 0; i < CFG.nops_after_tx; i++)
132 static volatile uint32_t barriers[16] = {0};
134 fai32(&barriers[which]);
135 while (barriers[which] != CFG.threads) { }
153 CFG.time = getElapsedTime();
163 while (CFG.running) {
171 for (uint32_t e = 0; e < CFG.execute; e++) {
181 CFG.time = getElapsedTime() - CFG.time;
184 faa32(&CFG.txcount, count);
208 int main(
int argc,
char** argv) {
220 pthread_attr_init(&attr);
221 pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
222 for (uint32_t i = 0; i < CFG.threads; i++)
226 for (uint32_t j = 1; j < CFG.threads; j++)
227 pthread_create(&tid[j], &attr, &
run_wrapper, args[j]);
239 for (uint32_t k = 1; k < CFG.threads; k++)
240 pthread_join(tid[k], NULL);
243 std::cout <<
"Verification: " << (v ?
"Passed" :
"Failed") <<
"\n";
252 #endif // BMHARNESS_HPP__
void spin64()
Definition: locks.hpp:36
void nontxnwork()
Definition: bmharness.hpp:114
bool set_op ops[]
Definition: stmskip.cc:238
Config()
Definition: bmharness.cpp:26
TxThread * threads[MAX_THREADS]
Definition: txthread.cpp:56
void usage()
Definition: bmharness.hpp:66
bool bench_verify()
Definition: CounterBench.cpp:74
#define SYS_SHUTDOWN()
Definition: common.hpp:94
void parseargs(int argc, char **argv)
Definition: bmharness.hpp:85
void bench_init()
Definition: CounterBench.cpp:57
void barrier(uint32_t which)
Definition: bmharness.hpp:130
static int seed
Definition: mesh.cpp:40
#define THREAD_SHUTDOWN()
Definition: common.hpp:93
int main(int argc, char **argv)
Definition: bmharness.hpp:208
void bench_test(uintptr_t, uint32_t *)
Definition: CounterBench.cpp:64
#define SYS_INIT()
Definition: common.hpp:91
Definition: bmconfig.hpp:21
void bench_reparse()
Definition: CounterBench.cpp:89
void catch_SIGALRM(int)
Definition: bmharness.hpp:122
#define THREAD_INIT()
Definition: common.hpp:92
NOINLINE void * run_wrapper(void *i)
Definition: bmharness.hpp:197
void run(uintptr_t id)
Definition: bmharness.hpp:141
volatile unsigned long count
Definition: queues.cpp:53
void dump_csv()
Definition: bmharness.hpp:48