llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.61k stars 11.82k forks source link

[mlir] [vector] -convert-vector-to-gpu crashes #107967

Open axeabc opened 1 month ago

axeabc commented 1 month ago

git version: 761bf333e378b52614c

system: Ubuntu 18.04.6 LTS

reproduce with: mlir-opt -convert-vector-to-gpu a.mlir

a.mlir:

#map = affine_map<(d0, d1, d2) -> (d0, d2)>
#map1 = affine_map<(d0, d1, d2) -> (d2, d1)>
#map2 = affine_map<(d0, d1, d2) -> (d0, d1)>
module {
  func.func @matmul_mk_kn_mn_4x4xi32_extui_i64(%arg0: vector<4x4xi32>, %arg1: vector<4x4xi32>, %arg2: vector <4x4xi64>) -> vector<4x4xi64 > {
    %0 = arith.extui %arg0 : vector<4x4xi32> to vector<4x4xi64>
    %1 = arith.extui %arg1 : vector<4x4xi32> to vector<4x4xi64>
    %2 = vector.contract {indexing_maps = [#map, #map1, #map2], iterator_types = ["parallel", "parallel", "reduction"], kind = #vector.kind<add>} %0, %1, %arg2 : vector<4x4xi64>, vector<4x4xi64> into vector<4x4xi64>
    return %2 : vector<4x4xi64>
  }
}

stack trace:

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.  Program arguments: /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -convert-vector-to-gpu a.mlir
 #0 0x000055fabd724128 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10d7128)
 #1 0x000055fabd721c3e llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10d4c3e)
 #2 0x000055fabd724abd SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f9c83b13420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x000055fac024dbb8 bool integerExtendSupportsMMAMatrixType<mlir::arith::ExtUIOp>(mlir::arith::ExtUIOp) VectorToGPU.cpp:0:0
 #5 0x000055fac024cedb bool __gnu_cxx::__ops::_Iter_pred<getOpToConvert(mlir::Operation*, bool)::$_2::operator()(mlir::vector::ContractionOp) const::'lambda'(mlir::Operation*)>::operator()<mlir::Operation* const*>(mlir::Operation* const*) VectorToGPU.cpp:0:0
 #6 0x000055fac024c47c void llvm::function_ref<void (mlir::Operation*)>::callback_fn<std::enable_if<!llvm::is_one_of<mlir::vector::ContractionOp, mlir::Operation*, mlir::Region*, mlir::Block*>::value && std::is_same<void, void>::value, void>::type mlir::detail::walk<(mlir::WalkOrder)1, mlir::ForwardIterator, getOpToConvert(mlir::Operation*, bool)::$_2, mlir::vector::ContractionOp, void>(mlir::Operation*, getOpToConvert(mlir::Operation*, bool)::$_2&&)::'lambda'(mlir::Operation*)>(long, mlir::Operation*) VectorToGPU.cpp:0:0
 #7 0x000055fabd82824e void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11db24e)
 #8 0x000055fabd82824e void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11db24e)
 #9 0x000055fac024591c getOpToConvert(mlir::Operation*, bool) VectorToGPU.cpp:0:0
#10 0x000055fac0243545 mlir::convertVectorToMMAOps(mlir::RewriterBase&, mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x3bf6545)
#11 0x000055fac0252d39 (anonymous namespace)::ConvertVectorToGPUPass::runOnOperation() VectorToGPU.cpp:0:0
#12 0x000055fac08162d6 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41c92d6)
#13 0x000055fac0816c40 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41c9c40)
#14 0x000055fac0819282 mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41cc282)
#15 0x000055fac0811ab1 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#16 0x000055fac081170b llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_0>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#17 0x000055fac08be3a5 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x42713a5)
#18 0x000055fac080cb35 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41bfb35)
#19 0x000055fac080cddf mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41bfddf)
#20 0x000055fac080d10e mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41c010e)
#21 0x000055fabd704d67 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10b7d67)
#22 0x00007f9c83131083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#23 0x000055fabd7048ee _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10b78ee)
CoTinker commented 1 month ago

The #map of vector.contract is missed, so I can't reproduce it.

axeabc commented 1 month ago

The #map of vector.contract is missed, so I can't reproduce it.

Sorry for that, I have updated the test case.