finch-tensor / Finch-mlir

Rewriting Finch in mlir
0 stars 0 forks source link

FIX: Add dialects sources #4

Closed mtsokol closed 1 week ago

mtsokol commented 1 week ago

Hi @nullplay,

In this PR I added some build configuration so that other dialects can be imported and used from mlir_finch package.

Also, I tried to run test8.mlir with vecdot but I couldn't get pass finch-translate command:

bin/finch-opt ../test8.mlir --finch-looplet-sequence --finch-looplet-run --cse --sparse-assembler="direct-out=true" --sparsifier="enable-runtime-library=false parallelization-strategy=any-storage-outer-loop" -o ../test8_opt.mlir

produces optimized MLIR but it still contains finch ops so the next step:

bin/finch-translate ../test8_opt.mlir --mlir-to-llvmir -o ../test8_opt.ll

fails with:

../test8_opt.mlir:325:120: error: `!"finch"<"looplet">` type created with unregistered dialect. If this is intended, please call allowUnregisteredDialects() on the MLIRContext, or use -allow-unregistered-dialect with the MLIR opt tool used
  func.func private @buffer_to_looplet(%arg0: memref<?xindex>, %arg1: memref<?xindex>, %arg2: memref<?xf32>) -> !finch.looplet {

Is it possible to run test8.mlir? (By which I mean generate an executable to run)

nullplay commented 1 week ago

Try this command : ./bin/finch-opt ../test8.mlir --inline --finch-looplet-sequence --finch-looplet-stepper --finch-looplet-sequence --finch-looplet-run --cse --sparsifier -o ../test8_opt.mlir

and then bin/finch-translate ../test8_opt.mlir --mlir-to-llvmir -o ../test8_opt.ll I'm pretty sure you can run this program by compiling generated .ll file.

Another way to run this program is using mlir-cpu-runner which is installed in your mlir install path.

Once you generate test8_opt.mlir, you can directly run this mlir file using mlir-cpu-runner ../test8_opt.mlir -e main -entry-point-result=void -shared-libs=/Users/jaeyeonwon/llvm-project/build/lib/libmlir_runner_utils.dylib,/Users/jaeyeonwon/llvm-project/build/lib/libmlir_c_runner_utils.dylib.

You can put your path into -shared-libs=.