Skip to content

Commit 3cf2b4a

Browse files
dot-asmflaub
authored andcommitted
multi_scalar.c: fine-tune MSM for small amounts of inputs.
Fixes supranational#235.
1 parent 680e865 commit 3cf2b4a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/multi_scalar.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,14 @@ static size_t pippenger_window_size(size_t npoints)
273273

274274
for (wbits=0; npoints>>=1; wbits++) ;
275275

276-
return wbits>12 ? wbits-3 : (wbits>4 ? wbits-2 : (wbits ? 2 : 1));
276+
if (wbits > 12)
277+
return wbits - 3;
278+
else if (wbits > 8)
279+
return wbits - 2;
280+
else if (wbits > 4)
281+
return wbits - 1;
282+
283+
return wbits ? 2 : 1;
277284
}
278285

279286
#define DECLARE_PRIVATE_POINTXYZZ(ptype, bits) \
@@ -408,10 +415,11 @@ void prefix##s_mult_pippenger(ptype *ret, \
408415
{ \
409416
if (npoints == 1) { \
410417
prefix##_from_affine(ret, points[0]); \
411-
prefix##_mult(ret, ret, scalars[0], nbits); \
418+
ptype##_mult_w5(ret, ret, scalars[0], nbits); \
412419
return; \
413420
} \
414-
if ((npoints * sizeof(ptype##_affine) * 8 * 3) <= SCRATCH_LIMIT) { \
421+
if ((npoints * sizeof(ptype##_affine) * 8 * 3) <= SCRATCH_LIMIT && \
422+
npoints < 32) { \
415423
ptype##_affine *table = alloca(npoints * sizeof(ptype##_affine) * 8); \
416424
ptype##s_precompute_wbits(table, 4, points, npoints); \
417425
ptype##s_mult_wbits(ret, table, 4, npoints, scalars, nbits, NULL); \

0 commit comments

Comments
 (0)