-
Notifications
You must be signed in to change notification settings - Fork 0
/
feedback.sh
executable file
·60 lines (52 loc) · 1.76 KB
/
feedback.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
58
59
60
#!/bin/bash
# Output Directory
output=feedback/
# feedback_circuits/circuit/*/(*).qasm Capture Regex
qasmregex="./feedback_circuits/circuits/.*/(.*).qasm"
# feedback_circuits/couplings/(*).txt Capture Regex
txtregex="./feedback_circuits/couplings/(.*).txt"
# Assertion Regex
assertionregex="^mapper:"
# 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/*.txt; 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 mapper on QASM and Coupling Graph to Output File
time (./mapper $circuitfile $couplingfile 2>&1) \
1> $output/$circuitname--$couplingname.txt \
2>> $record
OUTPUT=`head -n 4 $output/$circuitname--$couplingname.txt`
if [[ $OUTPUT =~ $assertionregex ]]
then
echo "No Mappings Possible" >> $record
else
echo "$OUTPUT" >> $record
fi
done
done
done