Skip to content

Commit 88bd6d5

Browse files
jakemasjammychiou1
authored andcommitted
added pointwise to bench_components
Signed-off-by: Jake Massimo <[email protected]>
1 parent 640f30b commit 88bd6d5

File tree

1 file changed

+34
-18
lines changed

1 file changed

+34
-18
lines changed

test/bench_components_mldsa.c

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <string.h>
1111
#include "../mldsa/ntt.h"
1212
#include "../mldsa/poly.h"
13+
#include "../mldsa/polyvec.h"
1314
#include "../mldsa/randombytes.h"
1415
#include "hal.h"
1516

@@ -22,29 +23,36 @@ static int cmp_uint64_t(const void *a, const void *b)
2223
return (int)((*((const uint64_t *)a)) - (*((const uint64_t *)b)));
2324
}
2425

25-
#define BENCH(txt, code) \
26-
for (i = 0; i < NTESTS; i++) \
27-
{ \
28-
mld_randombytes((uint8_t *)data0, sizeof(data0)); \
29-
for (j = 0; j < NWARMUP; j++) \
30-
{ \
31-
code; \
32-
} \
33-
\
34-
t0 = get_cyclecounter(); \
35-
for (j = 0; j < NITERATIONS; j++) \
36-
{ \
37-
code; \
38-
} \
39-
t1 = get_cyclecounter(); \
40-
(cyc)[i] = t1 - t0; \
41-
} \
42-
qsort((cyc), NTESTS, sizeof(uint64_t), cmp_uint64_t); \
26+
#define BENCH(txt, code) \
27+
for (i = 0; i < NTESTS; i++) \
28+
{ \
29+
mld_randombytes((uint8_t *)data0, sizeof(data0)); \
30+
mld_randombytes((uint8_t *)&polyvecl_a, sizeof(polyvecl_a)); \
31+
mld_randombytes((uint8_t *)&polyvecl_b, sizeof(polyvecl_b)); \
32+
mld_randombytes((uint8_t *)polyvecl_mat, sizeof(polyvecl_mat)); \
33+
for (j = 0; j < NWARMUP; j++) \
34+
{ \
35+
code; \
36+
} \
37+
\
38+
t0 = get_cyclecounter(); \
39+
for (j = 0; j < NITERATIONS; j++) \
40+
{ \
41+
code; \
42+
} \
43+
t1 = get_cyclecounter(); \
44+
(cyc)[i] = t1 - t0; \
45+
} \
46+
qsort((cyc), NTESTS, sizeof(uint64_t), cmp_uint64_t); \
4347
printf(txt " cycles=%" PRIu64 "\n", (cyc)[NTESTS >> 1] / NITERATIONS);
4448

4549
static int bench(void)
4650
{
4751
MLD_ALIGN int32_t data0[256];
52+
MLD_ALIGN mld_poly poly_out;
53+
MLD_ALIGN mld_polyvecl polyvecl_a, polyvecl_b;
54+
MLD_ALIGN mld_polyveck polyveck_out;
55+
MLD_ALIGN mld_polyvecl polyvecl_mat[MLDSA_K];
4856
uint64_t cyc[NTESTS];
4957
unsigned i, j;
5058
uint64_t t0, t1;
@@ -53,6 +61,14 @@ static int bench(void)
5361
BENCH("poly_ntt", mld_poly_ntt((mld_poly *)data0))
5462
BENCH("poly_invntt_tomont", mld_poly_invntt_tomont((mld_poly *)data0))
5563

64+
/* pointwise */
65+
BENCH("polyvecl_pointwise_acc_montgomery",
66+
mld_polyvecl_pointwise_acc_montgomery(&poly_out, &polyvecl_a,
67+
&polyvecl_b))
68+
BENCH("polyvec_matrix_pointwise_montgomery",
69+
mld_polyvec_matrix_pointwise_montgomery(&polyveck_out, polyvecl_mat,
70+
&polyvecl_b))
71+
5672
return 0;
5773
}
5874

0 commit comments

Comments
 (0)