Skip to content

Commit

Permalink
a little optimize mulGLV
Browse files Browse the repository at this point in the history
  • Loading branch information
herumi committed May 31, 2024
1 parent 72634d4 commit 1f1d818
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/msm_avx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,10 +1098,9 @@ struct EcM {
FpM::mul(y, y, r);
z = FpM::one_;
}
template<size_t w, bool isProj=true, bool mixed=false>
static void makeTable(EcM *tbl, const EcM& P)
template<bool isProj=true, bool mixed=false>
static void makeTable(EcM *tbl, size_t tblN, const EcM& P)
{
const size_t tblN = 1<<w;
tbl[0].clear<isProj>();
tbl[1] = P;
dbl<isProj>(tbl[2], P);
Expand Down Expand Up @@ -1137,7 +1136,7 @@ struct EcM {
Q.y = P.y;
Q.z = P.z;
}
#if 1
#if 0
// Treat idx as an unsigned integer
// 33.6M clk
template<bool isProj=true, bool mixed=false>
Expand All @@ -1148,7 +1147,7 @@ struct EcM {
// QQQ (n=1024) isProj=T : 36.8, isProj=F&&mixed=F : 36.0, isProj=F&&mixed=T : 34.6
Vec a[2], b[2];
EcM tbl1[tblN], tbl2[tblN];
makeTable<w, isProj, mixed>(tbl1, P);
makeTable<isProj, mixed>(tbl1, tblN, P);
if (!isProj && mixed) normalizeJacobiVec<EcM, tblN-1>(tbl1+1);
for (size_t i = 0; i < tblN; i++) {
mulLambda(tbl2[i], tbl1[i]);
Expand Down Expand Up @@ -1216,15 +1215,15 @@ struct EcM {
}
}
// Treat idx as a signed integer
// 34.6M clk
// 32.4M clk
template<bool isProj=true, bool mixed=false>
static void mulGLV(EcM& Q, const EcM& P, const Vec y[4])
{
const size_t w = 5;
const size_t tblN = (1<<(w-1))+1; // [0, 2^(w-1)]
Vec a[2], b[2];
EcM tbl1[tblN], tbl2[tblN];
makeTable<w, isProj, mixed>(tbl1, P);
makeTable<isProj, mixed>(tbl1, tblN, P);
if (!isProj && mixed) normalizeJacobiVec<EcM, tblN-1>(tbl1+1);
for (size_t i = 0; i < tblN; i++) {
mulLambda(tbl2[i], tbl1[i]);
Expand Down

0 comments on commit 1f1d818

Please sign in to comment.