11/*
2- * Copyright (c) 2020, NVIDIA CORPORATION.
2+ * Copyright (c) 2020-2022 , NVIDIA CORPORATION.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1414 * limitations under the License.
1515 */
1616
17- #include " cuco/static_map.cuh"
17+ #include < cuco/static_map.cuh>
18+
19+ #include < thrust/device_vector.h>
20+ #include < thrust/for_each.h>
21+
1822#include < benchmark/benchmark.h>
23+
1924#include < fstream>
2025#include < iostream>
2126#include < random>
22- #include < thrust/device_vector.h>
23- #include < thrust/for_each.h>
2427
2528enum class dist_type { UNIQUE, UNIFORM, GAUSSIAN };
2629
@@ -145,6 +148,9 @@ static void BM_static_map_search_all(::benchmark::State& state)
145148
146149 for (auto _ : state) {
147150 map.find (d_keys.begin (), d_keys.end (), d_results.begin ());
151+ // TODO: get rid of sync and rewrite the benchmark with `nvbench`
152+ // once https://github.com/NVIDIA/nvbench/pull/80 is merged
153+ cudaDeviceSynchronize ();
148154 }
149155
150156 state.SetBytesProcessed ((sizeof (Key) + sizeof (Value)) * int64_t (state.iterations ()) *
@@ -202,11 +208,55 @@ BENCHMARK_TEMPLATE(BM_static_map_insert, int32_t, int32_t, dist_type::UNIQUE)
202208 ->Apply(generate_size_and_occupancy)
203209 ->UseManualTime();
204210
205- BENCHMARK_TEMPLATE (BM_static_map_erase_all , int32_t , int32_t , dist_type::UNIQUE)
211+ BENCHMARK_TEMPLATE (BM_static_map_search_all , int32_t , int32_t , dist_type::UNIQUE)
206212 ->Unit(benchmark::kMillisecond )
207213 ->Apply(generate_size_and_occupancy);
208214
209- BENCHMARK_TEMPLATE (BM_static_map_insert, int32_t , int32_t , dist_type::UNIQUE)
215+ BENCHMARK_TEMPLATE (BM_static_map_insert, int32_t , int32_t , dist_type::UNIFORM)
216+ ->Unit(benchmark::kMillisecond )
217+ ->Apply(generate_size_and_occupancy)
218+ ->UseManualTime();
219+
220+ BENCHMARK_TEMPLATE (BM_static_map_search_all, int32_t , int32_t , dist_type::UNIFORM)
221+ ->Unit(benchmark::kMillisecond )
222+ ->Apply(generate_size_and_occupancy);
223+
224+ BENCHMARK_TEMPLATE (BM_static_map_insert, int32_t , int32_t , dist_type::GAUSSIAN)
225+ ->Unit(benchmark::kMillisecond )
226+ ->Apply(generate_size_and_occupancy)
227+ ->UseManualTime();
228+
229+ BENCHMARK_TEMPLATE (BM_static_map_search_all, int32_t , int32_t , dist_type::GAUSSIAN)
230+ ->Unit(benchmark::kMillisecond )
231+ ->Apply(generate_size_and_occupancy);
232+
233+ BENCHMARK_TEMPLATE (BM_static_map_insert, int64_t , int64_t , dist_type::UNIQUE)
210234 ->Unit(benchmark::kMillisecond )
211235 ->Apply(generate_size_and_occupancy)
212- ->UseManualTime();
236+ ->UseManualTime();
237+
238+ BENCHMARK_TEMPLATE (BM_static_map_search_all, int64_t , int64_t , dist_type::UNIQUE)
239+ ->Unit(benchmark::kMillisecond )
240+ ->Apply(generate_size_and_occupancy);
241+
242+ BENCHMARK_TEMPLATE (BM_static_map_insert, int64_t , int64_t , dist_type::UNIFORM)
243+ ->Unit(benchmark::kMillisecond )
244+ ->Apply(generate_size_and_occupancy)
245+ ->UseManualTime();
246+
247+ BENCHMARK_TEMPLATE (BM_static_map_search_all, int64_t , int64_t , dist_type::UNIFORM)
248+ ->Unit(benchmark::kMillisecond )
249+ ->Apply(generate_size_and_occupancy);
250+
251+ BENCHMARK_TEMPLATE (BM_static_map_insert, int64_t , int64_t , dist_type::GAUSSIAN)
252+ ->Unit(benchmark::kMillisecond )
253+ ->Apply(generate_size_and_occupancy)
254+ ->UseManualTime();
255+
256+ BENCHMARK_TEMPLATE (BM_static_map_search_all, int64_t , int64_t , dist_type::GAUSSIAN)
257+ ->Unit(benchmark::kMillisecond )
258+ ->Apply(generate_size_and_occupancy);
259+
260+ BENCHMARK_TEMPLATE (BM_static_map_erase_all, int32_t , int32_t , dist_type::UNIQUE)
261+ ->Unit(benchmark::kMillisecond )
262+ ->Apply(generate_size_and_occupancy);
0 commit comments