llvm, polly, 向量化测试,GEMM非常明显

1)这是OMP的

rm -f *.o3
clang -DLARGE_DATASET -O3 -mllvm -polly-omp-backend=LLVM -mllvm -polly-num-threads=2 -I/home/a/src/a3.llvm.polly/a1.polybench-c-4.2/utilities    /home/a/src/a3.llvm.polly/a1.polybench-c-4.2/utilities/polybench.c  /home/a/src/a3.llvm.polly/a1.polybench-c-4.2/stencils/jacobi-2d/jacobi-2d.c  -o a3.polly.o3
time ./a3.polly.o3

real    0m9.228s
user    0m9.016s
sys    0m0.169s
 

2)vectorizer的结果

a@a:~/src/a3.llvm.polly/a1.polybench-c-4.2$ rm -f *.o3
clang -DLARGE_DATASET -O3 -mllvm -polly -mllvm -polly-vectorizer=stripmine -I/home/a/src/a3.llvm.polly/a1.polybench-c-4.2/utilities    /home/a/src/a3.llvm.polly/a1.polybench-c-4.2/utilities/polybench.c  /home/a/src/a3.llvm.polly/a1.polybench-c-4.2/stencils/jacobi-2d/jacobi-2d.c  -o a3.polly.o3
time ./a3.polly.o3

real    0m9.078s
user    0m8.851s
sys    0m0.196s
 

3)对于GEMM,vectorizer效果非常明显。

rm -f *.o3
clang -DLARGE_DATASET -O3 -mllvm -polly-omp-backend=LLVM -mllvm -polly-num-threads=2 -I/home/a/src/a3.llvm.polly/a1.polybench-c-4.2/utilities    /home/a/src/a3.llvm.polly/a1.polybench-c-4.2/utilities/polybench.c  /home/a/src/a3.llvm.polly/a1.polybench-c-4.2/linear-algebra/blas/gemm/gemm.c  -o a3.polly.o3
time ./a3.polly.o3


rm -f *.o3
clang -DLARGE_DATASET -O3 -mllvm -polly -mllvm -polly-vectorizer=stripmine -I/home/a/src/a3.llvm.polly/a1.polybench-c-4.2/utilities    /home/a/src/a3.llvm.polly/a1.polybench-c-4.2/utilities/polybench.c  /home/a/src/a3.llvm.polly/a1.polybench-c-4.2/linear-algebra/blas/gemm/gemm.c  -o a3.polly.o3
time ./a3.polly.o3

real    0m3.265s
user    0m3.109s
sys    0m0.132s

real    0m1.211s
user    0m1.133s
sys    0m0.076s
 

4)出了个小BUG:

rm -f *.o3
clang -DLARGE_DATASET -O3 -mllvm -polly -mllvm -polly-vectorizer=stripmine -I/home/a/src/a3.llvm.polly/a1.polybench-c-4.2/utilities    /home/a/src/a3.llvm.polly/a1.polybench-c-4.2/utilities/polybench.c  /home/a/src/a3.llvm.polly/a1.polybench-c-4.2/datamining/correlation/correlation.c  -o a3.polly.o3
time ./a3.polly.o3
/usr/bin/ld: /tmp/correlation-ceecf1.o: in function `main':
correlation.c:(.text+0x181): undefined reference to `sqrt'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
bash: ./a3.polly.o3: 没有那个文件或目录
 

解决方法:加上-lm

这是常见的错

5)

rm -f *.o3
clang -DLARGE_DATASET -O3 -mllvm -polly-omp-backend=LLVM -mllvm -polly-num-threads=2 -I/home/a/src/a3.llvm.polly/a1.polybench-c-4.2/utilities    /home/a/src/a3.llvm.polly/a1.polybench-c-4.2/utilities/polybench.c  /home/a/src/a3.llvm.polly/a1.polybench-c-4.2/datamining/correlation/correlation.c  -o a3.polly.o3 -lm
time ./a3.polly.o3


rm -f *.o3
clang -DLARGE_DATASET -O3 -mllvm -polly -mllvm -polly-vectorizer=stripmine -I/home/a/src/a3.llvm.polly/a1.polybench-c-4.2/utilities    /home/a/src/a3.llvm.polly/a1.polybench-c-4.2/utilities/polybench.c  /home/a/src/a3.llvm.polly/a1.polybench-c-4.2/datamining/correlation/correlation.c  -o a3.polly.o3 -lm
time ./a3.polly.o3

real    0m20.509s
user    0m20.406s
sys    0m0.072s

real    0m2.272s
user    0m2.226s
sys    0m0.036s
 

a@a:~/src/a3.llvm.polly/a1.polybench-c-4.2$ 
rm -f *.o3
gcc -DLARGE_DATASET -O3 -I/home/a/src/a3.llvm.polly/a1.polybench-c-4.2/utilities    /home/a/src/a3.llvm.polly/a1.polybench-c-4.2/utilities/polybench.c  /home/a/src/a3.llvm.polly/a1.polybench-c-4.2/datamining/correlation/correlation.c  -o a3.polly.o3 -lm
time ./a3.polly.o3

real    0m17.786s
user    0m17.606s
sys    0m0.153s
 

如果向量化是正确的话,那么效果太好。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值