aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/sandbox
diff options
context:
space:
mode:
authorCyril SIX <cyril.six@kalray.eu>2019-07-11 18:24:02 +0200
committerCyril SIX <cyril.six@kalray.eu>2019-07-11 18:24:02 +0200
commitad8831a83451fc9802a8438256e68e25df5c243d (patch)
tree12bf45270e0ca5554540bc57c4f406d26436d485 /test/monniaux/sandbox
parent27b99ba6e3f93d098f276419ab57f4fb39297409 (diff)
downloadcompcert-kvx-ad8831a83451fc9802a8438256e68e25df5c243d.tar.gz
compcert-kvx-ad8831a83451fc9802a8438256e68e25df5c243d.zip
Premier jet du framework d'évaluation de perf (pas fini)
Diffstat (limited to 'test/monniaux/sandbox')
-rw-r--r--test/monniaux/sandbox/Makefile118
-rw-r--r--test/monniaux/sandbox/example.c13
-rw-r--r--test/monniaux/sandbox/f.c3
-rw-r--r--test/monniaux/sandbox/f.h1
4 files changed, 135 insertions, 0 deletions
diff --git a/test/monniaux/sandbox/Makefile b/test/monniaux/sandbox/Makefile
new file mode 100644
index 00000000..abc294dc
--- /dev/null
+++ b/test/monniaux/sandbox/Makefile
@@ -0,0 +1,118 @@
+# This Makefile does not depend on ../rules.mk
+
+# You can modify ALL_CFILES to include the files that should be linked
+ALL_CFILES=$(wildcard *.c)
+
+# Name of the target
+TARGET=toto
+
+# Name of the clock object
+CLOCK=../clock.gcc.k1c.o
+
+# Flags common to both compilers, then to gcc, then to ccomp
+ALL_CFLAGS=-g -Wall -D__K1C_COS__
+ALL_GCCFLAGS=$(ALL_CFLAGS) -std=c99 -Wextra -Werror=implicit
+ALL_CCOMPFLAGS=$(ALL_CFLAGS)
+
+# The compilers
+K1C_CC=k1-cos-gcc
+K1C_CCOMP=ccomp
+
+# Command to execute
+EXECUTE_CYCLES=k1-cluster --syscall=libstd_scalls.so --cycle-based --
+
+# You can define up to GCC4FLAGS and CCOMP4FLAGS
+GCC0FLAGS=$(ALL_GCCFLAGS) -O0
+GCC1FLAGS=$(ALL_GCCFLAGS) -O1
+GCC2FLAGS=$(ALL_GCCFLAGS) -O2
+GCC3FLAGS=$(ALL_GCCFLAGS) -O3
+GCC4FLAGS=
+CCOMP0FLAGS=$(ALL_CCOMPFLAGS) -O0
+CCOMP1FLAGS=$(ALL_CCOMPFLAGS) -fno-postpass
+CCOMP2FLAGS=$(ALL_CCOMPFLAGS)
+CCOMP3FLAGS=
+CCOMP4FLAGS=
+
+# Prefix names
+GCC0PREFIX=.gcc.o0
+GCC1PREFIX=.gcc.o1
+GCC2PREFIX=.gcc.o2
+GCC3PREFIX=.gcc.o3
+GCC4PREFIX=
+CCOMP0PREFIX=.ccomp.o0
+CCOMP1PREFIX=.ccomp.o1
+CCOMP2PREFIX=.ccomp.o2
+CCOMP3PREFIX=
+CCOMP4PREFIX=
+
+# List of outfiles, updated by gen_rules
+OUTFILES:=
+
+firstrule: all
+
+# $1: compiler
+# $2: compilation flags
+# $3: extension prefix
+define gen_rules
+
+%$(3).s: %.c
+ $(1) $(2) -S $$< -o $$@
+
+$(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)
+
+endef
+
+# Generic rules
+%.o: %.s
+ $(K1C_CC) $< -c -o $@
+
+%.out: %.bin
+ $(EXECUTE_CYCLES) $< | tee $@
+
+##
+# Generating the rules for all the compiler/flags..
+##
+
+ifneq ($(GCC0FLAGS),)
+$(eval $(call gen_rules,$(K1C_CC),$(GCC0FLAGS),$(GCC0PREFIX)))
+endif
+ifneq ($(GCC1FLAGS),)
+$(eval $(call gen_rules,$(K1C_CC),$(GCC1FLAGS),$(GCC1PREFIX)))
+endif
+ifneq ($(GCC2FLAGS),)
+$(eval $(call gen_rules,$(K1C_CC),$(GCC2FLAGS),$(GCC2PREFIX)))
+endif
+ifneq ($(GCC3FLAGS),)
+$(eval $(call gen_rules,$(K1C_CC),$(GCC3FLAGS),$(GCC3PREFIX)))
+endif
+ifneq ($(GCC4FLAGS),)
+$(eval $(call gen_rules,$(K1C_CC),$(GCC4FLAGS),$(GCC4PREFIX)))
+endif
+
+ifneq ($(CCOMP0FLAGS),)
+$(eval $(call gen_rules,$(K1C_CCOMP),$(CCOMP0FLAGS),$(CCOMP0PREFIX)))
+endif
+ifneq ($(CCOMP1FLAGS),)
+$(eval $(call gen_rules,$(K1C_CCOMP),$(CCOMP1FLAGS),$(CCOMP1PREFIX)))
+endif
+ifneq ($(CCOMP2FLAGS),)
+$(eval $(call gen_rules,$(K1C_CCOMP),$(CCOMP2FLAGS),$(CCOMP2PREFIX)))
+endif
+ifneq ($(CCOMP3FLAGS),)
+$(eval $(call gen_rules,$(K1C_CCOMP),$(CCOMP3FLAGS),$(CCOMP3PREFIX)))
+endif
+ifneq ($(CCOMP4FLAGS),)
+$(eval $(call gen_rules,$(K1C_CCOMP),$(CCOMP4FLAGS),$(CCOMP4PREFIX)))
+endif
+
+.PHONY: all clean
+all: $(OUTFILES)
+ echo $(OUTFILES)
+
+clean:
+ rm -f *.o *.s *.bin *.out
+
diff --git a/test/monniaux/sandbox/example.c b/test/monniaux/sandbox/example.c
new file mode 100644
index 00000000..774eb0b3
--- /dev/null
+++ b/test/monniaux/sandbox/example.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include "f.h"
+
+int main(void){
+ int i;
+ int S = 0;
+ for (i = 0; i < 1000; i++){
+ S += f(i, i*2);
+ }
+
+ printf("Final value: %d\n", S);
+ return 0;
+}
diff --git a/test/monniaux/sandbox/f.c b/test/monniaux/sandbox/f.c
new file mode 100644
index 00000000..7705c4f7
--- /dev/null
+++ b/test/monniaux/sandbox/f.c
@@ -0,0 +1,3 @@
+int f(int x, int y){
+ return x+y;
+}
diff --git a/test/monniaux/sandbox/f.h b/test/monniaux/sandbox/f.h
new file mode 100644
index 00000000..6ecab534
--- /dev/null
+++ b/test/monniaux/sandbox/f.h
@@ -0,0 +1 @@
+int f(int, int);