Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bench: clean things and remove dependency on gsl #13

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bench/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ REL_IMPLEMENTATION_DIR = $(subst $(BIN)/,$(SRC)/,$(@D))
ASSEMBLY_FILE = $(REL_IMPLEMENTATION_DIR)/$(OP_LOWERCASE).s

#
DEFINE ?= -DRUNS=11 -DTIMINGS=10000
DEFINE ?= -DRUNS=3 -DTIMINGS=10000
DEFINE_NS = -DJADE_NAMESPACE=$(NS_UPPERCASE) -DJADE_NAMESPACE_LC=$(NS_LOWERCASE)
INCLUDES = -I$(REL_IMPLEMENTATION_DIR)/include/ -I$(COMMON)/ -Iinclude/

RANDOMBYTES ?= $(EXT)/randombytes/librandombytes.a
RANDOMBYTES_INCLUDE ?= -I$(EXT)/randombytes/

BENCH_COMPILE = ($(CC) $(CFLAGS) -o $@ $(DEFINE) $(DEFINE_NS) $(INCLUDES) $(RANDOMBYTES_INCLUDE) $(COMMON)/crypto_$(OP_LOWERCASE).c $(ASSEMBLY_FILE) $(RANDOMBYTES) -lgsl) $(CI_CMD)
BENCH_COMPILE = ($(CC) $(CFLAGS) -o $@ $(DEFINE) $(DEFINE_NS) $(INCLUDES) $(RANDOMBYTES_INCLUDE) $(COMMON)/crypto_$(OP_LOWERCASE).c $(ASSEMBLY_FILE) $(RANDOMBYTES)) $(CI_CMD)


# -----------------------------------------------------------------------------
Expand Down
24 changes: 0 additions & 24 deletions bench/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
#define RUNS 1
#endif

#ifndef LOOPS
#define LOOPS 1
#endif

#ifndef TIMINGS
#define TIMINGS 10000
#endif
Expand Down Expand Up @@ -43,25 +39,5 @@
#define INC_OUTBYTES 2
#endif

//

#if defined(ST_ON)

#ifndef ST_MAX
#define ST_MAX 5
#endif

// 0.1 %
#ifndef ST_PER
#define ST_PER 0.1
#endif

#ifndef ST_CHK
#define ST_CHK (((double)ST_PER)/((double)100.0))
#endif

#endif
//

#endif

1 change: 0 additions & 1 deletion bench/common/cpucycles.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ static uint64_t cpucycles_median(uint64_t *cycles, size_t timings)
return median(cycles, timings-1);
}


#endif
64 changes: 20 additions & 44 deletions bench/common/crypto_scalarmult.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,23 @@

#include "config.h"
#include "cpucycles.c"
#include "increment.c"
#include "printbench.c"
#include "alignedcalloc.c"
#include "benchrandombytes.c"
#include "stability.c"

//

int main(int argc, char**argv)
{
size_t run, loop, i;
size_t run, i;
uint64_t cycles[TIMINGS];
uint64_t median_loops[OP1][LOOPS];

#if defined(ST_ON)
uint64_t median_runs[OP1][RUNS];
double sd_runs[OP1], mean_runs[OP1];
#endif

char *op1_str[] = {xstr(crypto_scalarmult_base,.csv),
xstr(crypto_scalarmult,.csv)};
char *op1_str[] = { xstr(crypto_scalarmult_base,.csv),
xstr(crypto_scalarmult,.csv)};

char *op1_str_short[] =
{ "scalarmult ",
"scalarmult_base"};
char *op1_str_short[] = { "scalarmult ",
"scalarmult_base" };

uint8_t *_m, *m; // CRYPTO_SCALARBYTES
uint8_t *_n, *n; // CRYPTO_SCALARBYTES
Expand All @@ -58,41 +50,25 @@ int main(int argc, char**argv)
p = alignedcalloc(&_p, CRYPTO_BYTES);
q = alignedcalloc(&_q, CRYPTO_BYTES);

_st_while_b

for(run = 0; run < RUNS; run++)
{
_st_reset_randombytes

for(loop = 0; loop < LOOPS; loop++)
{
benchrandombytes(m, CRYPTO_SCALARBYTES);
benchrandombytes(n, CRYPTO_SCALARBYTES);

// scalarmult_base
for (i = 0; i < TIMINGS; i++)
{ cycles[i] = cpucycles();
crypto_scalarmult_base(p,m); }
median_loops[1][loop] = cpucycles_median(cycles, TIMINGS);

// scalarmult
for (i = 0; i < TIMINGS; i++)
{ cycles[i] = cpucycles();
crypto_scalarmult(q,n,p); }
median_loops[0][loop] = cpucycles_median(cycles, TIMINGS);
}

_st_ifnotst(pb_print_1(argc, median_loops, op1_str, op1_str_short))
_st_store_1(median_runs, run, median_loops)
benchrandombytes(m, CRYPTO_SCALARBYTES);
benchrandombytes(n, CRYPTO_SCALARBYTES);

// scalarmult_base
for (i = 0; i < TIMINGS; i++)
{ cycles[i] = cpucycles();
crypto_scalarmult_base(p, m); }
median_runs[1][run] = cpucycles_median(cycles, TIMINGS);

// scalarmult
for (i = 0; i < TIMINGS; i++)
{ cycles[i] = cpucycles();
crypto_scalarmult(q, n, p); }
median_runs[0][run] = cpucycles_median(cycles, TIMINGS);
}

// all results must be within 'spec' at the same time
// does not save 'best' results
_st_check_1(sd_runs, mean_runs, median_runs)

_st_while_e

_st_print_1(argc, sd_runs, mean_runs, median_runs, op1_str, op1_str_short)
pb_print_1(argc, median_runs, op1_str, op1_str_short);

free(_m);
free(_n);
Expand Down
9 changes: 0 additions & 9 deletions bench/common/increment.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
#include "namespace.h"
#include <stdlib.h>




// iter by 1
static size_t inc_1(size_t len)
{
Expand All @@ -20,8 +17,6 @@ static size_t size_inc_1(size_t start, size_t end)
return end - start + 1;
}



// iter by <<1
static size_t inc_2(size_t len)
{
Expand All @@ -38,8 +33,6 @@ static size_t size_inc_2(size_t start, size_t end)
return r;
}



// iter 32 values in between each 2^n (plots)
static size_t inc_3(size_t len)
{
Expand All @@ -64,8 +57,6 @@ static size_t size_inc_3(size_t start, size_t end)
return r;
}



#define inc_in EVALUATOR(inc,INC_INBYTES)
#define size_inc_in EVALUATOR(size_inc,INC_INBYTES)

Expand Down
65 changes: 0 additions & 65 deletions bench/common/min.c

This file was deleted.

Loading
Loading