From ee49464e9745ed7da517b74791c7c85296184fd3 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Sun, 24 Mar 2019 12:34:59 +0100 Subject: mysteriously slow code --- test/monniaux/too_slow/Makefile | 27 ++++++++++++++ test/monniaux/too_slow/memset_from_bitsliced-aes.c | 43 ++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 test/monniaux/too_slow/Makefile create mode 100644 test/monniaux/too_slow/memset_from_bitsliced-aes.c (limited to 'test/monniaux/too_slow') diff --git a/test/monniaux/too_slow/Makefile b/test/monniaux/too_slow/Makefile new file mode 100644 index 00000000..bdc23def --- /dev/null +++ b/test/monniaux/too_slow/Makefile @@ -0,0 +1,27 @@ +include ../rules.mk + +PRODUCTS=memset_from_bitsliced-aes.gcc.host.out memset_from_bitsliced-aes.ccomp.host.out \ + memset_from_bitsliced-aes.gcc.k1c.out memset_from_bitsliced-aes.ccomp.k1c.out \ + memset_from_bitsliced-aes.gcc.k1c.s memset_from_bitsliced-aes.ccomp.k1c.s + +all: $(PRODUCTS) + +memset_from_bitsliced-aes.gcc.host.s memset_from_bitsliced-aes.ccomp.host.s memset_from_bitsliced-aes.gcc.k1c.s memset_from_bitsliced-aes.ccomp.k1c.s : ../clock.h + +memset_from_bitsliced-aes.ccomp.host: memset_from_bitsliced-aes.ccomp.host.o ../clock.gcc.host.o + $(CCOMP) $(CCOMPFLAGS) $+ -o $@ + +memset_from_bitsliced-aes.gcc.host: memset_from_bitsliced-aes.gcc.host.o ../clock.gcc.host.o + $(CC) $(CFLAGS) $+ -o $@ + +memset_from_bitsliced-aes.gcc.k1c: memset_from_bitsliced-aes.gcc.k1c.o ../clock.gcc.k1c.o + $(K1C_CC) $(K1C_CFLAGS) $+ -o $@ + +memset_from_bitsliced-aes.ccomp.k1c: memset_from_bitsliced-aes.ccomp.k1c.o ../clock.gcc.k1c.o + $(K1C_CCOMP) $(K1C_CCOMPFLAGS) $+ -o $@ + +clean: + -rm -f *.o *.s *.k1c + +.PHONY: clean + diff --git a/test/monniaux/too_slow/memset_from_bitsliced-aes.c b/test/monniaux/too_slow/memset_from_bitsliced-aes.c new file mode 100644 index 00000000..32137b55 --- /dev/null +++ b/test/monniaux/too_slow/memset_from_bitsliced-aes.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include "../clock.h" + +typedef uint64_t a; +a n[128]; +int o, bs_expand_key_k; +void b(a (*)[], uint8_t *); +void c(uint8_t d, uint8_t e, size_t f, uint8_t g, uint8_t iv) { + a i[1]; + b(i, g); +} + +void b(a (*i)[], uint8_t *j) { + for (; o < 176; o += 8) { + bs_expand_key_k = 4; + for (; bs_expand_key_k < 128; bs_expand_key_k += 128 / 64) + ; + memset(n, 0, sizeof(n)); + } +} + +void aes_ctr_test() { + uint8_t k = ""; + uint8_t l = ""; + uint8_t m = ""; + uint8_t output[4]; + c(output, m, 4, k, l); +} + +int main(int argc, char * argv[]) +{ + clock_prepare(); + + clock_start(); + + aes_ctr_test(); + clock_stop(); + print_total_clock(); + + return 0; +} -- cgit