Bump version to 19.1.0 (final)
[llvm-project.git] / polly / docs / experiments / matmul / runall.sh
blob37dce6878c18719c13d27eb578bc30d23e651d59
1 #!/bin/sh -a
3 echo "--> 1. Create LLVM-IR from C"
4 clang -S -emit-llvm matmul.c -Xclang -disable-O0-optnone -o matmul.ll
6 echo "--> 2. Prepare the LLVM-IR for Polly"
7 opt -S -polly-canonicalize matmul.ll -o matmul.preopt.ll
9 echo "--> 3. Show the SCoPs detected by Polly"
10 opt -basic-aa -polly-ast -analyze matmul.preopt.ll \
11 -polly-process-unprofitable -polly-use-llvm-names
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 -basic-aa -view-scops -disable-output matmul.preopt.ll
17 opt -basic-aa -dot-scops -disable-output matmul.preopt.ll -polly-use-llvm-names
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 -basic-aa -view-scops-only -disable-output matmul.preopt.ll
24 opt -basic-aa -dot-scops-only -disable-output matmul.preopt.ll -polly-use-llvm-names
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 -basic-aa -polly-scops -analyze matmul.preopt.ll \
31 -polly-process-unprofitable -polly-use-llvm-names
33 echo "--> 6. Show the dependences for the SCoPs"
34 opt -basic-aa -polly-dependences -analyze matmul.preopt.ll \
35 -polly-process-unprofitable -polly-use-llvm-names
37 echo "--> 7. Export jscop files"
38 opt -basic-aa -polly-export-jscop matmul.preopt.ll \
39 -polly-process-unprofitable -disable-output -polly-use-llvm-names
41 echo "--> 8. Import the updated jscop files and print the new SCoPs. (optional)"
42 opt -basic-aa -polly-import-jscop -polly-ast -analyze matmul.preopt.ll \
43 -polly-process-unprofitable -polly-use-llvm-names
44 opt -basic-aa -polly-import-jscop -polly-ast -analyze matmul.preopt.ll \
45 -polly-import-jscop-postfix=interchanged -polly-process-unprofitable -polly-use-llvm-names
46 opt -basic-aa -polly-import-jscop -polly-ast -analyze matmul.preopt.ll \
47 -polly-import-jscop-postfix=interchanged+tiled -polly-process-unprofitable -polly-use-llvm-names
48 opt -basic-aa -polly-import-jscop -polly-ast -analyze matmul.preopt.ll \
49 -polly-import-jscop-postfix=interchanged+tiled+vector \
50 -polly-process-unprofitable -polly-use-llvm-names
52 echo "--> 9. Codegenerate the SCoPs"
53 opt -S -basic-aa -polly-import-jscop -polly-import-jscop-postfix=interchanged \
54 -polly-codegen -polly-process-unprofitable -polly-use-llvm-names \
55 matmul.preopt.ll | opt -O3 -S -o matmul.polly.interchanged.ll
56 opt -S -basic-aa -polly-import-jscop \
57 -polly-import-jscop-postfix=interchanged+tiled -polly-codegen \
58 matmul.preopt.ll -polly-process-unprofitable -polly-use-llvm-names \
59 | opt -O3 -S -o matmul.polly.interchanged+tiled.ll
60 opt -S -basic-aa -polly-import-jscop -polly-process-unprofitable\
61 -polly-import-jscop-postfix=interchanged+tiled+vector -polly-codegen \
62 matmul.preopt.ll -polly-vectorizer=polly -polly-use-llvm-names \
63 | opt -O3 -S -o matmul.polly.interchanged+tiled+vector.ll
64 opt -S -basic-aa -polly-import-jscop -polly-process-unprofitable\
65 -polly-import-jscop-postfix=interchanged+tiled+vector -polly-codegen \
66 matmul.preopt.ll -polly-vectorizer=polly -polly-parallel -polly-use-llvm-names \
67 | opt -O3 -S -o matmul.polly.interchanged+tiled+vector+openmp.ll
68 opt -S matmul.preopt.ll | opt -O3 -S -o matmul.normalopt.ll
70 echo "--> 10. Create the executables"
71 llc matmul.polly.interchanged.ll -o matmul.polly.interchanged.s -relocation-model=pic
72 gcc matmul.polly.interchanged.s -o matmul.polly.interchanged.exe
73 llc matmul.polly.interchanged+tiled.ll -o matmul.polly.interchanged+tiled.s -relocation-model=pic
74 gcc matmul.polly.interchanged+tiled.s -o matmul.polly.interchanged+tiled.exe
75 llc matmul.polly.interchanged+tiled+vector.ll -o matmul.polly.interchanged+tiled+vector.s -relocation-model=pic
76 gcc matmul.polly.interchanged+tiled+vector.s -o matmul.polly.interchanged+tiled+vector.exe
77 llc matmul.polly.interchanged+tiled+vector+openmp.ll -o matmul.polly.interchanged+tiled+vector+openmp.s -relocation-model=pic
78 gcc matmul.polly.interchanged+tiled+vector+openmp.s -lgomp -o matmul.polly.interchanged+tiled+vector+openmp.exe
79 llc matmul.normalopt.ll -o matmul.normalopt.s -relocation-model=pic
80 gcc matmul.normalopt.s -lgomp -o matmul.normalopt.exe
82 echo "--> 11. Compare the runtime of the executables"
84 echo "time ./matmul.normalopt.exe"
85 time -f "%E real, %U user, %S sys" ./matmul.normalopt.exe
86 echo "time ./matmul.polly.interchanged.exe"
87 time -f "%E real, %U user, %S sys" ./matmul.polly.interchanged.exe
88 echo "time ./matmul.polly.interchanged+tiled.exe"
89 time -f "%E real, %U user, %S sys" ./matmul.polly.interchanged+tiled.exe
90 echo "time ./matmul.polly.interchanged+tiled+vector.exe"
91 time -f "%E real, %U user, %S sys" ./matmul.polly.interchanged+tiled+vector.exe
92 echo "time ./matmul.polly.interchanged+tiled+vector+openmp.exe"
93 time -f "%E real, %U user, %S sys" ./matmul.polly.interchanged+tiled+vector+openmp.exe