diff options
| author | Douglas Rumbaugh <dbr4@psu.edu> | 2024-01-24 11:31:28 -0500 |
|---|---|---|
| committer | Douglas Rumbaugh <dbr4@psu.edu> | 2024-01-24 11:31:28 -0500 |
| commit | 4aa907d6275b1b74be87ed2f2e94d8a2719a6a97 (patch) | |
| tree | 14940e24cde965da248b13b08fca004cd7ae8889 /benchmarks/insertion_tput.cpp | |
| parent | f0a55f7996e9ea2c7824fd5ab136b7c1864bbcdd (diff) | |
| download | dynamic-extension-4aa907d6275b1b74be87ed2f2e94d8a2719a6a97.tar.gz | |
Multithreaded Insertion Benchmark
Diffstat (limited to 'benchmarks/insertion_tput.cpp')
| -rw-r--r-- | benchmarks/insertion_tput.cpp | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/benchmarks/insertion_tput.cpp b/benchmarks/insertion_tput.cpp index 5498f93..785b933 100644 --- a/benchmarks/insertion_tput.cpp +++ b/benchmarks/insertion_tput.cpp @@ -18,27 +18,53 @@ typedef de::rq::Query<ISAM, Rec> Q; typedef de::DynamicExtension<Rec, ISAM, Q> Ext; +void insert_thread(int64_t start, int64_t end, Ext *extension) { + for (int64_t i=start; i<end; i++) { + Rec r = {i, i}; + while (!extension->insert(r)) { + _mm_pause(); + } + } +} + int main(int argc, char **argv) { - auto extension = new Ext(1000, 10000, 2); size_t n = 1000000000; - size_t per_trial = 1000; - TIMER_INIT(); - for (int64_t i=0; i<n; i+=per_trial) { + std::vector<int> counts = {1, 2, 4, 8}; //, 16, 32, 64}; + + + for (auto thread_count : counts) { + + auto extension = new Ext(1000, 12000, 8); + + size_t per_thread = n / thread_count; + + std::thread threads[thread_count]; + + TIMER_INIT(); TIMER_START(); - for (int64_t j=0; j<per_trial; j++) { - Rec r = {i+j, i+j}; - while (!extension->insert(r)) { - _mm_pause(); - } + for (size_t i=0; i<thread_count; i++) { + threads[i] = std::thread(insert_thread, i*per_thread, + i*per_thread+per_thread, extension); + } + + for (size_t i=0; i<thread_count; i++) { + threads[i].join(); } + TIMER_STOP(); - auto insert_lat = TIMER_RESULT(); - fprintf(stdout, "%ld\t%ld\t%ld\n", extension->get_record_count(), insert_lat, per_trial); + auto total_time = TIMER_RESULT(); + + double tput = (double) n / (double) total_time * 1e9; + + fprintf(stdout, "%ld\t%d\t%lf\n", extension->get_record_count(), + thread_count, tput); + + delete extension; } fflush(stderr); |