Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion Failure in NamedAttribute Construction when Running scalehls-opt command #75

Open
awiuejfnd opened this issue Feb 20, 2024 · 0 comments

Comments

@awiuejfnd
Copy link

Hi ScaleHLS Team,

I encountered an assertion failure when attempting to run scalehls-opt on a C program converted to MLIR, specifically targeting the pedestal subtraction example adapted for ScaleHLS. The error occurs during the design space exploration phase with the -scalehls-dse-pipeline option.

I ran scalehls-opt with the command:

scalehls-opt <input.mlir> -debug-only=scalehls -scalehls-dse-pipeline="top-func=top target-spec=../config.json" | scalehls-translate -scalehls-emit-hlscpp > output.cpp

And I got following error messages:

scalehls-opt: /path/to/attributes.cpp:28: mlir::NamedAttribute::NamedAttribute(StringAttr, Attribute): Assertion `name && value && "expected valid attribute name and value"' failed.

Here's the full bug report:

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: scalehls-opt Naive_Pedestal_Subtraction_No_Struc.mlir -debug-only=scalehls "-scalehls-dse-pipeline=top-func=ped_subtract target-spec=../config.json"
 #0 0x000056364652255a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/llvm/lib/Support/Unix/Signals.inc:569:11
 #1 0x000056364652270b PrintStackTraceSignalHandler(void*) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/llvm/lib/Support/Unix/Signals.inc:636:1
 #2 0x0000563646520d86 llvm::sys::RunSignalHandlers() /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/llvm/lib/Support/Signals.cpp:104:5
 #3 0x0000563646522df5 SignalHandler(int) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #4 0x000014f4cd7fecf0 __restore_rt (/lib64/libpthread.so.0+0x12cf0)
 #5 0x000014f4cc051acf raise (/lib64/libc.so.6+0x4eacf)
 #6 0x000014f4cc024ea5 abort (/lib64/libc.so.6+0x21ea5)
 #7 0x000014f4cc024d79 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x21d79)
 #8 0x000014f4cc04a426 (/lib64/libc.so.6+0x47426)
 #9 0x0000563646201521 mlir::NamedAttribute::NamedAttribute(mlir::StringAttr, mlir::Attribute) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/lib/IR/Attributes.cpp:29:3
#10 0x0000563642ffa80d mlir::NamedAttrList::append(mlir::StringAttr, mlir::Attribute) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/include/mlir/IR/OperationSupport.h:514:12
#11 0x0000563642fdff49 mlir::OperationState::addAttribute(mlir::StringAttr, mlir::Attribute) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/include/mlir/IR/OperationSupport.h:672:3
#12 0x000056364499d376 mlir::scalehls::hls::ConstBufferOp::build(mlir::OpBuilder&, mlir::OperationState&, mlir::Type, mlir::ElementsAttr) /project/scratch01/compile/ruoxiw/scalehls/build/tools/scalehls/include/scalehls/Dialect/HLS/HLS.cpp.inc:1357:3
#13 0x00005636453c3ac7 mlir::scalehls::hls::ConstBufferOp mlir::OpBuilder::create<mlir::scalehls::hls::ConstBufferOp, mlir::MemRefType, mlir::ElementsAttr>(mlir::Location, mlir::MemRefType&&, mlir::ElementsAttr&&) /project/scratch01/compile/ruoxiw/scalehls/build/../polygeist/llvm-project/llvm/../mlir/include/mlir/IR/Builders.h:460:5
#14 0x00005636453c39ca mlir::scalehls::hls::ConstBufferOp mlir::RewriterBase::replaceOpWithNewOp<mlir::scalehls::hls::ConstBufferOp, mlir::MemRefType, mlir::ElementsAttr>(mlir::Operation*, mlir::MemRefType&&, mlir::ElementsAttr&&) /project/scratch01/compile/ruoxiw/scalehls/build/../polygeist/llvm-project/llvm/../mlir/include/mlir/IR/PatternMatch.h:452:18
#15 0x00005636453bd72f (anonymous namespace)::ConvertGetGlobalToConstBuffer::matchAndRewrite(mlir::memref::GetGlobalOp, mlir::PatternRewriter&) const /project/scratch01/compile/ruoxiw/scalehls/lib/Transforms/Dataflow/BufferizeDataflow.cpp:136:14
#16 0x00005636453c372b mlir::detail::OpOrInterfaceRewritePatternBase<mlir::memref::GetGlobalOp>::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const /project/scratch01/compile/ruoxiw/scalehls/build/../polygeist/llvm-project/llvm/../mlir/include/mlir/IR/PatternMatch.h:329:12
#17 0x000056364607d691 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/lib/Rewrite/PatternApplicator.cpp:201:25
#18 0x0000563646020f9a (anonymous namespace)::GreedyPatternRewriteDriver::simplify(llvm::MutableArrayRef<mlir::Region>) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp:270:19
#19 0x00005636460205e8 mlir::applyPatternsAndFoldGreedily(llvm::MutableArrayRef<mlir::Region>, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp:405:8
#20 0x000056364309b9f2 mlir::applyPatternsAndFoldGreedily(mlir::Operation*, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h:71:10
#21 0x0000563645440a6f mlir::scalehls::applyFuncPreprocess(mlir::func::FuncOp, bool) /project/scratch01/compile/ruoxiw/scalehls/lib/Transforms/FuncPreprocess.cpp:189:9
#22 0x000056364544713c (anonymous namespace)::FuncPreprocess::runOnOperation() /project/scratch01/compile/ruoxiw/scalehls/lib/Transforms/FuncPreprocess.cpp:210:3
#23 0x0000563646087f1a mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:462:21
#24 0x00005636460884f4 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:525:16
#25 0x000056364608d5f8 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:745:36
#26 0x000056364608d279 mlir::LogicalResult mlir::failableParallelForEach<__gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&>(mlir::MLIRContext*, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>>, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/include/mlir/IR/Threading.h:46:18
#27 0x000056364608973b mlir::LogicalResult mlir::failableParallelForEach<std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>&, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&>(mlir::MLIRContext*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>&, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/include/mlir/IR/Threading.h:92:10
#28 0x0000563646089048 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:755:14
#29 0x00005636460881a7 mlir::detail::OpToOpPassAdaptor::runOnOperation(bool) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:646:5
#30 0x0000563646087f0b mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:459:5
#31 0x00005636460884f4 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:525:16
#32 0x0000563646089d09 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:828:10
#33 0x0000563646089c3f mlir::PassManager::run(mlir::Operation*) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:808:60
#34 0x0000563645367ee2 performActions(llvm::raw_ostream&, bool, bool, llvm::SourceMgr&, mlir::MLIRContext*, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, bool, bool) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:91:17
#35 0x0000563645367b51 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, bool, bool, bool, bool, bool, bool, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, llvm::ThreadPool*) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:139:12
#36 0x0000563645367942 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool)::$_0::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:181:12
#37 0x0000563645367852 mlir::LogicalResult llvm::function_ref<mlir::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>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool)::$_0>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#38 0x00005636463ac87e llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#39 0x00005636463abe9d mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/lib/Support/ToolUtilities.cpp:28:12
#40 0x00005636453668db mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:186:10
#41 0x0000563645366a6f mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::PassPipelineCLParser const&, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool, bool) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:209:10
#42 0x000056364536767f mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) /project/scratch01/compile/ruoxiw/scalehls/polygeist/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:306:14
#43 0x0000563642f629ec main /project/scratch01/compile/ruoxiw/scalehls/tools/scalehls-opt/scalehls-opt.cpp:16:23
#44 0x000014f4cc03dd85 __libc_start_main (/lib64/libc.so.6+0x3ad85)
#45 0x0000563642f628be _start (/project/scratch01/compiling/ruoxiw/scalehls/build/bin/scalehls-opt+0x1cfe8be)

And here is the generated mlir code:

module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<i64, dense<64> : vector<2xi32>>, #dlti.dl_entry<f80, dense<128> : vector<2xi32>>, #dlti.dl_entry<i1, dense<8> : vector<2xi32>>, #dlti.dl_entry<i8, dense<8> : vector<2xi32>>, #dlti.dl_entry<i16, dense<16> : vector<2xi32>>, #dlti.dl_entry<i32, dense<32> : vector<2xi32>>, #dlti.dl_entry<f16, dense<16> : vector<2xi32>>, #dlti.dl_entry<f64, dense<64> : vector<2xi32>>, #dlti.dl_entry<f128, dense<128> : vector<2xi32>>>, llvm.data_layout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", llvm.target_triple = "x86_64-unknown-linux-gnu", "polygeist.target-cpu" = "x86-64", "polygeist.target-features" = "+cx8,+fxsr,+mmx,+sse,+sse2,+x87", "polygeist.tune-cpu" = "generic"} {
  memref.global @ped_sub_results : memref<256x16xi16> = dense<0>
  func.func @ped_subtract(%arg0: i16, %arg1: i8, %arg2: i8, %arg3: i8, %arg4: i8, %arg5: i32, %arg6: i16, %arg7: i8, %arg8: i8, %arg9: i8, %arg10: i8, %arg11: i8, %arg12: i8, %arg13: memref<4096xi16>, %arg14: i16, %arg15: memref<8192xi16>) -> i32 attributes {llvm.linkage = #llvm.linkage<external>} {
    %c1_i32 = arith.constant 1 : i32
    %c16_i32 = arith.constant 16 : i32
    %c256_i32 = arith.constant 256 : i32
    %c0_i32 = arith.constant 0 : i32
    %alloca = memref.alloca() : memref<i32>
    %0 = arith.extsi %arg10 : i8 to i32
    affine.store %0, %alloca[] : memref<i32>
    %1 = memref.get_global @ped_sub_results : memref<256x16xi16>
    %2 = arith.extsi %arg3 : i8 to i32
    %3 = arith.muli %2, %c256_i32 : i32
    %4 = arith.muli %3, %c16_i32 : i32
    affine.for %arg16 = 0 to 256 {
      %5 = affine.load %alloca[] : memref<i32>
      %6 = arith.muli %5, %c16_i32 : i32
      %7 = arith.addi %4, %6 : i32
      affine.for %arg17 = 0 to 16 {
        %10 = affine.load %arg13[%arg17 + %arg16 * 16] : memref<4096xi16>
        %11 = arith.extsi %10 : i16 to i32
        %12 = arith.index_cast %arg17 : index to i32
        %13 = arith.addi %7, %12 : i32
        %14 = arith.index_cast %13 : i32 to index
        %15 = memref.load %arg15[%14] : memref<8192xi16>
        %16 = arith.extsi %15 : i16 to i32
        %17 = arith.subi %11, %16 : i32
        %18 = arith.trunci %17 : i32 to i16
        affine.store %18, %1[%arg16, %arg17] : memref<256x16xi16>
      }
      %8 = arith.addi %5, %c1_i32 : i32
      %9 = arith.remsi %8, %c256_i32 : i32
      affine.store %9, %alloca[] : memref<i32>
    }
    return %c0_i32 : i32
  }
}

I'm seeking guidance on debugging this issue or any potential workarounds. Any help or insights into what might be causing this error would be greatly appreciated.

Best

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant