ZHEN WEI via llvm-dev
2019-Apr-25 06:42 UTC
[llvm-dev] How to use the pass 'Unroll and Jam'
Dear LLVM developers, Recently I want to try the pass '-loop-unroll-and-jam' to observe how the IR is transformed, but I don't see the IR changed after doing the following steps. Here are the details for preparing my experiment and I have tried the LLVM 6, 7 and 8: 1) Simple 2D array source code (loop.c) is given ``` #define M 32768 #define N 32768 double a[M][N], b[M][N], c[M][N]; int main() { for (int i = 0; i < M; i++) { for (int j = 0; j < N; j++) { c[i][j] = a[i][j] + b[i][j]; } } return 0; } ``` 2) Create an LLVM IR file ./bin/clang -O1 loop.c -emit-llvm -S -o loop.ll 3) Run the 'unroll-and-jam' pass ./bin/opt -loop-unroll-and-jam loop.ll -S -o loop-unrolljam.ll I added the option '--debug-pass=Structure' to the opt, and I can see the 'Unroll and Jam loops' indeed executed by the Loop Pass Manager. ``` ModulePass Manager FunctionPass Manager Dominator Tree Construction Basic Alias Analysis (stateless AA impl) Function Alias Analysis Results Natural Loop Information Scalar Evolution Analysis Dependence Analysis Canonicalize natural loops LCSSA Verifier Loop-Closed SSA Form Pass Loop Pass Manager Unroll and Jam loops Module Verifier Print Module IR ``` I also tried to add the option '-debug' to the opt to see if there is the debug information printed by LoopUnrollAndJam, but nothing. Thank you very much. -- Zhen Wei (魏禛) Master Student Department of Computer Science & Information Engineering National Taiwan University Email: zhenwei.tw at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190425/995af7e9/attachment.html>
Das, Dibyendu via llvm-dev
2019-Apr-25 08:24 UTC
[llvm-dev] How to use the pass 'Unroll and Jam'
Try the combo: -enable-unroll-and-jam -allow-unroll-and-jam -unroll-and-jam-count=4 From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of ZHEN WEI via llvm-dev Sent: Thursday, April 25, 2019 12:13 PM To: llvm-dev at lists.llvm.org Subject: [llvm-dev] How to use the pass 'Unroll and Jam' Dear LLVM developers, Recently I want to try the pass '-loop-unroll-and-jam' to observe how the IR is transformed, but I don't see the IR changed after doing the following steps. Here are the details for preparing my experiment and I have tried the LLVM 6, 7 and 8: 1) Simple 2D array source code (loop.c) is given ``` #define M 32768 #define N 32768 double a[M][N], b[M][N], c[M][N]; int main() { for (int i = 0; i < M; i++) { for (int j = 0; j < N; j++) { c[i][j] = a[i][j] + b[i][j]; } } return 0; } ``` 2) Create an LLVM IR file ./bin/clang -O1 loop.c -emit-llvm -S -o loop.ll 3) Run the 'unroll-and-jam' pass ./bin/opt -loop-unroll-and-jam loop.ll -S -o loop-unrolljam.ll I added the option '--debug-pass=Structure' to the opt, and I can see the 'Unroll and Jam loops' indeed executed by the Loop Pass Manager. ``` ModulePass Manager FunctionPass Manager Dominator Tree Construction Basic Alias Analysis (stateless AA impl) Function Alias Analysis Results Natural Loop Information Scalar Evolution Analysis Dependence Analysis Canonicalize natural loops LCSSA Verifier Loop-Closed SSA Form Pass Loop Pass Manager Unroll and Jam loops Module Verifier Print Module IR ``` I also tried to add the option '-debug' to the opt to see if there is the debug information printed by LoopUnrollAndJam, but nothing. Thank you very much. -- Zhen Wei (魏禛) Master Student Department of Computer Science & Information Engineering National Taiwan University Email: zhenwei.tw at gmail.com<mailto:zhenwei.tw at gmail.com> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190425/47a84501/attachment.html>
ZHEN WEI via llvm-dev
2019-Apr-25 09:22 UTC
[llvm-dev] How to use the pass 'Unroll and Jam'
Hi Das, Thanks for your reply! I have received similar responses from @LebedevRI on the IRC. After I modified the arguments for opt as the following, my loops can be unroll-and-jam successfully: -loop-unroll-and-jam -allow-unroll-and-jam -unroll-and-jam-count=2 'loop-unroll-and-jam' and 'allow-unroll-and-jam' are both needed to turn on the functionality. Thanks again. Have a nice day. Das, Dibyendu <Dibyendu.Das at amd.com> 於 2019年4月25日 週四 下午4:24寫道:> Try the combo: > > > > -enable-unroll-and-jam -allow-unroll-and-jam -unroll-and-jam-count=4 > > > > *From:* llvm-dev <llvm-dev-bounces at lists.llvm.org> *On Behalf Of *ZHEN > WEI via llvm-dev > *Sent:* Thursday, April 25, 2019 12:13 PM > *To:* llvm-dev at lists.llvm.org > *Subject:* [llvm-dev] How to use the pass 'Unroll and Jam' > > > > Dear LLVM developers, > > > > Recently I want to try the pass '-loop-unroll-and-jam' to observe how the > IR is transformed, but I don't see the IR changed after doing the following > steps. > > > > Here are the details for preparing my experiment and I have tried the LLVM > 6, 7 and 8: > > 1) Simple 2D array source code (loop.c) is given > > > > ``` > > #define M 32768 > > #define N 32768 > > > > double a[M][N], b[M][N], c[M][N]; > > > > int main() { > > for (int i = 0; i < M; i++) { > > for (int j = 0; j < N; j++) { > > c[i][j] = a[i][j] + b[i][j]; > > } > > } > > return 0; > > } > > ``` > > 2) Create an LLVM IR file > > ./bin/clang -O1 loop.c -emit-llvm -S -o loop.ll > > > > 3) Run the 'unroll-and-jam' pass > > ./bin/opt -loop-unroll-and-jam loop.ll -S -o loop-unrolljam.ll > > > > I added the option '--debug-pass=Structure' to the opt, and I can see the > 'Unroll and Jam loops' indeed executed by the Loop Pass Manager. > > ``` > > ModulePass Manager > FunctionPass Manager > Dominator Tree Construction > Basic Alias Analysis (stateless AA impl) > Function Alias Analysis Results > Natural Loop Information > Scalar Evolution Analysis > Dependence Analysis > Canonicalize natural loops > LCSSA Verifier > Loop-Closed SSA Form Pass > Loop Pass Manager > Unroll and Jam loops > Module Verifier > Print Module IR > > ``` > > > > I also tried to add the option '-debug' to the opt to see if there is the > debug information printed by LoopUnrollAndJam, but nothing. > > > > Thank you very much. > > -- > > Zhen Wei (魏禛) > Master Student > Department of Computer Science & Information Engineering > National Taiwan University > Email: zhenwei.tw at gmail.com >-- Zhen Wei (魏禛) Master Student Department of Computer Science & Information Engineering National Taiwan University Email: zhenwei.tw at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190425/c16b2b7e/attachment.html>