From 22f15b974803084d2d73f28a2a0c17a856d7f070 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Thu, 12 Dec 2024 15:02:16 +0900 Subject: [PATCH] tweak msm benchmark --- include/mcl/ec.hpp | 4 ++-- src/msm_avx.cpp | 19 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/include/mcl/ec.hpp b/include/mcl/ec.hpp index 184d27b9..bd0290a3 100644 --- a/include/mcl/ec.hpp +++ b/include/mcl/ec.hpp @@ -1005,7 +1005,7 @@ inline size_t estimateBucketSize(size_t n) First, get approximate value x and compute glvCost of x-1 and x+1, and return the minimum value. */ -inline size_t getTheoreticBucketSize(size_t n) +inline size_t glvGetTheoreticBucketSize(size_t n) { size_t x = estimateBucketSize(n); size_t vm1 = x > 1 ? glvCost(n, x-1) : n; @@ -1016,7 +1016,7 @@ inline size_t getTheoreticBucketSize(size_t n) return x; } -// return heuristic backet size which is faster than getTheoreticBucketSize +// return heuristic backet size which is faster than glvGetTheoreticBucketSize inline size_t glvGetBucketSize(size_t n) { if (n <= 2) return 2; diff --git a/src/msm_avx.cpp b/src/msm_avx.cpp index 1e45ad77..75ad7762 100644 --- a/src/msm_avx.cpp +++ b/src/msm_avx.cpp @@ -1722,7 +1722,7 @@ CYBOZU_TEST_AUTO(glvParam) printf("\n"); for (size_t d = 9; d < 28; d++) { size_t n = (size_t(1) << d)/8*2; // /(#SIMD)*(GLV) - size_t b1 = mcl::ec::getTheoreticBucketSize(n); + size_t b1 = mcl::ec::glvGetTheoreticBucketSize(n); size_t cost1 = mcl::ec::glvCost(n, b1); double mem1 = (8*8*8*3) * (size_t(1) << b1) / 1024.0 / 1024; size_t b2 = glvGetBucketSizeAVX512(n); @@ -2411,13 +2411,12 @@ void msmBench(int C, size_t db, size_t de, size_t b) G1 P1; for (size_t d = db; d <= de; d++) { size_t n = size_t(1) << d; - size_t db = glvGetBucketSizeAVX512(n/4); - printf("% 8zd % 2zd", n, size_t(db)); - CYBOZU_BENCH_C(" ", C, mcl::msm::mulVecAVX512, (Unit*)&P1, (Unit*)Pvec.data(), (const Unit*)xVec.data(), n, db); - if (b) { - printf("% 8zd % 2zd", n, b); - CYBOZU_BENCH_C(" ", C, mcl::msm::mulVecAVX512, (Unit*)&P1, (Unit*)Pvec.data(), (const Unit*)xVec.data(), n, b); - } + size_t b1 = glvGetBucketSizeAVX512(n/4); + printf("% 8zd % 2zd", n, b1); + CYBOZU_BENCH_C(" ", C, mcl::msm::mulVecAVX512, (Unit*)&P1, (Unit*)Pvec.data(), (const Unit*)xVec.data(), n, b1); + size_t b2 = b ? b : mcl::ec::glvGetTheoreticBucketSize(n/4); + printf("% 8zd % 2zd", n, size_t(b2)); + CYBOZU_BENCH_C(" ", C, mcl::msm::mulVecAVX512, (Unit*)&P1, (Unit*)Pvec.data(), (const Unit*)xVec.data(), n, b2); } } @@ -2429,7 +2428,7 @@ void showParams() size_t nn = n/8*2; // /#SIMD*GLV size_t b1 = glvGetBucketSizeAVX512(nn); size_t c1 = mcl::ec::glvCost(nn, b1); - size_t b2 = mcl::ec::getTheoreticBucketSize(nn); + size_t b2 = mcl::ec::glvGetTheoreticBucketSize(nn); size_t c2 = mcl::ec::glvCost(nn, b2); printf("%zd|%zd|%zd|%zd|%zd|%.2f\n", d, b1, c1, b2, c2, c1/double(c2)); } @@ -2446,7 +2445,7 @@ int main(int argc, char *argv[]) opt.appendOpt(&d, 9, "d", ": set n to 1<