kumasento / polymer

Bridging polyhedral analysis tools to the MLIR framework
MIT License
99 stars 20 forks source link

Generate runnable MLIR from polymer-opt #41

Closed kumasento closed 3 years ago

kumasento commented 3 years ago

Currently we generate a single function that takes in block arguments. In order to make it compatible with polybench code in general, we should change the codegen behaviour.

The workflow should work as follows:

  1. The input MLIR code should contain a @main function that acts as the entry point. It should also have a set of affine functions that should be optimised by polymer-opt.
  2. Given the names of the entry point and the affine functions to be transformed (should be passed as command-line args), polymer-opt optimises all the given affine functions and replaces the function call to them by the optimised versions.
  3. We can then perform some post optimisation and lower it down to LLVM.

For example, command like this should work properly:

# In the build/ directory
./bin/polymer-opt ../test/polymer-opt/PlutoTransform/matmul.mlir --pluto-opt=matmul | ../llvm/build/bin/mlir-opt --lower-affine --convert-scf-to-std --convert-std-to-llvm | ../llvm/build/bin/mlir-cpu-runner --entry-point-result=void -O3

TODO -

kumasento commented 3 years ago

If a given input code itself is runnable, Polymer should just replace its scop functions.