Repository navigation
Expand file tree
/
Copy pathbenchmark_python.sh
More file actions
70 lines (61 loc) · 1.73 KB
/
Copy pathbenchmark_python.sh
File metadata and controls
70 lines (61 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
#SBATCH --account=csmpi
#SBATCH --partition=csmpi_fpga_long
#SBATCH --cpus-per-task=1
#SBATCH --mem=16G
#SBATCH --gres=gpu:0
#SBATCH --time=10:00:00
#SBATCH --output=results/slurm/python_eloc-%j.out
#SBATCH --error=results/slurm/python_eloc-%j.err
PYTHON_EXEC="python3"
# Experiment variables:
SEED=0
GAMMA=0.5
WARMUP_RUNS=3
RUNS=7
MODE="python"
mkdir tmp
cp runs.txt tmp/runs.txt
touch results/sac_python.csv
echo "alpha,L,nspins,nhidden,nsamples,mode,run_index,warmup_runs,measured_runs,runtime_ms" > results/sac_python.csv
NR_EXPERIMENTS=`awk 'END{print FNR}' runs.txt`
# Generate state and RBM:
i=1
while [ $i -le $NR_EXPERIMENTS ]; do
echo "Generating state and RBM for experiment $i/$NR_EXPERIMENTS"
args=`awk "NR==$i" tmp/runs.txt`
ALPHA=${args[0]}
L=${args[1]}
NSAMPLES=${args[2]}
$PYTHON_EXEC auxiliary/generate_states.py $ALPHA $L $NSAMPLES $SEED
$PYTHON_EXEC auxiliary/generate_RBM.py $ALPHA $L $NSAMPLES $SEED
((i++))
#done
echo "Copy eloc.py"
cp eloc_original.py tmp/eloc.py
# Running experiments:
i=1
while [ $i -le $NR_EXPERIMENTS ]; do
args=($(awk "NR==$i" tmp/runs.txt | tr -d "\n\r"))
echo "Running warmup experiment $args ($i/$NR_EXPERIMENTS)"
j=1
while [ $j -le $WARMUP_RUNS ]; do
MS=`$PYTHON_EXEC tmp/eloc.py $args`
echo "($j/$WARMUP_RUNS): $MS"
((j++))
done
echo "Running experiment $args ($i/$NR_EXPERIMENTS)"
j=1
while [ $j -le $RUNS ]; do
ALPHA=${args[0]}
L=${args[1]}
NSAMPLES=${args[2]}
NSPINS=$((L*L))
NHIDDEN=$((ALPHA*NSPINS))
RET=($($PYTHON_EXEC tmp/eloc.py $ALPHA $L $NSAMPLES $GAMMA))
echo "($j/$RUNS): $RET"
echo "$ALPHA,$L,$NSPINS,$NHIDDEN,$NSAMPLES,$MODE,$j,$WARMUP_RUNS,$RUNS,$RET" >> results/sac_python.csv
((j++))
done
((i++))
done