pnnl/soda-opt

Difference in Pass Pipelines

pluvixox opened this issue · 5 comments

I find that there are some differences in Pass pipelines. I'm confused with pm.addPass(cf::createConvertControlFlowToLLVMPass()) and pm.addPass(createCanonicalizerPass()). What are their functions in soda's pipeline? When needed?

Hi,

Sorry for the delay on this response.

createConvertControlFlowToLLVMPass is in charge of converting remaining cf.ops to llvm.ops. In order to provide the IR to the backend HLS tool we need to generate LLVM IR, thus this step is necessary.

createCanonicalizerPass cleans up some redundant/unused MLIR ops. These ops may appear after an operation is replaced, its consumers updated, but the operation was never removed. This pass is also in charge of simplifying the use of constant values that may have been declared several times, but represent the same constant. It declares the constant at the top, and updates all uses to use this new ssa value representing the constant. Additional features of the canonicalizer are described here.

Hi,

Sorry for the delay on this response.

createConvertControlFlowToLLVMPass is in charge of converting remaining cf.ops to llvm.ops. In order to provide the IR to the backend HLS tool we need to generate LLVM IR, thus this step is necessary.

createCanonicalizerPass cleans up some redundant/unused MLIR ops. These ops may appear after an operation is replaced, its consumers updated, but the operation was never removed. This pass is also in charge of simplifying the use of constant values that may have been declared several times, but represent the same constant. It declares the constant at the top, and updates all uses to use this new ssa value representing the constant. Additional features of the canonicalizer are described here.

Thank you for your reply! I get your point and they both seem important. Maybe I didn't make my point clear. Followings are some specific examples:
createConvertControlFlowToLLVMPass: In soda-opt-pipeline, it appears after createReconcileUnrealizedCastsPass. But in lower-all-to-llvm, it doesn't appear after createReconcileUnrealizedCastsPass.
createCanonicalizerPass: In lower-all-to-llvm, it appears at the end. But in soda-opt-pipeline, it doesn't appear.
It really confuses me.

The passes in the soda-opt pipeline were derived from a design space exploration engine using polybench kernels as benchmark and tuning for performance. It appears that on average, the additional canonicalization did not affect performance when compared to the other pass, thus the DSE did not include it. The DSE engine exhaustively explored the problem of pass selection/ordering and tuned some pass parameters.

I got it! Thanks for the detailed answer! I read papers about soda-opt again and find explanation about DSE in An MLIR-based Compiler Flow for System-Level Design and Hardware Acceleration. I didn't read carefully enough earlier. Thanks again for your reply!

Exactly!
For future reference, links to the papers are listed here:

https://github.com/pnnl/soda-opt#publications