Move www/experiments to docs/experiments
[polly-mirror.git] / docs / experiments / matmul / runall.sh
blob575b58f982462d7db168a052045350dc22cf3b30
1 #!/bin/sh -a
3 echo "--> 1. Create LLVM-IR from C"
4 clang -S -emit-llvm matmul.c -o matmul.s
6 echo "--> 2. Prepare the LLVM-IR for Polly"
7 opt -S -polly-canonicalize matmul.s > matmul.preopt.ll
9 echo "--> 3. Show the SCoPs detected by Polly"
10 opt -basicaa -polly-ast -analyze -q matmul.preopt.ll \
11 -polly-process-unprofitable
13 echo "--> 4.1 Highlight the detected SCoPs in the CFGs of the program"
14 # We only create .dot files, as directly -view-scops directly calls graphviz
15 # which would require user interaction to continue the script.
16 # opt -basicaa -view-scops -disable-output matmul.preopt.ll
17 opt -basicaa -dot-scops -disable-output matmul.preopt.ll
19 echo "--> 4.2 Highlight the detected SCoPs in the CFGs of the program (print \
20 no instructions)"
21 # We only create .dot files, as directly -view-scops-only directly calls
22 # graphviz which would require user interaction to continue the script.
23 # opt -basicaa -view-scops-only -disable-output matmul.preopt.ll
24 opt -basicaa -dot-scops-only -disable-output matmul.preopt.ll
26 echo "--> 4.3 Create .png files from the .dot files"
27 for i in `ls *.dot`; do dot -Tpng $i > $i.png; done
29 echo "--> 5. View the polyhedral representation of the SCoPs"
30 opt -basicaa -polly-scops -analyze matmul.preopt.ll -polly-process-unprofitable
32 echo "--> 6. Show the dependences for the SCoPs"
33 opt -basicaa -polly-dependences -analyze matmul.preopt.ll \
34 -polly-process-unprofitable
36 echo "--> 7. Export jscop files"
37 opt -basicaa -polly-export-jscop matmul.preopt.ll -polly-process-unprofitable
39 echo "--> 8. Import the updated jscop files and print the new SCoPs. (optional)"
40 opt -basicaa -polly-import-jscop -polly-ast -analyze matmul.preopt.ll \
41 -polly-process-unprofitable
42 opt -basicaa -polly-import-jscop -polly-ast -analyze matmul.preopt.ll \
43 -polly-import-jscop-postfix=interchanged -polly-process-unprofitable
44 opt -basicaa -polly-import-jscop -polly-ast -analyze matmul.preopt.ll \
45 -polly-import-jscop-postfix=interchanged+tiled -polly-process-unprofitable
46 opt -basicaa -polly-import-jscop -polly-ast -analyze matmul.preopt.ll \
47 -polly-import-jscop-postfix=interchanged+tiled+vector \
48 -polly-process-unprofitable
50 echo "--> 9. Codegenerate the SCoPs"
51 opt -basicaa -polly-import-jscop -polly-import-jscop-postfix=interchanged \
52 -polly-codegen -polly-process-unprofitable\
53 matmul.preopt.ll | opt -O3 > matmul.polly.interchanged.ll
54 opt -basicaa -polly-import-jscop \
55 -polly-import-jscop-postfix=interchanged+tiled -polly-codegen \
56 matmul.preopt.ll -polly-process-unprofitable \
57 | opt -O3 > matmul.polly.interchanged+tiled.ll
58 opt -basicaa -polly-import-jscop -polly-process-unprofitable\
59 -polly-import-jscop-postfix=interchanged+tiled+vector -polly-codegen \
60 matmul.preopt.ll -polly-vectorizer=polly\
61 | opt -O3 > matmul.polly.interchanged+tiled+vector.ll
62 opt -basicaa -polly-import-jscop -polly-process-unprofitable\
63 -polly-import-jscop-postfix=interchanged+tiled+vector -polly-codegen \
64 matmul.preopt.ll -polly-vectorizer=polly -polly-parallel\
65 | opt -O3 > matmul.polly.interchanged+tiled+vector+openmp.ll
66 opt matmul.preopt.ll | opt -O3 > matmul.normalopt.ll
68 echo "--> 10. Create the executables"
69 llc matmul.polly.interchanged.ll -o matmul.polly.interchanged.s && gcc matmul.polly.interchanged.s \
70 -o matmul.polly.interchanged.exe
71 llc matmul.polly.interchanged+tiled.ll -o matmul.polly.interchanged+tiled.s && gcc matmul.polly.interchanged+tiled.s \
72 -o matmul.polly.interchanged+tiled.exe
73 llc matmul.polly.interchanged+tiled+vector.ll \
74 -o matmul.polly.interchanged+tiled+vector.s \
75 && gcc matmul.polly.interchanged+tiled+vector.s \
76 -o matmul.polly.interchanged+tiled+vector.exe
77 llc matmul.polly.interchanged+tiled+vector+openmp.ll \
78 -o matmul.polly.interchanged+tiled+vector+openmp.s \
79 && gcc -lgomp matmul.polly.interchanged+tiled+vector+openmp.s \
80 -o matmul.polly.interchanged+tiled+vector+openmp.exe
81 llc matmul.normalopt.ll -o matmul.normalopt.s && gcc matmul.normalopt.s \
82 -o matmul.normalopt.exe
84 echo "--> 11. Compare the runtime of the executables"
86 echo "time ./matmul.normalopt.exe"
87 time -f "%E real, %U user, %S sys" ./matmul.normalopt.exe
88 echo "time ./matmul.polly.interchanged.exe"
89 time -f "%E real, %U user, %S sys" ./matmul.polly.interchanged.exe
90 echo "time ./matmul.polly.interchanged+tiled.exe"
91 time -f "%E real, %U user, %S sys" ./matmul.polly.interchanged+tiled.exe
92 echo "time ./matmul.polly.interchanged+tiled+vector.exe"
93 time -f "%E real, %U user, %S sys" ./matmul.polly.interchanged+tiled+vector.exe
94 echo "time ./matmul.polly.interchanged+tiled+vector+openmp.exe"
95 time -f "%E real, %U user, %S sys" ./matmul.polly.interchanged+tiled+vector+openmp.exe