#!/bin/bash

# For each of a variety of network latencies and bandwidths, run three
# experiments in parallel on different NUMA nodes

# read, write, readwrite, or init
mode=readwrite

# You'll probably want to tune the FLORAM_NUMA_P[01] environment
# variables to taste

run1() {
    FLORAM_NUMA_P0="numactl -C 18-25 -m 1" \
    FLORAM_NUMA_P1="numactl -C 26-33 -m 1" \
        ./run-experiment $mode $1 128 3000 >> ${mode}_${2}_1.out
}

run2() {
    FLORAM_NUMA_P0="numactl -C 36-43 -m 2" \
    FLORAM_NUMA_P1="numactl -C 44-51 -m 2" \
        ./run-experiment $mode $1 128 3100 >> ${mode}_${2}_2.out
}

run3() {
    FLORAM_NUMA_P0="numactl -C 54-61 -m 3" \
    FLORAM_NUMA_P1="numactl -C 61-69 -m 3" \
        ./run-experiment $mode $1 128 3200 >> ${mode}_${2}_3.out
}

run() {
    ./set-networking $2 $3
    run1 $1 "${2}_${3}_128" &
    run2 $1 "${2}_${3}_128" &
    run3 $1 "${2}_${3}_128" &
    wait
}

run 20 10ms 100mbit
run 20 50ms 100mbit
run 20 70ms 100mbit
run 20 30ms 10mbit
run 20 30ms 30mbit
run 20 30ms 50mbit
run 20 30ms 70mbit
run 20 30ms 90mbit
run 20 30ms 110mbit
run 16 30ms 100mbit
run 18 30ms 100mbit
run 20 30ms 100mbit
run 22 30ms 100mbit
run 24 30ms 100mbit
run 26 30ms 100mbit