This is a C implementation of a partitioned counter. An instance of the partitioned can be incremented by multiple threads simultaneously in a thread-safe way.
-
'pc_init(pc_t *pc, int64_t *global_counter, uint32_t num_counters, int32_t threshold)': to initialize the counter.
-
'pc_destructor(pc_t *pc)': to destroy the counter and free up resources.
-
'pc_add(pc_t *pc, int64_t count)': to increment the counter by +count.
-
'pc_sync(pc_t *pc)': to sync up partitioned counters.
To build on a Haswell or newer hardware:
$ make
$ ./test_pc 8
The argument to 'test_pc' is the number of threads.
Contributions via GitHub pull requests are welcome.
- Prashant Pandey [email protected]
- Rob Johnson [email protected]