kumasento / polymer

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

error when running mlir example #121

Closed lethean1 closed 2 years ago

lethean1 commented 2 years ago

I installed pact branch of polymer and passed check-polymer, but met this error when running the matmul.mlir example:

root@gpu0:~/polymer/build# ./bin/polymer-opt -extract-scop-stmt -pluto-opt matmul.mlir 
polymer-opt: /root/polymer/llvm/mlir/lib/Analysis/AffineStructures.cpp:3327: void getIndependentConstraints(const mlir::FlatAffineConstraints&, unsigned int, unsigned int, llvm::SmallVectorImpl<unsigned int>&, llvm::SmallVectorImpl<unsigned int>&): Assertion `pos < cst.getNumIds() && "invalid start position"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.      Program arguments: ./bin/polymer-opt -extract-scop-stmt -pluto-opt matmul.mlir
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
./bin/polymer-opt(+0xdcdf1)[0x559523c58df1]
./bin/polymer-opt(+0xdaab4)[0x559523c56ab4]
./bin/polymer-opt(+0xdac2b)[0x559523c56c2b]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0)[0x7f385f2de3c0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb)[0x7f385ec5318b]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x12b)[0x7f385ec32859]
/lib/x86_64-linux-gnu/libc.so.6(+0x25729)[0x7f385ec32729]
/lib/x86_64-linux-gnu/libc.so.6(+0x36f36)[0x7f385ec43f36]
./bin/polymer-opt(+0x45fcd6)[0x559523fdbcd6]
./bin/polymer-opt(+0x43ce36)[0x559523fb8e36]
./bin/polymer-opt(+0x43941d)[0x559523fb541d]
./bin/polymer-opt(+0x438a62)[0x559523fb4a62]
./bin/polymer-opt(+0x439682)[0x559523fb5682]
./bin/polymer-opt(+0x3c17d4)[0x559523f3d7d4]
./bin/polymer-opt(+0x3c20c4)[0x559523f3e0c4]
./bin/polymer-opt(+0x2939e5)[0x559523e0f9e5]
./bin/polymer-opt(+0x293e30)[0x559523e0fe30]
./bin/polymer-opt(+0x296eb1)[0x559523e12eb1]
./bin/polymer-opt(+0x25e133)[0x559523dda133]
./bin/polymer-opt(+0x25e7d4)[0x559523dda7d4]
./bin/polymer-opt(+0x25eaee)[0x559523ddaaee]
./bin/polymer-opt(+0x620ac)[0x559523bde0ac]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0x7f385ec340b3]
./bin/polymer-opt(+0x61c8e)[0x559523bddc8e]
Aborted (core dumped)

And any help on how to run this correctly is appreciated. Thanks

kumasento commented 2 years ago

Thank you for your report!

Interesting, would you mind using the main branch? It might have hit some hidden bugs that unit tests aren't able to discover.

Also, the example code has just been updated to match the latest MLIR fashion, please check those out if that's possible.

Let me know if this would work. Thanks!

lethean1 commented 2 years ago

It seems that your latest commit of main branch doesn't provide llvm directory, and I want to know which version I should use. And the example code I used is as follows:

func @matmul() {
  %A = memref.alloc() : memref<64x64xf32>
  %B = memref.alloc() : memref<64x64xf32>
  %C = memref.alloc() : memref<64x64xf32>

  affine.for %i = 0 to 64 {
    affine.for %j = 0 to 64 {
      affine.for %k = 0 to 64 {
        %0 = affine.load %A[%i, %k] : memref<64x64xf32>
        %1 = affine.load %B[%k, %j] : memref<64x64xf32>
        %2 = mulf %0, %1 : f32
        %3 = affine.load %C[%i, %j] : memref<64x64xf32>
        %4 = addf %2, %3 : f32
        affine.store %4, %C[%i, %j] : memref<64x64xf32>
      }
    }
  }

  return
}

And mulf op still belongs to std dialect in the mlir version I used

kumasento commented 2 years ago

You could find the LLVM version from the Polygeist repo at the point of this commit ID: https://github.com/kumasento/polymer/blob/e87c27c36b3d346612e505a1b5d7939e6b6aeb41/.github/workflows/buildAndTest.yml#L34-L40

from which I reach to: https://github.com/llvm/llvm-project/tree/40b9c39db15929b2b70762b68ecc6c16721f9fb1