22#include " benchmark/benchmark.h"
33#include " gtest/gtest.h"
44
5- #define DEGREE 1 << 20
5+ #define NUM_COEFFS ( 1 << 20 )
66
77namespace zkir {
88namespace {
@@ -23,18 +23,18 @@ extern "C" void _mlir_ciface_intt_mont(Memref<i256> *output,
2323 Memref<i256> *input);
2424
2525void BM_ntt_benchmark (::benchmark::State &state) {
26- Memref<i256> input (1 , DEGREE );
26+ Memref<i256> input (1 , NUM_COEFFS );
2727 _mlir_ciface_input_generation (&input);
2828
29- Memref<i256> ntt (1 , DEGREE );
29+ Memref<i256> ntt (1 , NUM_COEFFS );
3030 for (auto _ : state) {
3131 _mlir_ciface_ntt (&ntt, &input);
3232 }
3333
34- Memref<i256> intt (1 , DEGREE );
34+ Memref<i256> intt (1 , NUM_COEFFS );
3535 _mlir_ciface_intt (&intt, &ntt);
3636
37- for (int i = 0 ; i < DEGREE ; i++) {
37+ for (int i = 0 ; i < NUM_COEFFS ; i++) {
3838 for (int j = 0 ; j < 4 ; j++) {
3939 EXPECT_EQ (intt.pget (0 , i)->limbs [j], input.pget (0 , i)->limbs [j]);
4040 }
@@ -44,18 +44,18 @@ void BM_ntt_benchmark(::benchmark::State &state) {
4444BENCHMARK (BM_ntt_benchmark)->Unit (::benchmark::kSecond );
4545
4646void BM_intt_benchmark (::benchmark::State &state) {
47- Memref<i256> input (1 , DEGREE );
47+ Memref<i256> input (1 , NUM_COEFFS );
4848 _mlir_ciface_input_generation (&input);
4949
50- Memref<i256> ntt (1 , DEGREE );
50+ Memref<i256> ntt (1 , NUM_COEFFS );
5151 _mlir_ciface_ntt (&ntt, &input);
5252
53- Memref<i256> intt (1 , DEGREE );
53+ Memref<i256> intt (1 , NUM_COEFFS );
5454 for (auto _ : state) {
5555 _mlir_ciface_intt (&intt, &ntt);
5656 }
5757
58- for (int i = 0 ; i < DEGREE ; i++) {
58+ for (int i = 0 ; i < NUM_COEFFS ; i++) {
5959 for (int j = 0 ; j < 4 ; j++) {
6060 EXPECT_EQ (intt.pget (0 , i)->limbs [j], input.pget (0 , i)->limbs [j]);
6161 }
@@ -67,18 +67,18 @@ void BM_intt_benchmark(::benchmark::State &state) {
6767BENCHMARK (BM_intt_benchmark)->Iterations (1 )->Unit(::benchmark::kSecond );
6868
6969void BM_ntt_mont_benchmark (::benchmark::State &state) {
70- Memref<i256> input (1 , DEGREE );
70+ Memref<i256> input (1 , NUM_COEFFS );
7171 _mlir_ciface_input_generation (&input);
7272
73- Memref<i256> ntt (1 , DEGREE );
73+ Memref<i256> ntt (1 , NUM_COEFFS );
7474 for (auto _ : state) {
7575 _mlir_ciface_ntt_mont (&ntt, &input);
7676 }
7777
78- Memref<i256> intt (1 , DEGREE );
78+ Memref<i256> intt (1 , NUM_COEFFS );
7979 _mlir_ciface_intt_mont (&intt, &ntt);
8080
81- for (int i = 0 ; i < DEGREE ; i++) {
81+ for (int i = 0 ; i < NUM_COEFFS ; i++) {
8282 for (int j = 0 ; j < 4 ; j++) {
8383 EXPECT_EQ (intt.pget (0 , i)->limbs [j], input.pget (0 , i)->limbs [j]);
8484 }
@@ -88,18 +88,18 @@ void BM_ntt_mont_benchmark(::benchmark::State &state) {
8888BENCHMARK (BM_ntt_mont_benchmark)->Unit (::benchmark::kSecond );
8989
9090void BM_intt_mont_benchmark (::benchmark::State &state) {
91- Memref<i256> input (1 , DEGREE );
91+ Memref<i256> input (1 , NUM_COEFFS );
9292 _mlir_ciface_input_generation (&input);
9393
94- Memref<i256> ntt (1 , DEGREE );
94+ Memref<i256> ntt (1 , NUM_COEFFS );
9595 _mlir_ciface_ntt_mont (&ntt, &input);
9696
97- Memref<i256> intt (1 , DEGREE );
97+ Memref<i256> intt (1 , NUM_COEFFS );
9898 for (auto _ : state) {
9999 _mlir_ciface_intt_mont (&intt, &ntt);
100100 }
101101
102- for (int i = 0 ; i < DEGREE ; i++) {
102+ for (int i = 0 ; i < NUM_COEFFS ; i++) {
103103 for (int j = 0 ; j < 4 ; j++) {
104104 EXPECT_EQ (intt.pget (0 , i)->limbs [j], input.pget (0 , i)->limbs [j]);
105105 }
0 commit comments