-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeedback-enfield.sh
executable file
·57 lines (49 loc) · 1.77 KB
/
feedback-enfield.sh
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
#!/bin/bash
# Output Directory
output=feedback-enfield/
# feedback_circuits/circuit/*/(*).qasm Capture Regex
qasmregex="./feedback_circuits/circuits/.*/(.*).qasm"
# feedback_circuits/couplings/(*).txt Capture Regex
txtregex="./feedback_circuits/couplings/(.*).json"
# Enfield
efd="./enfield/build/tools/efd"
# Hide excessive trap messages
trap "" SIGABRT
# Make Output Directory
mkdir -p $output
# Make Record File
record=$output/record.txt
# : > $record
# For every size category of QASM
for size in ./feedback_circuits/circuits/*; do
# For every QASM in the size category
for circuitfile in $size/*.qasm; do
# For every Coupling Graph
for couplingfile in ./feedback_circuits/couplings/*.json; do
# Capture QASM name
if [[ $circuitfile =~ $qasmregex ]]
then
circuitname="${BASH_REMATCH[1]}"
else
echo "$circuitfile doesn't match"
fi
# Capture Coupling Graph name
if [[ $couplingfile =~ $txtregex ]]
then
couplingname="${BASH_REMATCH[1]}"
else
echo "$couplingname doesn't match"
fi
# Output to stdout
echo "Testing $circuitname on $couplingname" | tee -a $record
# Run efd on QASM and Coupling Graph to Record File
time ($efd -i $circuitfile -arch-file $couplingfile -stats 2>&1) \
1> $output/$circuitname--$couplingname.txt \
2>> $record
CIRCUIT=`head -n -9 $output/$circuitname--$couplingname.txt`
STATS=`tail -n 9 $output/$circuitname--$couplingname.txt`
echo "$CIRCUIT" > $output/$circuitname--$couplingname.txt
echo "$STATS" >> $record
done
done
done