diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/monniaux/ternary/Makefile | 26 | ||||
-rw-r--r-- | test/monniaux/ternary/ternary.c | 23 |
2 files changed, 49 insertions, 0 deletions
diff --git a/test/monniaux/ternary/Makefile b/test/monniaux/ternary/Makefile new file mode 100644 index 00000000..b051b397 --- /dev/null +++ b/test/monniaux/ternary/Makefile @@ -0,0 +1,26 @@ +include ../rules.mk + +PRODUCTS=ternary.gcc.host.out ternary.ccomp.host.out \ + ternary.gcc.k1c.out ternary.ccomp.k1c.out \ + ternary.gcc.k1c.s ternary.ccomp.k1c.s + +all: $(PRODUCTS) + +ternary.gcc.host.s ternary.ccomp.host.s ternary.gcc.k1c.s ternary.ccomp.k1c.s : ../clock.h + +ternary.ccomp.host: ternary.ccomp.host.o ../clock.gcc.host.o + $(CCOMP) $(CCOMPFLAGS) $+ -o $@ + +ternary.gcc.host: ternary.gcc.host.o ../clock.gcc.host.o + $(CC) $(CFLAGS) $+ -o $@ + +ternary.gcc.k1c: ternary.gcc.k1c.o ../clock.gcc.k1c.o + $(K1C_CC) $(K1C_CFLAGS) $+ -o $@ + +ternary.ccomp.k1c: ternary.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/ternary/ternary.c b/test/monniaux/ternary/ternary.c new file mode 100644 index 00000000..45201ff8 --- /dev/null +++ b/test/monniaux/ternary/ternary.c @@ -0,0 +1,23 @@ +#include <stdint.h> +#include <stdio.h> +#include <inttypes.h> +#include "../clock.h" + +typedef uint32_t data; + +data silly_computation(void) { + data x = 1; + for(int i=0; i<10000; i++) { + x = x * (((x & 0x100) != 0) ? 45561U : 337777U); + } + return x; +} + +int main() { + clock_prepare(); + clock_start(); + data result = silly_computation(); + clock_stop(); + printf("result=%" PRIu32 "\ncycles=%" PRIu64 "\n", result, get_total_clock()); + return 0; +} |