benchmark of raw

dev
MITSUNARI Shigeo 9 years ago
parent 98aa972ebc
commit d14774301b
  1. 6
      include/mcl/op.hpp
  2. 26
      sample/rawbench.cpp

@ -156,9 +156,9 @@ struct Op {
, rp(0), montRedPU(0), montPU(0) , rp(0), montRedPU(0), montPU(0)
, fp_negP(0), fp_invOp(0), fp_addP(0), fp_subP(0), fpDbl_modP(0) , fp_negP(0), fp_invOp(0), fp_addP(0), fp_subP(0), fpDbl_modP(0)
, fg(createFpGenerator()) , fg(createFpGenerator())
, fpDbl_add(0), fpDbl_sub() , fpDbl_add(0), fpDbl_sub(0)
, fpDbl_addP(0), fpDbl_subP() , fpDbl_addP(0), fpDbl_subP(0)
, fpDbl_addNC(0), fpDbl_subNC() , fpDbl_addNC(0), fpDbl_subNC(0)
, fpDbl_sqrPre(0), fpDbl_mulPre(0), fpDbl_mod(0) , fpDbl_sqrPre(0), fpDbl_mulPre(0), fpDbl_mod(0)
, xi_c(0) , xi_c(0)
, fp2_add(0), fp2_sub(0), fp2_mul(0), fp2_neg(0) , fp2_add(0), fp2_sub(0), fp2_mul(0), fp2_neg(0)

@ -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) void benchRaw(const char *p, mcl::fp::Mode mode)
{ {
const char *s = getModeStr(mode);
Fp::setModulo(p, 0, mode); Fp::setModulo(p, 0, mode);
const mcl::fp::Op& op = Fp::getOp(); const mcl::fp::Op& op = Fp::getOp();
Fp fx = -1, fy; Fp fx = -1, fy;
@ -52,7 +51,7 @@ void benchRaw(const char *p, mcl::fp::Mode mode)
memcpy(uy, fy.getUnit(), sizeof(fy)); memcpy(uy, fy.getUnit(), sizeof(fy));
double fp_sqrT, fp_addT, fp_subT, fp_mulT; double fp_sqrT, fp_addT, fp_subT, fp_mulT;
double fpDbl_addT, fpDbl_subT; 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 fp2_mulT, fp2_sqrT;
// double fp_addNCT, fp_subNCT, fpDbl_addNCT,fpDbl_subNCT; // double fp_addNCT, fp_subNCT, fpDbl_addNCT,fpDbl_subNCT;
CYBOZU_BENCH_T(fp_sqrT, op.fp_sqr, ux, ux); 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(fp_mulT, op.fp_mul, ux, ux, ux);
CYBOZU_BENCH_T(fpDbl_addT, op.fpDbl_add, 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); CYBOZU_BENCH_T(fpDbl_subT, op.fpDbl_sub, ux, uy, ux);
printf("%10s ", s); CYBOZU_BENCH_T(fpDbl_sqrPreT, op.fpDbl_sqrPre, ux, ux);
const double Ttbl[] = { CYBOZU_BENCH_T(fpDbl_mulPreT, op.fpDbl_mulPre, ux, ux, ux);
fp_sqrT, fp_addT, fp_subT, fp_mulT, 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_addT, fpDbl_subT,
fpDbl_sqrPreT, fpDbl_mulPreT, fpDbl_modT,
}; };
for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(Ttbl); i++) { for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(tTbl); i++) {
printf(" %8.2f", Ttbl[i]); printf(" %8.2f", tTbl[i]);
} }
printf("\n"); printf("\n");
} }

Loading…
Cancel
Save