aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/sandbox
diff options
context:
space:
mode:
authorCyril SIX <cyril.six@kalray.eu>2019-07-12 11:57:48 +0200
committerCyril SIX <cyril.six@kalray.eu>2019-07-12 11:57:48 +0200
commit69fa20d6babe8f9cad978e55332f21f77f3bc964 (patch)
treed39967a7db8d1d2a98103721e4ffcd36328730fc /test/monniaux/sandbox
parent5d69b44d38730c7112634bf6f815168065ac9aad (diff)
downloadcompcert-kvx-69fa20d6babe8f9cad978e55332f21f77f3bc964.tar.gz
compcert-kvx-69fa20d6babe8f9cad978e55332f21f77f3bc964.zip
(#143) Mesure de cycles sur sandbox
Diffstat (limited to 'test/monniaux/sandbox')
-rw-r--r--test/monniaux/sandbox/Makefile26
-rw-r--r--test/monniaux/sandbox/example.c9
2 files changed, 31 insertions, 4 deletions
diff --git a/test/monniaux/sandbox/Makefile b/test/monniaux/sandbox/Makefile
index abc294dc..11a179fc 100644
--- a/test/monniaux/sandbox/Makefile
+++ b/test/monniaux/sandbox/Makefile
@@ -1,4 +1,5 @@
# This Makefile does not depend on ../rules.mk
+SHELL=bash
# You can modify ALL_CFILES to include the files that should be linked
ALL_CFILES=$(wildcard *.c)
@@ -9,8 +10,11 @@ TARGET=toto
# Name of the clock object
CLOCK=../clock.gcc.k1c.o
+# Maximum amount of time measures (see cycles.h)
+MAX_MEASURES=10
+
# Flags common to both compilers, then to gcc, then to ccomp
-ALL_CFLAGS=-g -Wall -D__K1C_COS__
+ALL_CFLAGS=-g -Wall -D__K1C_COS__ -DMAX_MEASURES=$(MAX_MEASURES)
ALL_GCCFLAGS=$(ALL_CFLAGS) -std=c99 -Wextra -Werror=implicit
ALL_CCOMPFLAGS=$(ALL_CFLAGS)
@@ -48,6 +52,9 @@ CCOMP4PREFIX=
# List of outfiles, updated by gen_rules
OUTFILES:=
+# First line of the CSV file
+FIRSTLINE:=benches
+
firstrule: all
# $1: compiler
@@ -62,7 +69,7 @@ $(TARGET)$(3).bin: $(ALL_CFILES:.c=$(3).o) $(CLOCK)
$(K1C_CC) $$+ -lm -o $$@
OUTFILES:=$(OUTFILES) $(TARGET)$(3).out
-#OUTFILES=$(shell echo $(OUTFILES) $(TARGET)$(3).out)
+FIRSTLINE:=$(FIRSTLINE), $(3)
endef
@@ -109,9 +116,20 @@ ifneq ($(CCOMP4FLAGS),)
$(eval $(call gen_rules,$(K1C_CCOMP),$(CCOMP4FLAGS),$(CCOMP4PREFIX)))
endif
+measures.csv: $(OUTFILES)
+ @echo $(FIRSTLINE) > $@
+ @for ((i=0;i<=$(MAX_MEASURES);i++)) do\
+ first=$$(grep "($$i) cycles" $(firstword $(OUTFILES)));\
+ if test ! -z "$$first"; then\
+ line="$(TARGET) $$i";\
+ $(foreach outfile,$(OUTFILES),line="$$line, $$(grep "($$i) cycles" $(outfile) | cut -d':' -f2)"; ):;\
+ echo "$$line" >> $@;\
+ fi;\
+ done;\
+ echo "$@ created!"
+
.PHONY: all clean
-all: $(OUTFILES)
- echo $(OUTFILES)
+all: measures.csv
clean:
rm -f *.o *.s *.bin *.out
diff --git a/test/monniaux/sandbox/example.c b/test/monniaux/sandbox/example.c
index 774eb0b3..4fec922d 100644
--- a/test/monniaux/sandbox/example.c
+++ b/test/monniaux/sandbox/example.c
@@ -1,13 +1,22 @@
#include <stdio.h>
#include "f.h"
+#include "../cycles.h"
int main(void){
+ cycle_count_config();
+
int i;
int S = 0;
+
+ TIMESTOP(0)
for (i = 0; i < 1000; i++){
S += f(i, i*2);
}
+ TIMESTOP(1)
printf("Final value: %d\n", S);
+ TIMESTOP(2)
+
+ TIMEPRINT(2)
return 0;
}