From 69fa20d6babe8f9cad978e55332f21f77f3bc964 Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Fri, 12 Jul 2019 11:57:48 +0200 Subject: (#143) Mesure de cycles sur sandbox --- test/monniaux/sandbox/Makefile | 26 ++++++++++++++++++++++---- test/monniaux/sandbox/example.c | 9 +++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) (limited to 'test/monniaux/sandbox') 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 #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; } -- cgit