Skip to content
Snippets Groups Projects
Commit 11cfbda4 authored by Alban Gruin's avatar Alban Gruin
Browse files

Replace dtor by a coccinelle patch, use -Os instead of -O3, lighter destructor

parent 65c78308
No related branches found
No related tags found
No related merge requests found
bench/build/ bench/build/
bench/sic.patch
...@@ -57,29 +57,41 @@ kernels = \ ...@@ -57,29 +57,41 @@ kernels = \
isqrt \ isqrt \
jfdctint \ jfdctint \
lms \ lms \
ludcmp \
matrix1 \ matrix1 \
md5 \ md5 \
minver \ minver \
pm \
prime \ prime \
quicksort \
rad2deg \ rad2deg \
recursion \ recursion \
sha \
st st
sequentials = \ sequentials = \
adpcm_dec \ adpcm_dec \
adpcm_enc \ adpcm_enc \
cjpeg_transupp \ ammunition \
cjpeg_wrbmp \ anagram \
dijkstra \ audiobeam \
fmref \ cjpeg_transupp \
g723_enc \ cjpeg_wrbmp \
gsm_dec \ dijkstra \
h264_dec \ epic \
huff_dec \ fmref \
huff_enc \ g723_enc \
ndes \ gsm_dec \
petrinet \ gsm_enc \
statemate h264_dec \
huff_dec \
huff_enc \
ndes \
petrinet \
rijndael_dec \
rijndael_enc \
statemate \
susan
bmarks = $(addprefix kernel/,$(kernels)) $(addprefix sequential/,$(sequentials)) bmarks = $(addprefix kernel/,$(kernels)) $(addprefix sequential/,$(sequentials))
...@@ -96,22 +108,24 @@ RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump ...@@ -96,22 +108,24 @@ RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump
SRC_BSP_C = $(wildcard $(bsp_dir)/hal/*.c) $(wildcard $(bsp_dir)/drivers/uart/*.c) SRC_BSP_C = $(wildcard $(bsp_dir)/hal/*.c) $(wildcard $(bsp_dir)/drivers/uart/*.c)
SRC_BSP_S = $(wildcard $(bsp_dir)/hal/*.S) SRC_BSP_S = $(wildcard $(bsp_dir)/hal/*.S)
COCCI_SRC_FILES = $(shell find kernel/ sequential/ -type f -name "*.c")
OBJ_BSP_C = $(addprefix build/,$(SRC_BSP_C:.c=.o)) OBJ_BSP_C = $(addprefix build/,$(SRC_BSP_C:.c=.o))
OBJ_BSP_S = $(addprefix build/,$(SRC_BSP_S:.S=.o)) OBJ_BSP_S = $(addprefix build/,$(SRC_BSP_S:.S=.o))
OBJ_BSP = $(OBJ_BSP_S) $(OBJ_BSP_C) OBJ_BSP = $(OBJ_BSP_S) $(OBJ_BSP_C)
BSP_INCS = -Ibsp/config -Ibsp/drivers/uart -Ibsp/hal BSP_INCS = -Ibsp/config -Ibsp/drivers/uart -Ibsp/hal
INCS = $(BSP_INCS) INCS = $(BSP_INCS) -Isic
FLAGS_STR := "$(RISCV_CFLAGS) $(RISCV_LDFLAGS) " FLAGS_STR := "$(RISCV_CFLAGS) $(RISCV_LDFLAGS) "
CFLAGS ?= -DPREALLOCATE=1 -fvisibility=hidden -DSTDIO_THRU_UART -O3 -mcmodel=medany -static -Wall -pedantic CFLAGS ?= -DPREALLOCATE=1 -fvisibility=hidden -DSTDIO_THRU_UART -Os -mcmodel=medany -static -Wall -pedantic
RISCV_CFLAGS := -DPERFORMANCE_RUN=1 \ RISCV_CFLAGS := -DPERFORMANCE_RUN=1 \
-DITERATIONS=3 \ -DITERATIONS=3 \
-DFLAGS_STR=\"$(FLAGS_STR)\" \ -DFLAGS_STR=\"$(FLAGS_STR)\" \
-Wno-unknown-pragmas \ -Wno-unknown-pragmas \
-DPREALLOCATE=1 -fvisibility=hidden -DSTDIO_THRU_UART -O3 -mcmodel=medany -static -Wall -pedantic -DPREALLOCATE=1 -fvisibility=hidden -DSTDIO_THRU_UART -Os -mcmodel=medany -static -Wall -pedantic
RISCV_LDFLAGS = -Lbuild/ -lcva6 -static -nostartfiles -T bsp/config/link.ld RISCV_LDFLAGS = -Lbuild/ -lcva6 -static -nostartfiles -T bsp/config/link.ld
...@@ -130,7 +144,7 @@ $(1): build/artifacts/$(1).D ...@@ -130,7 +144,7 @@ $(1): build/artifacts/$(1).D
$(1): build/artifacts/$(1).hex $(1): build/artifacts/$(1).hex
$(1): build/artifacts/$(1).bin $(1): build/artifacts/$(1).bin
$(1): build/mem/$(1).mem $(1): build/mem/$(1).mem
build/artifacts/$(1).riscv: build/libcva6.a build/dtor.o $$($(1)_OBJ_FILES) build/artifacts/$(1).riscv: build/libcva6.a $$($(1)_OBJ_FILES)
$$(DIR_GUARD) $$(DIR_GUARD)
@echo " LD $$@" @echo " LD $$@"
@$$(RISCV_GCC) $$(RISCV_CFLAGS) -o $$@ $$^ $$(RISCV_LDFLAGS) @$$(RISCV_GCC) $$(RISCV_CFLAGS) -o $$@ $$^ $$(RISCV_LDFLAGS)
...@@ -153,10 +167,10 @@ build/artifacts/%.bin: build/artifacts/%.riscv ...@@ -153,10 +167,10 @@ build/artifacts/%.bin: build/artifacts/%.riscv
@echo " OBJCOPY $< -> $@" @echo " OBJCOPY $< -> $@"
@$(RISCV_OBJCOPY) -O binary $< $@ @$(RISCV_OBJCOPY) -O binary $< $@
build/libcva6.a: $(OBJ_BSP) build/libcva6.a: $(OBJ_BSP) build/sic/siccsrs.o
$(DIR_GUARD) $(DIR_GUARD)
@echo " AR $< -> $@" @echo " AR $< -> $@"
@$(RISCV_AR) rcs build/libcva6.a $(OBJ_BSP) @$(RISCV_AR) rcs build/libcva6.a $^
build/%.o: %.c build/%.o: %.c
$(DIR_GUARD) $(DIR_GUARD)
...@@ -173,8 +187,12 @@ build/mem/%.mem: build/artifacts/%.bin ...@@ -173,8 +187,12 @@ build/mem/%.mem: build/artifacts/%.bin
@echo " BIN2MEM $< -> $@" @echo " BIN2MEM $< -> $@"
@$(utils_dir)/bin2mem.py $< $@ @$(utils_dir)/bin2mem.py $< $@
sic.patch: sic.cocci
@echo " SPATCH $<"
@spatch --sp-file $< $(COCCI_SRC_FILES) --patch . >$@
clean: clean:
@echo " RM build/" @echo " RM build/"
@rm -rf build/ @rm -rf build/ sic.patch
.PHONY: all clean .PHONY: all clean
@@
@@
+ #include <siccsrs.h>
int main(void)
{
...
+ siccsrs();
return ...;
}
...@@ -2,10 +2,20 @@ ...@@ -2,10 +2,20 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "siccsrs.h"
#define READCSR(_t, counter) \ #define READCSR(_t, counter) \
asm volatile("csrr %0, " # counter : "=r" (_t)) asm volatile ("csrr %0, " # counter : "=r" (_t))
static inline void print_uint(const char *msg, uint32_t val) {
char buffer[sizeof(uint32_t) * 8 + 1] = {0};
utoa(val, buffer, 10);
fputs(msg, stdout);
fputs(buffer, stdout);
}
static void __attribute__((destructor)) dtor(void) { void siccsrs(void) {
uint32_t brpending, mempending, lsu, imiss; uint32_t brpending, mempending, lsu, imiss;
READCSR(brpending, 0xB11); READCSR(brpending, 0xB11);
...@@ -13,8 +23,9 @@ static void __attribute__((destructor)) dtor(void) { ...@@ -13,8 +23,9 @@ static void __attribute__((destructor)) dtor(void) {
READCSR(lsu, 0xB13); READCSR(lsu, 0xB13);
READCSR(imiss, 0xB14); READCSR(imiss, 0xB14);
printf("==== dtor ====\n" print_uint("brpending: ", brpending);
"brpending: %ld; mempending: %ld; lsu: %ld; imiss: %ld\n" print_uint("; mempending: ", mempending);
"==== end of dtor ====\n", print_uint("; lsu: ", lsu);
brpending, mempending, lsu, imiss); print_uint("; imiss: ", imiss);
puts("");
} }
#ifndef __SICCSRS_H_
#define __SICCSRS_H_
void siccsrs(void);
#endif /* __SICCSRS_H_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment