From 52aeb8026a9d9d2675eebf965d4ff3f87a0e2346 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Sun, 24 Mar 2019 18:00:19 +0100 Subject: demo ternary op --- test/monniaux/ternary/Makefile | 26 ++++++++++++++++++++++++++ test/monniaux/ternary/ternary.c | 23 +++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 test/monniaux/ternary/Makefile create mode 100644 test/monniaux/ternary/ternary.c (limited to 'test/monniaux/ternary') 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 +#include +#include +#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; +} -- cgit From cc65063de9adb38f9e3d5ccc8a85135ae269124b Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Sun, 24 Mar 2019 18:10:43 +0100 Subject: another ternary implementation --- test/monniaux/ternary/ternary.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'test/monniaux/ternary') diff --git a/test/monniaux/ternary/ternary.c b/test/monniaux/ternary/ternary.c index 45201ff8..79025639 100644 --- a/test/monniaux/ternary/ternary.c +++ b/test/monniaux/ternary/ternary.c @@ -5,10 +5,16 @@ typedef uint32_t data; +#if 0 +#define TERNARY(a, b, c) ((a) ? (b) : (c)) +#else +#define TERNARY(a, b, c) (((-(a)) & (b)) | ((-1+(a)) & (c))) +#endif + data silly_computation(void) { data x = 1; for(int i=0; i<10000; i++) { - x = x * (((x & 0x100) != 0) ? 45561U : 337777U); + x = x * TERNARY(((x & 0x100) != 0), 45561U, 337777U); } return x; } -- cgit From cba7f5e13ccea83e60ccfdf1895bef18bf50fe0a Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Fri, 5 Apr 2019 15:13:33 +0200 Subject: implement using our "pattern matching" --- test/monniaux/ternary/ternary.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'test/monniaux/ternary') diff --git a/test/monniaux/ternary/ternary.c b/test/monniaux/ternary/ternary.c index 79025639..61da9597 100644 --- a/test/monniaux/ternary/ternary.c +++ b/test/monniaux/ternary/ternary.c @@ -5,16 +5,23 @@ typedef uint32_t data; -#if 0 -#define TERNARY(a, b, c) ((a) ? (b) : (c)) +static inline int32_t ternary_int32(int32_t a, int32_t b, int32_t c) { + return (((-((a) == 0)) & (c)) | ((-((a) != 0)) & (b))); +} +static inline uint32_t ternary_uint32(uint32_t a, uint32_t b, uint32_t c) { + return ternary_int32(a, b, c); +} + +#if defined(__COMPCERT__) && defined(__K1C__) +#define TERNARY(a, b, c) ternary_uint32((a), (b), (c)) #else -#define TERNARY(a, b, c) (((-(a)) & (b)) | ((-1+(a)) & (c))) +#define TERNARY(a, b, c) ((a) ? (b) : (c)) #endif data silly_computation(void) { data x = 1; for(int i=0; i<10000; i++) { - x = x * TERNARY(((x & 0x100) != 0), 45561U, 337777U); + x = x * TERNARY(x & 0x100, 45561U, 337777U); } return x; } -- cgit From 98383707438a3e31ffd86a82b57fbe439945f777 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Fri, 5 Apr 2019 15:18:50 +0200 Subject: move patterns to include file --- test/monniaux/ternary/ternary.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'test/monniaux/ternary') diff --git a/test/monniaux/ternary/ternary.c b/test/monniaux/ternary/ternary.c index 61da9597..ed7de156 100644 --- a/test/monniaux/ternary/ternary.c +++ b/test/monniaux/ternary/ternary.c @@ -2,26 +2,14 @@ #include #include #include "../clock.h" +#include "../ternary.h" typedef uint32_t data; -static inline int32_t ternary_int32(int32_t a, int32_t b, int32_t c) { - return (((-((a) == 0)) & (c)) | ((-((a) != 0)) & (b))); -} -static inline uint32_t ternary_uint32(uint32_t a, uint32_t b, uint32_t c) { - return ternary_int32(a, b, c); -} - -#if defined(__COMPCERT__) && defined(__K1C__) -#define TERNARY(a, b, c) ternary_uint32((a), (b), (c)) -#else -#define TERNARY(a, b, c) ((a) ? (b) : (c)) -#endif - data silly_computation(void) { data x = 1; for(int i=0; i<10000; i++) { - x = x * TERNARY(x & 0x100, 45561U, 337777U); + x = x * TERNARY32(x & 0x100, 45561U, 337777U); } return x; } -- cgit From 24e97bd87918f2c487416744ba12a78aba35a9e5 Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Fri, 26 Apr 2019 16:35:30 +0200 Subject: Changes to include a -O1 -fschedule-insns2 gcc run as well --- test/monniaux/ternary/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'test/monniaux/ternary') diff --git a/test/monniaux/ternary/Makefile b/test/monniaux/ternary/Makefile index b051b397..7b1fe155 100644 --- a/test/monniaux/ternary/Makefile +++ b/test/monniaux/ternary/Makefile @@ -1,7 +1,7 @@ include ../rules.mk PRODUCTS=ternary.gcc.host.out ternary.ccomp.host.out \ - ternary.gcc.k1c.out ternary.ccomp.k1c.out \ + ternary.gcc.o1.k1c.out ternary.gcc.k1c.out ternary.ccomp.k1c.out \ ternary.gcc.k1c.s ternary.ccomp.k1c.s all: $(PRODUCTS) @@ -17,6 +17,9 @@ ternary.gcc.host: ternary.gcc.host.o ../clock.gcc.host.o ternary.gcc.k1c: ternary.gcc.k1c.o ../clock.gcc.k1c.o $(K1C_CC) $(K1C_CFLAGS) $+ -o $@ +ternary.gcc.o1.k1c: ternary.gcc.o1.k1c.o ../clock.gcc.k1c.o + $(K1C_CC) $(K1C_CFLAGS_O1) $+ -o $@ + ternary.ccomp.k1c: ternary.ccomp.k1c.o ../clock.gcc.k1c.o $(K1C_CCOMP) $(K1C_CCOMPFLAGS) $+ -o $@ -- cgit From 76abb605749d1b8ddcc842cecb258fa755d63ccf Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Tue, 14 May 2019 18:01:28 +0200 Subject: Avancement sur la génération de Makefile des benchmarks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/monniaux/ternary/Makefile | 29 ----------------------------- test/monniaux/ternary/make.proto | 1 + 2 files changed, 1 insertion(+), 29 deletions(-) delete mode 100644 test/monniaux/ternary/Makefile create mode 100644 test/monniaux/ternary/make.proto (limited to 'test/monniaux/ternary') diff --git a/test/monniaux/ternary/Makefile b/test/monniaux/ternary/Makefile deleted file mode 100644 index 7b1fe155..00000000 --- a/test/monniaux/ternary/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -include ../rules.mk - -PRODUCTS=ternary.gcc.host.out ternary.ccomp.host.out \ - ternary.gcc.o1.k1c.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.gcc.o1.k1c: ternary.gcc.o1.k1c.o ../clock.gcc.k1c.o - $(K1C_CC) $(K1C_CFLAGS_O1) $+ -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/make.proto b/test/monniaux/ternary/make.proto new file mode 100644 index 00000000..c5219f1c --- /dev/null +++ b/test/monniaux/ternary/make.proto @@ -0,0 +1 @@ +target: ternary -- cgit From 76c41fd907a3f7e7d574da4c075f30656e3ede9f Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Fri, 17 May 2019 14:14:38 +0200 Subject: Measures to CSV done --- test/monniaux/ternary/make.proto | 1 + test/monniaux/ternary/ternary.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'test/monniaux/ternary') diff --git a/test/monniaux/ternary/make.proto b/test/monniaux/ternary/make.proto index c5219f1c..1568ed07 100644 --- a/test/monniaux/ternary/make.proto +++ b/test/monniaux/ternary/make.proto @@ -1 +1,2 @@ target: ternary +measures: [cycles] diff --git a/test/monniaux/ternary/ternary.c b/test/monniaux/ternary/ternary.c index ed7de156..e8813a5c 100644 --- a/test/monniaux/ternary/ternary.c +++ b/test/monniaux/ternary/ternary.c @@ -19,6 +19,6 @@ int main() { clock_start(); data result = silly_computation(); clock_stop(); - printf("result=%" PRIu32 "\ncycles=%" PRIu64 "\n", result, get_total_clock()); + printf("result=%" PRIu32 "\ncycles:%" PRIu64 "\n", result, get_total_clock()); return 0; } -- cgit