diff --git a/runtime/experiments/applications/ekf/by_iteration/.gitignore b/runtime/experiments/applications/ekf/by_iteration/.gitignore new file mode 100644 index 0000000..343f11e --- /dev/null +++ b/runtime/experiments/applications/ekf/by_iteration/.gitignore @@ -0,0 +1,3 @@ +*res.dat +rt.log +log.csv diff --git a/runtime/experiments/applications/ekf/by_iteration/README.md b/runtime/experiments/applications/ekf/by_iteration/README.md new file mode 100644 index 0000000..20079c5 --- /dev/null +++ b/runtime/experiments/applications/ekf/by_iteration/README.md @@ -0,0 +1,9 @@ +# EKF + +Executes TinyEKF as shows by [You Chong's GPS example](http://www.mathworks.com/matlabcentral/fileexchange/31487-extended-kalman-filter-ekf--for-gps) + +In order to be compatible with the stdin/stdout model of serverless, the input and output files are binary concatenations of various C structs. + +See `main()` in `runtime/tests/TinyEKF/extras/c/gps_ekf_fn.c` for specifics. + +This test executes multiple iterations, comparing the binary result against a known memoized result stored at `expected_result.dat`. diff --git a/runtime/experiments/applications/ekf/by_iteration/debug.sh b/runtime/experiments/applications/ekf/by_iteration/debug.sh new file mode 100755 index 0000000..6ab3666 --- /dev/null +++ b/runtime/experiments/applications/ekf/by_iteration/debug.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Executes the runtime in GDB +# Substitutes the absolute path from the container with a path relatively derived from the location of this script +# This allows debugging outside of the Docker container +# Also disables pagination and stopping on SIGUSR1 + +experiment_directory=$(pwd) +project_directory=$(cd ../../../.. && pwd) +binary_directory=$(cd "$project_directory"/bin && pwd) + +export LD_LIBRARY_PATH="$binary_directory:$LD_LIBRARY_PATH" +export PATH="$binary_directory:$PATH" + +gdb --eval-command="handle SIGUSR1 nostop" \ + --eval-command="handle SIGPIPE nostop" \ + --eval-command="set pagination off" \ + --eval-command="set substitute-path /sledge/runtime $project_directory" \ + --eval-command="run $experiment_directory/spec.json" \ + sledgert diff --git a/runtime/experiments/applications/ekf/by_iteration/initial_state.dat b/runtime/experiments/applications/ekf/by_iteration/initial_state.dat new file mode 100644 index 0000000..9a960e1 Binary files /dev/null and b/runtime/experiments/applications/ekf/by_iteration/initial_state.dat differ diff --git a/runtime/experiments/applications/ekf/by_iteration/one_iteration.dat b/runtime/experiments/applications/ekf/by_iteration/one_iteration.dat new file mode 100644 index 0000000..1229f11 Binary files /dev/null and b/runtime/experiments/applications/ekf/by_iteration/one_iteration.dat differ diff --git a/runtime/experiments/applications/ekf/by_iteration/run.sh b/runtime/experiments/applications/ekf/by_iteration/run.sh new file mode 100755 index 0000000..870dca1 --- /dev/null +++ b/runtime/experiments/applications/ekf/by_iteration/run.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# Executes the runtime in GDB +# Substitutes the absolute path from the container with a path relatively derived from the location of this script +# This allows debugging outside of the Docker container +# Also disables pagination and stopping on SIGUSR1 + +experiment_directory=$(pwd) +runtime_directory=$(cd ../../../.. && pwd) +binary_directory=$(cd "$runtime_directory"/bin && pwd) +log="$experiment_directory/log.csv" + +# Copy data if not here +if [[ ! -f "./initial_state.dat" ]]; then + cp $runtime_directory/tests/TinyEKF/extras/c/ekf_raw.dat ./initial_state.dat +fi + +if [ "$1" != "-d" ]; then + SLEDGE_SANDBOX_PERF_LOG=$log PATH="$binary_directory:$PATH" LD_LIBRARY_PATH="$binary_directory:$LD_LIBRARY_PATH" sledgert "$experiment_directory/spec.json" >rt.log 2>&1 & + sleep 2 +else + echo "Running under gdb" +fi + +one_iteration_expected_result="$(tr -d '\0' <./one_iteration.dat)" +two_iterations_expected_result="$(tr -d '\0' <./two_iterations.dat)" +three_iterations_expected_result="$(tr -d '\0' <./three_iterations.dat)" + +success_count=0 +total_count=50 + +for ((i = 0; i < total_count; i++)); do + echo "$i" + curl -H 'Expect:' -H "Content-Type: application/octet-stream" --data-binary "@initial_state.dat" localhost:10000 2>/dev/null >./one_iteration_res.dat + curl -H 'Expect:' -H "Content-Type: application/octet-stream" --data-binary "@one_iteration_res.dat" localhost:10001 2>/dev/null >./two_iterations_res.dat + curl -H 'Expect:' -H "Content-Type: application/octet-stream" --data-binary "@two_iterations_res.dat" localhost:10002 2>/dev/null >./three_iterations_res.dat + if diff -s one_iteration_res.dat one_iteration.dat && diff -s two_iterations_res.dat two_iterations.dat && diff -s three_iterations_res.dat three_iterations.dat; then + success_count=$((success_count + 1)) + else + echo "FAIL" + exit + fi + + rm *_res.dat +done + +echo "$success_count / $total_count" + +if [ "$1" != "-d" ]; then + sleep 5 + echo -n "Running Cleanup: " + pkill sledgert >/dev/null 2>/dev/null + echo "[DONE]" +fi diff --git a/runtime/experiments/applications/ekf/by_iteration/spec.json b/runtime/experiments/applications/ekf/by_iteration/spec.json new file mode 100644 index 0000000..2043944 --- /dev/null +++ b/runtime/experiments/applications/ekf/by_iteration/spec.json @@ -0,0 +1,42 @@ +{ + "active": "yes", + "name": "ekf_first_iter", + "path": "ekf_wasm.so", + "port": 10000, + "relative-deadline-us": 50000, + "argsize": 1, + "http-req-headers": [], + "http-req-content-type": "application/octet-stream", + "http-req-size": 1024000, + "http-resp-headers": [], + "http-resp-size": 1024000, + "http-resp-content-type": "application/octet-stream" +}, +{ + "active": "yes", + "name": "ekf_second_iter", + "path": "ekf_wasm.so", + "port": 10001, + "relative-deadline-us": 50000, + "argsize": 1, + "http-req-headers": [], + "http-req-content-type": "application/octet-stream", + "http-req-size": 1024000, + "http-resp-headers": [], + "http-resp-size": 1024000, + "http-resp-content-type": "application/octet-stream" +}, +{ + "active": "yes", + "name": "ekf_third_iter", + "path": "ekf_wasm.so", + "port": 10002, + "relative-deadline-us": 50000, + "argsize": 1, + "http-req-headers": [], + "http-req-content-type": "application/octet-stream", + "http-req-size": 1024000, + "http-resp-headers": [], + "http-resp-size": 1024000, + "http-resp-content-type": "application/octet-stream" +} diff --git a/runtime/experiments/applications/ekf/by_iteration/three_iterations.dat b/runtime/experiments/applications/ekf/by_iteration/three_iterations.dat new file mode 100644 index 0000000..cc0ab73 Binary files /dev/null and b/runtime/experiments/applications/ekf/by_iteration/three_iterations.dat differ diff --git a/runtime/experiments/applications/ekf/by_iteration/two_iterations.dat b/runtime/experiments/applications/ekf/by_iteration/two_iterations.dat new file mode 100644 index 0000000..a98da81 Binary files /dev/null and b/runtime/experiments/applications/ekf/by_iteration/two_iterations.dat differ