Skip to content

Commit

Permalink
compute v2 before v1, then we can use mixed jacobi
Browse files Browse the repository at this point in the history
  • Loading branch information
herumi committed May 15, 2024
1 parent 350848f commit b3f5713
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion include/mcl/ec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,9 @@ void normalizeVecT(Eout& Q, Ein& P, size_t n, size_t N = 256)
split x to (a, b) such that x = a + b L where 0 <= a, b <= L, 0 <= x <= r-1 = L^2+L
if adj is true, then 0 <= a < L, 0 <= b <= L+1
*/
inline void optimizedSplitRawForBLS12_381(Unit a[2], Unit b[2], const Unit x[4], bool adj = true)
inline void optimizedSplitRawForBLS12_381(Unit a[2], Unit b[2], const Unit x[4])
{
const bool adj = false;
assert(sizeof(Unit) == 8);
/*
z = -0xd201000000010000
Expand Down
11 changes: 6 additions & 5 deletions src/msm_avx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,16 +1144,17 @@ struct EcM {
if (!first) for (int k = 0; k < w; k++) EcM::dbl<isProj>(Q, Q);
EcM T;
Vec idx;
idx = vand(vpsrlq(v1, bitLen-w-j*w), g_vmask4);
// compute v2 first before v1. see misc/internal.md
idx = vand(vpsrlq(v2, bitLen-w-j*w), g_vmask4);
if (first) {
Q.gather(tbl1, idx);
Q.gather(tbl2, idx);
first = false;
} else {
T.gather(tbl1, idx);
T.gather(tbl2, idx);
add<isProj, mixed>(Q, Q, T);
}
idx = vand(vpsrlq(v2, bitLen-w-j*w), g_vmask4);
T.gather(tbl2, idx);
idx = vand(vpsrlq(v1, bitLen-w-j*w), g_vmask4);
T.gather(tbl1, idx);
add<isProj, mixed>(Q, Q, T);
}
}
Expand Down

0 comments on commit b3f5713

Please sign in to comment.