Skip to content

Commit

Permalink
Merge pull request #61 from opencompl/sasha/make-csv
Browse files Browse the repository at this point in the history
add a cycles.csv target which recomputes only if the inputs or the xdsl commit change
  • Loading branch information
superlopuh authored Nov 3, 2023
2 parents c693d2e + 2881da7 commit 2f43517
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 3 deletions.
15 changes: 14 additions & 1 deletion kernels/Makefile.kernels
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,18 @@ all: $(TESTS)

allrun: $(RUN)

CYCLES_CSV := cycles.csv

# Generate the target file by combining the specified files from TESTS
$(CYCLES_CSV): $(addsuffix .csv, $(basename $(TESTS)))
rm $(CYCLES_CSV)
@echo "Combining CSV files specified in TESTS into $@"
@for file in $(TESTS); do \
filename=$$(basename $$file .x); \
csv_file=$$filename.csv; \
value=$$(cat $$csv_file); \
echo "$$filename,$$value" >> $@; \
done

clean:
rm -fr *.ll12 *.x *.o *.logs/ logs/
rm -fr *.ll12 *.x *.o *.logs/ logs/ *.csv
1 change: 1 addition & 0 deletions kernels/dsum/8x16xf32/baseline.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1202
7 changes: 7 additions & 0 deletions kernels/dsum/8x16xf32/cycles.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
baseline,1202
noalias,1202
ssr1d,253
ssr1d_frep1d,187
ssr2d,273
linalg,1089
scf,1227
1 change: 1 addition & 0 deletions kernels/dsum/8x16xf32/linalg.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1089
1 change: 1 addition & 0 deletions kernels/dsum/8x16xf32/maybe_update_xdsl_commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6a9d83ca561182afb9135daa5cca5e2bf8397158
1 change: 1 addition & 0 deletions kernels/dsum/8x16xf32/noalias.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1202
1 change: 1 addition & 0 deletions kernels/dsum/8x16xf32/scf.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1227
1 change: 1 addition & 0 deletions kernels/dsum/8x16xf32/ssr1d.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
253
1 change: 1 addition & 0 deletions kernels/dsum/8x16xf32/ssr1d_frep1d.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
187
1 change: 1 addition & 0 deletions kernels/dsum/8x16xf32/ssr2d.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
273
30 changes: 28 additions & 2 deletions snitch/Makefile.rules
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# vim: set ft=make:

.PHONY: traces
.PHONY: traces, force_xdsl_commit, maybe_update_xdsl_commit

MAKEFILE_RULES_DIRNAME := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))

Expand All @@ -17,6 +17,29 @@ MLIROPT = mlir-opt-16
MLIRTRANSLATE = mlir-translate-16
XDSLOPT = xdsl-opt

XDSL_DIR = /src/xdsl
XDSL_COMMIT_FILE = /src/xdsl_commit.txt

# Get the current commit hash of xdsl
CURRENT_XDSL_COMMIT := $(shell git -C $(XDSL_DIR) rev-parse HEAD)

# Read the last recorded commit hash from a file, if it exists
LAST_XDSL_COMMIT := $(shell cat $(XDSL_COMMIT_FILE) 2>/dev/null)

# Rule to update the recorded commit hash in a file
$(XDSL_COMMIT_FILE): maybe_update_xdsl_commit


# Rule to update the recorded commit hash in a file
maybe_update_xdsl_commit:
@if [ "$(CURRENT_XDSL_COMMIT)" != "$(LAST_XDSL_COMMIT)" ]; then \
echo $(CURRENT_XDSL_COMMIT) > $(XDSL_COMMIT_FILE); \
fi

# Phony target to force re-reading xdsl commit
force_xdsl_commit:
$(RM) $(SUBMODULE_COMMIT_FILE)

CFLAGS =
# Mixing .c and .ll files makes some flags, useful for the former,
# unused for the latter (e.g. -I)
Expand Down Expand Up @@ -101,7 +124,7 @@ XDSLOPTFLAGS += -t riscv-asm

# Assembly rules

%.S: %.xdsl.mlir
%.S: %.xdsl.mlir $(XDSL_COMMIT_FILE)
$(XDSLOPT) $(XDSLOPTFLAGS) $< -o $@

%.S: %.c
Expand Down Expand Up @@ -149,6 +172,9 @@ sim_%: %.logs/trace_hart_00000000.dasm
%.trace.txt %.trace.json: %.dasm
$(DASM) < $< | $(GENTRACE) --permissive -d $*.trace.json > $*.trace.txt

%.csv: %.x.logs/trace_hart_00000000.trace.json
grep -o '"cycles": [0-9]*' $< | cut -d " " -f 2 | sed -n '2p' > $@

define get_trace_targets
$(addsuffix .trace.txt, $(basename $(shell find $(1) -name 'trace_hart_*.dasm')))
endef
Expand Down
1 change: 1 addition & 0 deletions xdsl_commit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bd0de9285a21d5ca081c79710fc1d5eda0a289d1

0 comments on commit 2f43517

Please sign in to comment.