From d14774301b5c2358a3b6c4104c4f37762cd8bc4d Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Tue, 8 Mar 2016 14:56:14 +0900 Subject: [PATCH] benchmark of raw --- include/mcl/op.hpp | 6 +++--- sample/rawbench.cpp | 26 +++++++++++++++++++------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/include/mcl/op.hpp b/include/mcl/op.hpp index 52a1079..57f43b5 100644 --- a/include/mcl/op.hpp +++ b/include/mcl/op.hpp @@ -156,9 +156,9 @@ struct Op { , rp(0), montRedPU(0), montPU(0) , fp_negP(0), fp_invOp(0), fp_addP(0), fp_subP(0), fpDbl_modP(0) , fg(createFpGenerator()) - , fpDbl_add(0), fpDbl_sub() - , fpDbl_addP(0), fpDbl_subP() - , fpDbl_addNC(0), fpDbl_subNC() + , fpDbl_add(0), fpDbl_sub(0) + , fpDbl_addP(0), fpDbl_subP(0) + , fpDbl_addNC(0), fpDbl_subNC(0) , fpDbl_sqrPre(0), fpDbl_mulPre(0), fpDbl_mod(0) , xi_c(0) , fp2_add(0), fp2_sub(0), fp2_mul(0), fp2_neg(0) diff --git a/sample/rawbench.cpp b/sample/rawbench.cpp index a5bc47e..be7b387 100644 --- a/sample/rawbench.cpp +++ b/sample/rawbench.cpp @@ -39,7 +39,6 @@ void benchFpSub(const char *pStr, const char *xStr, const char *yStr, mcl::fp::M void benchRaw(const char *p, mcl::fp::Mode mode) { - const char *s = getModeStr(mode); Fp::setModulo(p, 0, mode); const mcl::fp::Op& op = Fp::getOp(); Fp fx = -1, fy; @@ -52,7 +51,7 @@ void benchRaw(const char *p, mcl::fp::Mode mode) memcpy(uy, fy.getUnit(), sizeof(fy)); double fp_sqrT, fp_addT, fp_subT, fp_mulT; double fpDbl_addT, fpDbl_subT; -// double fpDbl_sqrPreT, fpDbl_mulPreT, fpDbl_modT; + double fpDbl_sqrPreT, fpDbl_mulPreT, fpDbl_modT; // double fp2_mulT, fp2_sqrT; // double fp_addNCT, fp_subNCT, fpDbl_addNCT,fpDbl_subNCT; CYBOZU_BENCH_T(fp_sqrT, op.fp_sqr, ux, ux); @@ -61,13 +60,26 @@ void benchRaw(const char *p, mcl::fp::Mode mode) CYBOZU_BENCH_T(fp_mulT, op.fp_mul, ux, ux, ux); CYBOZU_BENCH_T(fpDbl_addT, op.fpDbl_add, ux, ux, ux); CYBOZU_BENCH_T(fpDbl_subT, op.fpDbl_sub, ux, uy, ux); - printf("%10s ", s); - const double Ttbl[] = { - fp_sqrT, fp_addT, fp_subT, fp_mulT, + CYBOZU_BENCH_T(fpDbl_sqrPreT, op.fpDbl_sqrPre, ux, ux); + CYBOZU_BENCH_T(fpDbl_mulPreT, op.fpDbl_mulPre, ux, ux, ux); + CYBOZU_BENCH_T(fpDbl_modT, op.fpDbl_mod, ux, ux); + printf("%s\n", getModeStr(mode)); + const char *tStrTbl[] = { + "fp_add", "fp_sub", "fp_sqr", "fp_mul", + "D_add", "D_sub", + "D_sqrPre", "D_mulPre", "D_mod", + }; + for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(tStrTbl); i++) { + printf(" %8s", tStrTbl[i]); + } + printf("\n"); + const double tTbl[] = { + fp_addT, fp_subT, fp_sqrT, fp_mulT, fpDbl_addT, fpDbl_subT, + fpDbl_sqrPreT, fpDbl_mulPreT, fpDbl_modT, }; - for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(Ttbl); i++) { - printf(" %8.2f", Ttbl[i]); + for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(tTbl); i++) { + printf(" %8.2f", tTbl[i]); } printf("\n"); }