diff options
author | Jan Huwald <jh@sotun.de> | 2012-05-07 19:53:27 (GMT) |
---|---|---|
committer | Jan Huwald <jh@sotun.de> | 2012-05-07 19:53:27 (GMT) |
commit | 00b209240138660db1ded3ef3870023964ce6e4e (patch) | |
tree | 8ffaec780b060bdc478929aa714b8af2ee760671 /code/glue |
Diffstat (limited to 'code/glue')
-rw-r--r-- | code/glue/Makefile | 8 | ||||
-rwxr-xr-x | code/glue/da-controlled-sim-wrapper | 62 | ||||
-rwxr-xr-x | code/glue/distill-performance | 5 | ||||
-rwxr-xr-x | code/glue/exec-matlab | 8 | ||||
-rwxr-xr-x | code/glue/extract-matlab-matrix | 43 | ||||
-rwxr-xr-x | code/glue/plot_sliding_perf | 24 | ||||
-rwxr-xr-x | code/glue/plot_spike_time_hist | 19 | ||||
-rwxr-xr-x | code/glue/print-params | 3 | ||||
-rwxr-xr-x | code/glue/repeat-trace-cmd | bin | 0 -> 9863 bytes | |||
-rw-r--r-- | code/glue/repeat-trace-cmd.c | 27 | ||||
-rwxr-xr-x | code/glue/sim-wrapper | 24 |
11 files changed, 223 insertions, 0 deletions
diff --git a/code/glue/Makefile b/code/glue/Makefile new file mode 100644 index 0000000..35bd16b --- /dev/null +++ b/code/glue/Makefile @@ -0,0 +1,8 @@ +.PHONY: all clean +all: repeat-trace-cmd + +clean: + rm *~ repeat-trace-cmd + +repeat-trace-cmd: repeat-trace-cmd.c + gcc repeat-trace-cmd.c -o repeat-trace-cmd -O23
\ No newline at end of file diff --git a/code/glue/da-controlled-sim-wrapper b/code/glue/da-controlled-sim-wrapper new file mode 100755 index 0000000..918de4a --- /dev/null +++ b/code/glue/da-controlled-sim-wrapper @@ -0,0 +1,62 @@ +#!/bin/sh + +# check param count +if [ ! $# -eq 7 ]; then + echo 'wrong parameter count (see the source for parameter order)' >&2 + # 1. model name (e.g. the "if" from "sim-if") + # 2. controller name (relative to trainer-dir) + # 3. input_neuron_file + # 4. input_synapse_file + # 5. output_neuron_file + # 6. output_synapse_file + # 7. performance output + exit 1 +fi + +# determine the path of the simulaton program +SIM=`dirname $0`/../core/sim-$1 +if [ ! -x $SIM ]; then + echo "executable ($SIM) does not exist" >&2 + exit 1 +fi + +# determine the path of the controller programm +CTL=`dirname $0`/../trainer/$2-$1 +if [ ! -x $CTL ]; then + echo "executable ($CTL) does not exist" >&2 + exit 1 +fi + + +# create tmp dir +FIFODIR=`mktemp -td fasimu.XXXXXXXXXX` + +# create fifos +mkfifo $FIFODIR/spike_in +mkfifo $FIFODIR/spike_out +mkfifo $FIFODIR/trace_in +mkfifo $FIFODIR/global_in +mkfifo $FIFODIR/global_out + +# TODO: check if an additional i/o file is an executable + +# launch controller and simulator +#echo $CTL - $FIFODIR/trace_in $FIFODIR/global_in $FIFODIR/global_out $FIFODIR/spike_in $FIFODIR/spike_out "2> trainer.err &" +$CTL $7 $FIFODIR/trace_in $FIFODIR/global_in $FIFODIR/global_out $FIFODIR/spike_in $FIFODIR/spike_out 2> trainer.err & + +#echo $SIM "2> sim.err" $3 $4 $FIFODIR/spike_in $FIFODIR/global_in $5 $6 $FIFODIR/spike_out $FIFODIR/global_out $FIFODIR/trace_in +$SIM 2> sim.err $3 $4 $FIFODIR/spike_in $FIFODIR/global_in $5 $6 $FIFODIR/spike_out $FIFODIR/global_out $FIFODIR/trace_in + +# hint: simulator params are + # input_neuron_file + # input_synapse_file + # input_spike_file + # input_global_file + # output_neuron_file + # output_synapse_file + # output_spike_file + # output_global_file + # trace_commando_file + +# delete tmp dir +rm -R $FIFODIR diff --git a/code/glue/distill-performance b/code/glue/distill-performance new file mode 100755 index 0000000..af90f2f --- /dev/null +++ b/code/glue/distill-performance @@ -0,0 +1,5 @@ +#!/bin/bash + +if [ -f performance.out.raw ]; then + cat performance.out.raw | tr "\r" "\n" | grep ^PERF | cut -d" " -f2 > performance.out +fi diff --git a/code/glue/exec-matlab b/code/glue/exec-matlab new file mode 100755 index 0000000..ccb0d23 --- /dev/null +++ b/code/glue/exec-matlab @@ -0,0 +1,8 @@ +#!/bin/sh + +if [ -f $0.m ]; then + env - bash -c "(echo \"$1\"; cat $0.m) | matlab -nodesktop" +# env - bash -c "cat $0.m | octave" +else + echo file $0.m not found +fi diff --git a/code/glue/extract-matlab-matrix b/code/glue/extract-matlab-matrix new file mode 100755 index 0000000..b5021a4 --- /dev/null +++ b/code/glue/extract-matlab-matrix @@ -0,0 +1,43 @@ +#!/bin/bash + +# TODO: use tail instead of cat where only the top of the file is needed + +# extract the multiplier of the matrix +MUL=`cat $1 \ +| egrep -o 'e\+[0-9]* \*' \ +| tr -d 'e+ *'` + +if [ -z "$MUL" ]; then + MUL=1 +fi + +# get the number of cols +COLS=`cat $1 \ +| egrep '([:space:]*([01](\.[0-9]*){0,1})[:space:]*)+$' \ +| tail -n1 \ +| wc -w` + +# read the matrix, multiply to correct value and put it out +cat $1 \ +| egrep '([:space:]*([01](\.[0-9]*){0,1})[:space:]*)+$' \ +| tr " " "\n" \ +| egrep -v '^$' \ +| while read; do + echo $MUL '*' $REPLY +done \ +| bc \ +| sed 's/\([0-9]\+\)\.0*/\1/' \ +| ( I=1 + while read; do + if [ $I -eq $COLS ]; then + echo "$REPLY" + I=1 + else + echo -n "$REPLY," + I=$(( $I + 1 )) + fi + done ) + + +# old debug stuff +#echo $MUL $COLS
\ No newline at end of file diff --git a/code/glue/plot_sliding_perf b/code/glue/plot_sliding_perf new file mode 100755 index 0000000..c71d42b --- /dev/null +++ b/code/glue/plot_sliding_perf @@ -0,0 +1,24 @@ +#!/bin/bash + +if [ -f "performance.out" ]; then + echo "x=load('performance.out'); + x=(x > 1); + y=length(x); + p=zeros(y-100,1); + for i=1:(y-100) + p(i)=mean(x(i:(i+100),1)); + end + p" \ + | octave -q \ + | tr -dc "0123456789.\n" \ + |grep -v "^$" \ + > performance.out.sliding-avg + + PWD=`pwd` + + echo "set title 'performance (sliding avg, window size 100) $PWD' + set terminal postscript + set output 'performance.out.ps' + plot 'performance.out.sliding-avg' using 1 with lines, 0.5" \ + | gnuplot +fi diff --git a/code/glue/plot_spike_time_hist b/code/glue/plot_spike_time_hist new file mode 100755 index 0000000..ad45305 --- /dev/null +++ b/code/glue/plot_spike_time_hist @@ -0,0 +1,19 @@ +#!/bin/bash + +if [ -f "spikes.out" ]; then + cat spikes.out | cut -d, -f1 > spikes.out.timing + + echo "x = load('spikes.out.timing'); + y = hist(x, ceil(max(x)/10)); + y'" \ + | octave -q \ + | tr -dc "0123456789.\n" \ + | grep -v "^$" \ + > spikes.out.binned-timing + + echo "set title 'population frequency $PWD' + set terminal postscript + set output 'spikes.out.binned-timing.ps' + plot 'spikes.out.binned-timing' using 1 with lines" \ + | gnuplot +fi
\ No newline at end of file diff --git a/code/glue/print-params b/code/glue/print-params new file mode 100755 index 0000000..3df1e19 --- /dev/null +++ b/code/glue/print-params @@ -0,0 +1,3 @@ +#!/bin/bash + +echo $@ diff --git a/code/glue/repeat-trace-cmd b/code/glue/repeat-trace-cmd Binary files differnew file mode 100755 index 0000000..b889e0b --- /dev/null +++ b/code/glue/repeat-trace-cmd diff --git a/code/glue/repeat-trace-cmd.c b/code/glue/repeat-trace-cmd.c new file mode 100644 index 0000000..ac35733 --- /dev/null +++ b/code/glue/repeat-trace-cmd.c @@ -0,0 +1,27 @@ +#include <stdio.h> + +int main(int argc, char **argv) { + double t, dt; + long n; + + if (argc != 4) { + fprintf(stderr, "ERROR: wrong argument count\nUse %s total_time time_per_trace \"trace command(s) \"\n", argv[0]); + return -1; + } + + if ((sscanf(argv[1], "%lf", &t) != 1) || + (sscanf(argv[2], "%lf", &dt) != 1)) { + fprintf(stderr, "failed to read arg 1/2\n"); + return -1; + } + printf("%f, %f\n", t, dt); + // print the full command once + + // now print enough newline (= command repetitions) + // TODO: be faster than lame-duck-speed + n = (long) (t / dt); // on step already passed because of above printf statement + while (n>1) { + printf("\n"); + n--; + } +} diff --git a/code/glue/sim-wrapper b/code/glue/sim-wrapper new file mode 100755 index 0000000..9825409 --- /dev/null +++ b/code/glue/sim-wrapper @@ -0,0 +1,24 @@ +#!/bin/sh + +if [ ! $# -eq 10 ]; then + echo 'wrong parameter count (see ./sim-current for parameter order and add the model (current/if/...) as the first param)' >&2 + exit 1 +fi + +# determine the path of the simulaton program +SIM=`dirname $0`/../core/sim-$1 +if [ ! -x $SIM ]; then + echo "executable ($SIM) does not exist" >&2 + exit 1 +fi + +# check if one of the input files is executable +if [ -x $2 -o -x $3 -o -x $4 -o -x $5 -o -x $5 -o -x $6 -o -x $6 -o -x $7 -o -x $8 -o -x $9 ]; then + # yes -> interactive simulation + # create the FIFOs to communicate + echo Interactive spike program is not NOT IMPLEMENTED + exit 1 +else + # no -> static simulation + $SIM $2 $3 $4 $5 $6 $7 $8 $9 $10 +fi |