-
Notifications
You must be signed in to change notification settings - Fork 173
Expand file tree
/
Copy pathmath_utils_benchmark.cpp
More file actions
46 lines (39 loc) · 1.27 KB
/
Copy pathmath_utils_benchmark.cpp
File metadata and controls
46 lines (39 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <cstdint>
#include "benchmark/benchmark.h" // from @google_benchmark
#include "lib/Utils/MathUtils.h"
#include "mlir/include/mlir/Support/LLVM.h" // from @llvm-project
namespace mlir {
namespace heir {
static void BM_findPrimitive2nthRoot(benchmark::State& state) {
uint64_t q_val = state.range(0);
uint64_t n = state.range(1);
APInt q(64, q_val);
for (auto _ : state) {
auto root = findPrimitive2nthRoot(q, n);
benchmark::DoNotOptimize(root);
}
}
// q = 65537, n = 1024
BENCHMARK(BM_findPrimitive2nthRoot)
->Args({65537, 1024})
->Unit(benchmark::kMicrosecond);
// q = 114689, n = 1024
BENCHMARK(BM_findPrimitive2nthRoot)
->Args({114689, 1024})
->Unit(benchmark::kMicrosecond);
// q = 2147565569, n = 8192
BENCHMARK(BM_findPrimitive2nthRoot)
->Args({2147565569, 8192})
->Unit(benchmark::kMicrosecond);
// A larger prime: 2^32 + 15 * 2^27 + 1 = 4294967297 + 2013265920 + 1? No.
// Let's use 3221225473 from MathUtilsTest.cpp
BENCHMARK(BM_findPrimitive2nthRoot)
->Args({3221225473, 8192})
->Unit(benchmark::kMicrosecond);
// q = 1152921504606846977, n = 65536
BENCHMARK(BM_findPrimitive2nthRoot)
->Args({1152921504606846977, 65536})
->Unit(benchmark::kMicrosecond);
} // namespace heir
} // namespace mlir
BENCHMARK_MAIN();