summaryrefslogtreecommitdiff
path: root/make
diff options
context:
space:
mode:
authorJan Huwald <jh@sotun.de>2012-05-07 20:01:51 (GMT)
committerJan Huwald <jh@sotun.de>2012-05-07 20:01:51 (GMT)
commit420d2ef464d4a741028e132e662d5626806a41f5 (patch)
tree1aca6eb512e4ed0fb5f3c10c528cb998b6ffd695 /make
Initial commitHEADmaster
Diffstat (limited to 'make')
-rw-r--r--make/asm.make8
-rw-r--r--make/doc.make18
-rw-r--r--make/model.make23
-rw-r--r--make/pgopt.make18
-rw-r--r--make/plot.make111
-rw-r--r--make/reports.make7
-rw-r--r--make/simulate.make35
-rw-r--r--make/test.make27
8 files changed, 247 insertions, 0 deletions
diff --git a/make/asm.make b/make/asm.make
new file mode 100644
index 0000000..ccbd6d8
--- /dev/null
+++ b/make/asm.make
@@ -0,0 +1,8 @@
+asm/bin/%: asm/%.s
+ @mkdir -p asm/bin
+ $(CC) $(CCOPTS) $(ERR) -g $< -o $@
+
+# depend on std-executable to get their dependecies
+asm/%.s: core/%.cpp bin/%
+ @mkdir -p asm
+ $(CC) $(CCOPTS) $(ERR) $< -I. -Iproperties/default -S -o $@
diff --git a/make/doc.make b/make/doc.make
new file mode 100644
index 0000000..545d483
--- /dev/null
+++ b/make/doc.make
@@ -0,0 +1,18 @@
+.PHONY: doc
+doc: doc/include_graph.pdf doc/techreport.pdf
+
+doc/include_graph.svg: toolbin/gen_include_dep_graph.sh core/*.?pp
+ (cd core && ../toolbin/gen_include_dep_graph.sh *.?pp) | dot -Tsvg -o $@
+
+doc/%.pdf: doc/%.svg
+ inkscape $< -A $@
+
+doc/%.pdf: doc/%.tex
+ rubber -d $<
+
+doc/%.tex: doc/%.org
+ emacs -batch -l ~/.emacs --eval "(setq org-export-headline-levels 5)" --visit=$< --funcall org-export-as-latex-batch
+
+.PHONY: doc/clean
+doc/clean:
+ rm -f doc/*{aux,log,out,pdf,png,tex,toc,~} doc/include_graph.svg
diff --git a/make/model.make b/make/model.make
new file mode 100644
index 0000000..758cf55
--- /dev/null
+++ b/make/model.make
@@ -0,0 +1,23 @@
+# model/$basefile_$name_value.auto.model
+.SECONDEXPANSION:
+model/%.auto.model: BASE=$(shell echo "$(@F)" | sed 's/\(.*\).auto.model/\1/' | cut -f1 -d_)
+model/%.auto.model: NAME=$(shell echo "$(@F)" | sed 's/\(.*\).auto.model/\1/' | cut -f2 -d_)
+model/%.auto.model: VALUE=$(shell echo "$(@F)" | sed 's/\(.*\).auto.model/\1/' | cut -f3 -d_)
+model/%.auto.model: model/$$(BASE).model
+ @[ -n "$(BASE)" -a -n "$(NAME)" -a -n "$(VALUE)" ] || (echo "Missing parameter"; false)
+ @echo Generating $@
+ @echo -e 'include "$(BASE)";\n' \
+ 'const const { double $(NAME) = $(VALUE); }' \
+ > $@
+
+# model/$basefile_$name_value.auto.model
+.SECONDEXPANSION:
+model/%.autoint.model: BASE=$(shell echo "$(@F)" | sed 's/\(.*\).autoint.model/\1/' | cut -f1 -d_)
+model/%.autoint.model: NAME=$(shell echo "$(@F)" | sed 's/\(.*\).autoint.model/\1/' | cut -f2 -d_)
+model/%.autoint.model: VALUE=$(shell echo "$(@F)" | sed 's/\(.*\).autoint.model/\1/' | cut -f3 -d_)
+model/%.autoint.model: model/$$(BASE).model
+ @[ -n "$(BASE)" -a -n "$(NAME)" -a -n "$(VALUE)" ] || (echo "Missing parameter"; false)
+ @echo Generating $@
+ @echo -e 'include "$(BASE)";\n' \
+ 'const const { int $(NAME) = $(VALUE); }' \
+ > $@ \ No newline at end of file
diff --git a/make/pgopt.make b/make/pgopt.make
new file mode 100644
index 0000000..ecfd971
--- /dev/null
+++ b/make/pgopt.make
@@ -0,0 +1,18 @@
+ifeq ($(PGOPT), 1)
+ PGOPTS =-fprofile-dir=tmp/pgopt/profiles -fprofile-use
+
+# add dependency to all bins that should be profiled
+bin/simulate.dep: tmp/pgopt/run/simulate/.finish
+endif
+
+tmp/pgopt/bin/%: core/%.cpp properties/default/properties.hpp
+ mkdir -p $(shell dirname $@) tmp/pgopt/profiles
+ $(CC) $(CCOPTS) $(ERR) -fprofile-dir=$(shell pwd)/tmp/pgopt/profiles -fprofile-generate $< -I. -Iproperties/default -o $@
+
+# HACK: put some additional programs here
+tmp/pgopt/run/%/.finish: tmp/pgopt/bin/% tmp/pgopt/run/%/.bootstrap tmp/pgopt/bin/spike_in tmp/pgopt/bin/spike_out
+ cd $(shell dirname $@) && ../../../../$< 60.0
+ cd $(shell dirname $@) && ../../bin/spike_in 0 0 60 > /dev/null
+ cd $(shell dirname $@) && ../../bin/spike_out 0 0 60 > /dev/null
+ cd $(shell dirname $@) && rm * .bootstrap
+ touch $@
diff --git a/make/plot.make b/make/plot.make
new file mode 100644
index 0000000..514958d
--- /dev/null
+++ b/make/plot.make
@@ -0,0 +1,111 @@
+define make-dir =
+@mkdir -p $(shell dirname "$@")
+endef
+
+# plot/$model/$seed/$prop_$from_$till_$step.replay.data
+.SECONDEXPANSION:
+plot/%.replay.data: SIM_MODEL=$(shell echo -n "$(@D)/" | tac -s/ | cut -s -d/ -f2)
+plot/%.replay.data: PLOT_NAME=$(shell echo "$(@F)" | sed 's/\(.*\).replay.data/\1/' | cut -f1 -d_)
+plot/%.replay.data: PLOT_INST=$(shell echo "$(@F)" | sed 's/\(.*\).replay.data/\1/' | cut -f2 -d_)
+plot/%.replay.data: PLOT_FROM=$(shell echo "$(@F)" | sed 's/\(.*\).replay.data/\1/' | cut -f3 -d_)
+plot/%.replay.data: SIM_UNTIL=$(shell echo "$(@F)" | sed 's/\(.*\).replay.data/\1/' | cut -f4 -d_)
+plot/%.replay.data: PLOT_STEP=$(shell echo "$(@F)" | sed 's/\(.*\).replay.data/\1/' | cut -f5 -d_)
+plot/%.replay.data: bin/$$(SIM_MODEL)-replay $$(shell dirname sim/%)/.$$(SIM_UNTIL).simulate
+ @[ -n "$(SIM_MODEL)" -a -n "$(PLOT_NAME)" -a -n "$(PLOT_INST)" -a -n "$(PLOT_FROM)" -a -n "$(SIM_UNTIL)" -a -n "$(PLOT_STEP)" ] || (echo "Missing parameter"; false)
+ @echo "Replaying $(PLOT_NAME) of instance $(PLOT_INST) of model $(SIM_MODEL) from $(PLOT_FROM) to $(SIM_UNTIL)"
+ @mkdir -p $(shell dirname $@)
+ @cd "$(shell dirname $@ | sed 's/^plot/sim/')" && ../../../$< $(PLOT_NAME) $(PLOT_INST) $(PLOT_FROM) $(SIM_UNTIL) $(PLOT_STEP) > ../../../$@~
+ @mv "$@~" "$@"
+
+plot/%.replay.x11: plot/%.replay.data
+ echo "plot '$<' using 1:2 with lines" | gnuplot -persist
+
+plot/%.replay.pdf: PLOT_NAME=$(shell echo "$(@F)" | sed 's/\(.*\).replay.data/\1/' | cut -f1 -d_)
+plot/%.replay.pdf: PLOT_INST=$(shell echo "$(@F)" | sed 's/\(.*\).replay.data/\1/' | cut -f2 -d_)
+plot/%.replay.pdf: plot/%.replay.data R/plot.R
+ @echo "Plotting $@"
+ @R < R/plot.R --vanilla --args "$<" "$@~" "$(PLOT_NAME)" "$(PLOT_INST)" > /dev/null
+ @mv "$@~" "$@"
+
+
+# plot/$model/$seed/$prop_$from_$till_$step.coarse_replay.data
+.SECONDEXPANSION:
+plot/%.coarse_replay.data: SIM_MODEL=$(shell echo -n "$(@D)/" | tac -s/ | cut -s -d/ -f2)
+plot/%.coarse_replay.data: PLOT_NAME=$(shell echo "$(@F)" | sed 's/\(.*\).coarse_replay.data/\1/' | cut -f1 -d_)
+plot/%.coarse_replay.data: PLOT_INST=$(shell echo "$(@F)" | sed 's/\(.*\).coarse_replay.data/\1/' | cut -f2 -d_)
+plot/%.coarse_replay.data: PLOT_FROM=$(shell echo "$(@F)" | sed 's/\(.*\).coarse_replay.data/\1/' | cut -f3 -d_)
+plot/%.coarse_replay.data: SIM_UNTIL=$(shell echo "$(@F)" | sed 's/\(.*\).coarse_replay.data/\1/' | cut -f4 -d_)
+plot/%.coarse_replay.data: bin/$$(SIM_MODEL)-coarse_replay $$(shell dirname sim/%)/.$$(SIM_UNTIL).simulate
+ @[ -n "$(SIM_MODEL)" -a -n "$(PLOT_NAME)" -a -n "$(PLOT_INST)" -a -n "$(PLOT_FROM)" -a -n "$(SIM_UNTIL)" ] || (echo "Missing parameter"; false)
+ @echo "Coarsely replaying $(PLOT_NAME) of instance $(PLOT_INST) of model $(SIM_MODEL) from $(PLOT_FROM) to $(SIM_UNTIL)"
+ $(make-dir)
+ @cd "$(shell dirname $@ | sed 's/^plot/sim/')" && ../../../$< $(PLOT_NAME) $(PLOT_INST) $(PLOT_FROM) $(SIM_UNTIL) > ../../../$@~
+ @mv "$@~" "$@"
+
+plot/%.coarse_replay.x11: plot/%.coarse_replay.data
+ echo "plot '$<' using 1:2 with lines" | gnuplot -persist
+
+plot/%.coarse_replay.pdf: PLOT_NAME=$(shell echo "$(@F)" | sed 's/\(.*\).coarse_replay.data/\1/' | cut -f1 -d_)
+plot/%.coarse_replay.pdf: PLOT_INST=$(shell echo "$(@F)" | sed 's/\(.*\).coarse_replay.data/\1/' | cut -f2 -d_)
+plot/%.coarse_replay.pdf: plot/%.coarse_replay.data R/plot.R
+ @echo "Plotting $@"
+ @R < R/plot.R --vanilla --args "$<" "$@" "$(PLOT_NAME)" "$(PLOT_INST)" > /dev/null
+
+# plot/$model/$seed/$from_$till.all_spikes.data
+.SECONDEXPANSION:
+plot/%.all_spikes.data: SIM_MODEL=$(shell echo -n "$(@D)/" | tac -s/ | cut -s -d/ -f2)
+plot/%.all_spikes.data: PLOT_FROM=$(shell echo "$(@F)" | sed 's/\(.*\).all_spikes.data/\1/' | cut -f1 -d_)
+plot/%.all_spikes.data: SIM_UNTIL=$(shell echo "$(@F)" | sed 's/\(.*\).all_spikes.data/\1/' | cut -f2 -d_)
+plot/%.all_spikes.data: bin/all_spikes $$(shell dirname sim/%)/.$$(SIM_UNTIL).simulate
+ @[ -n "$(SIM_MODEL)" -a -n "$(PLOT_FROM)" -a -n "$(SIM_UNTIL)" ] || (echo "Missing parameter"; false)
+ @echo "Dumping all spikes of model $(SIM_MODEL) from $(PLOT_FROM) to $(SIM_UNTIL)"
+ $(make-dir)
+ @cd "$(shell dirname $@ | sed 's/^plot/sim/')" && ../../../$< $(PLOT_FROM) $(SIM_UNTIL) > ../../../$@~
+ @mv "$@~" "$@"
+
+plot/%.all_spikes.x11: plot/%.all_spikes.data
+ @echo "plot '$<' using 1:2 with dots" | gnuplot -persist
+
+plot/%.all_spikes.pdf: plot/%.all_spikes.data R/plot_all.R
+ @echo "Plotting $@"
+ @R < R/plot_all.R --vanilla --args "$<" "$@~" &> /dev/null
+ @mv "$@~" "$@"
+
+# plot/$model/$seed/$time_.synapse_heatmap.data
+.SECONDEXPANSION:
+plot/%.synapse_heatmap.data: SIM_MODEL=$(shell echo -n "$(@D)/" | tac -s/ | cut -s -d/ -f2)
+plot/%.synapse_heatmap.data: PLOT_NAME=$(shell echo "$(@F)" | sed 's/\(.*\).synapse_heatmap.data/\1/' | cut -f1 -d_)
+plot/%.synapse_heatmap.data: SIM_TIME=$(shell echo "$(@F)" | sed 's/\(.*\).synapse_heatmap.data/\1/' | cut -f2 -d_)
+plot/%.synapse_heatmap.data: bin/$$(SIM_MODEL)-coarse_replay $$(shell dirname sim/%)/.$$(SIM_UNTIL).simulate
+ @[ -n "$(SIM_MODEL)" -a -n "$(PLOT_FROM)" -a -n "$(SIM_TIME)" ] || (echo "Missing parameter"; false)
+ @echo "Heatmap of $(PLOT_NAME) model $(SIM_MODEL) at $(SIM_TIME)"
+ $(make-dir)
+ @cd "$(shell dirname $@ | sed 's/^plot/sim/')" && ../../../$< $(PLOT_NAME) $(SIM_TIME) $(SIM_TIME) > ../../../$@~
+ @mv "$@~" "$@"
+
+plot/%.synapse_heatmap.pdf: plot/%.synapse_heatmap.data R/plot_all.R
+ @echo "Plotting $@"
+ @R < R/hm.R --vanilla --args "$<" "$@~" &> /dev/null
+ @mv "$@~" "$@"
+
+
+
+# plot/$model/$seed/$prop_$from_$till_$step.replay_mean.data
+.SECONDEXPANSION:
+plot/%.replay_mean.data: plot/%.replay.data
+ @echo Compute mean over $<
+ @(echo "scale=10"; grep -v '^#' $< | cut -f2- | tr "\t" "+" \
+ | sed 's/e/*10^/g' | sed 'ss\(.*\)s(\1)/'$$( \
+ grep -v '^#' $< | head -n1 | tr -dc "\t" | wc -c \
+ )'s') | bc > $@.raw
+ @grep -v '^#' $< | cut -f1 | paste - $@.raw > $@~
+ @mv "$@~" "$@"
+
+plot/%.replay_mean.x11: plot/%.replay_mean.data
+ echo "plot '$<' using 1:2 with lines" | gnuplot -persist
+
+plot/%.replay_mean.pdf: PLOT_NAME=$(shell echo "$(@F)" | sed 's/\(.*\).replay_mean.data/\1/' | cut -f1 -d_)
+plot/%.replay_mean.pdf: plot/%.replay_mean.data R/plot.R
+ @echo "Plotting $@"
+ @R < R/plot.R --vanilla --args "$<" "$@~" "$(PLOT_NAME)" "0" > /dev/null
+ @mv "$@~" "$@"
diff --git a/make/reports.make b/make/reports.make
new file mode 100644
index 0000000..c7e897d
--- /dev/null
+++ b/make/reports.make
@@ -0,0 +1,7 @@
+.PHONY: reports
+reports: $(REPORT)
+ @echo "=== REPORTS FINISHED ==="
+
+report_%: bin/report_%
+ @echo "=== $@ ==="
+ @cd tmp && ../$<
diff --git a/make/simulate.make b/make/simulate.make
new file mode 100644
index 0000000..001ce46
--- /dev/null
+++ b/make/simulate.make
@@ -0,0 +1,35 @@
+.SECONDEXPANSION:
+sim/%/.topology: SIM_MODEL=$(shell echo -n "$(@D)/" | tac -s/ | cut -s -d/ -f2)
+sim/%/.topology: SIM_SEED= $(shell echo -n "$(@D)/" | tac -s/ | cut -s -d/ -f1)
+%/.topology: bin/$$(SIM_MODEL)-convert_topology
+ @echo "Generating topology for model $(SIM_MODEL) with random seed $(SIM_SEED)"
+ @mkdir -p "$(shell dirname $@)"
+ @[ ! -f "$@" -a ! -f "$@.prelim" ] || toolbin/warn_data
+ @date > "$@.prelim"
+ @R=`pwd`; cd "$(shell dirname $@)" && $$R/octave/random_topo.octave $(SIM_SEED) 2>plain_topology | grep --line-buffered '^generation'
+ @R=`pwd`; cd "$(shell dirname $@)" && $$R/bin/$(SIM_MODEL)-convert_topology <plain_topology
+ @date > "$@"
+ @rm "$@.prelim"
+
+
+.SECONDEXPANSION:
+sim/%/.bootstrap: SIM_MODEL=$(shell echo -n "$(@D)/" | tac -s/ | cut -s -d/ -f2)
+sim/%/.bootstrap: SIM_SEED= $(shell echo -n "$(@D)/" | tac -s/ | cut -s -d/ -f1)
+%/.bootstrap: bin/$$(SIM_MODEL)-bootstrap %/.topology
+ @echo "Bootstrapping model $(SIM_MODEL) with random seed $(SIM_SEED)"
+ @mkdir -p "$(shell dirname $@)"
+ @[ ! -f "$@" -a ! -f "$@.prelim" ] || toolbin/warn_data
+ @date > "$@.prelim"
+ @R=`pwd`; cd "$(shell dirname $@)" && $$R/bin/$(SIM_MODEL)-bootstrap $(SIM_SEED)
+ @date > "$@"
+ @rm "$@.prelim"
+
+# sim/$model/$seed/.$time.simulate
+.SECONDEXPANSION:
+sim/%.simulate: SIM_MODEL=$(shell echo -n "$(@D)/" | tac -s/ | cut -s -d/ -f2)
+sim/%.simulate: SIM_UNTIL=$(shell basename "$(@F)" | sed 's/.\(.*\).simulate/\1/')
+sim/%.simulate: bin/$$(SIM_MODEL)-simulate $$(shell dirname sim/%)/.bootstrap
+ @echo "=== Simulating model $(SIM_MODEL) until $(SIM_UNTIL) ==="
+ @[ -n "$(SIM_MODEL)" -a -n "$(SIM_SEED)" -a -n "$(SIM_UNTIL)" ] || (echo "missing sim parameter"; false)
+ @R=`pwd`; cd "$(shell dirname $@)" && flock -o .lock $$R/bin/$(SIM_MODEL)-simulate $(SIM_UNTIL) 2>.$(SIM_UNTIL).simulate.log
+ @date > "$@"
diff --git a/make/test.make b/make/test.make
new file mode 100644
index 0000000..e57180c
--- /dev/null
+++ b/make/test.make
@@ -0,0 +1,27 @@
+.PHONY: test speedtest alltest
+test: $(TEST) exec
+
+# targets with long runtime
+speedtest: $(SPEEDTEST)
+alltest: test speedtest
+
+test_%: tmp/.passed.test_%
+ @echo "=== $@ passed ==="
+
+tmp/%/.test.init_dir:
+ @mkdir -p $(shell dirname $@)
+ @rm $(shell dirname $@)/{*,.test*} 2>/dev/null || true
+ @date > $@
+
+.SECONDEXPANSION:
+tmp/.passed.test_%: DIR=tmp/$(shell basename $<)
+tmp/.passed.test_%: bin/test_% tmp/test_%/.test.init_dir
+ @echo "running $(DIR)"
+ @(cd "$(DIR)" && ../../$<) || (if [ -z "$$KEEPTEST" ]; then rm -r "$(DIR)"; fi; false)
+ @rm -r "$(DIR)"
+ @date > $@
+
+# TODO: bootstrap has to wait for dir creation (yes, this is a race
+# cond right now - good luck)
+tmp/.passed.test_sim_loop: tmp/test_sim_loop/.bootstrap
+tmp/.passed.test_filter: tmp/test_filter/.topology
contact: Jan Huwald // Impressum