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

scalehls-opt crash when N=16 #41

Closed
SerenaC94 opened this issue Mar 30, 2022 · 8 comments
Closed

scalehls-opt crash when N=16 #41

SerenaC94 opened this issue Mar 30, 2022 · 8 comments

Comments

@SerenaC94
Copy link

Hi,

I just installed the tool and tried to run the gemm example as described in the README. The first attempt worked fine, then I changed N=32 to N=16 in test_gemm.c, run mlir-clang, and scalehls-opt crashed with the following stack trace:

scalehls-opt test_gemm16.mlir -debug-only=scalehls     -scalehls-dse-pipeline="top-func=test_gemm target-spec=../config.json"
Start multiple level DSE.
----------
Stage1: Simplify loop nests structure...

Finish Stage1.
----------
Stage2: Apply loop perfection, loop order opt, and remove variable loop bound...
Loop band 0: Loop order opt (1,2,0) 

Finish Stage2.
----------
Stage3: Conduct top function design space exploration...
Loop band 0: Initialize the loop design space...
(1,1,1) (2,1,1) (4,1,1) (8,1,1) (16,1,1) scalehls-opt: /files0/extended/curz959/scalehls/polygeist/llvm-project/mlir/include/mlir/IR/AttributeSupport.h:126: const mlir::AbstractAttribute &mlir::AttributeStorage::getAbstractAttribute() const: Assertion `abstractAttribute && "Malformed attribute storage object."' failed.
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 test_gemm16.mlir -debug-only=scalehls "-scalehls-dse-pipeline=top-func=test_gemm target-spec=../config.json"
 #0 0x000000000462243a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /files0/extended/curz959/scalehls/polygeist/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:11
 #1 0x000000000462260b PrintStackTraceSignalHandler(void*) /files0/extended/curz959/scalehls/polygeist/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:1
 #2 0x0000000004620be5 llvm::sys::RunSignalHandlers() /files0/extended/curz959/scalehls/polygeist/llvm-project/llvm/lib/Support/Signals.cpp:96:5
 #3 0x0000000004622d81 SignalHandler(int) /files0/extended/curz959/scalehls/polygeist/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #4 0x00007f661269e3c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x143c0)
 #5 0x00007f661213103b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4303b)
 #6 0x00007f6612110859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #7 0x00007f6612110729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #8 0x00007f6612122006 (/lib/x86_64-linux-gnu/libc.so.6+0x34006)
 #9 0x0000000001aac952 mlir::AttributeStorage::getAbstractAttribute() const /files0/extended/curz959/scalehls/polygeist/llvm-project/mlir/include/mlir/IR/AttributeSupport.h:0:5
#10 0x00000000042fbf68 mlir::Attribute::getDialect() const /files0/extended/curz959/scalehls/polygeist/llvm-project/mlir/include/mlir/IR/Attributes.h:73:41
#11 0x0000000004312205 mlir::Attribute::getContext() const /files0/extended/curz959/scalehls/polygeist/llvm-project/mlir/lib/IR/Attributes.cpp:20:66
#12 0x0000000001a77446 mlir::Operation::getContext() /files0/extended/curz959/scalehls/polygeist/llvm-project/mlir/include/mlir/IR/Operation.h:99:31
#13 0x0000000001a65f9d mlir::OpState::getContext() /files0/extended/curz959/scalehls/polygeist/llvm-project/mlir/include/mlir/IR/OpDefinition.h:109:31
#14 0x0000000001b08233 mlir::getTripCountMapAndOperands(mlir::AffineForOp, mlir::AffineMap*, llvm::SmallVectorImpl<mlir::Value>*) /files0/extended/curz959/scalehls/polygeist/llvm-project/mlir/lib/Dialect/Affine/Analysis/LoopAnalysis.cpp:38:16
#15 0x0000000001b086cd mlir::getConstantTripCount(mlir::AffineForOp) /files0/extended/curz959/scalehls/polygeist/llvm-project/mlir/lib/Dialect/Affine/Analysis/LoopAnalysis.cpp:88:8
#16 0x00000000035c61c0 mlir::scalehls::getAverageTripCount(mlir::AffineForOp) /files0/extended/curz959/scalehls/lib/Support/Utils.cpp:383:32
#17 0x000000000363852a mlir::scalehls::ScaleHLSEstimator::visitOp(mlir::AffineForOp, long) /files0/extended/curz959/scalehls/lib/Transforms/QoREstimation.cpp:422:28
#18 0x000000000363a652 mlir::scalehls::ScaleHLSEstimator::estimateLoop(mlir::AffineForOp, mlir::FuncOp) /files0/extended/curz959/scalehls/lib/Transforms/QoREstimation.cpp:912:15
#19 0x00000000035e50b8 mlir::scalehls::LoopDesignSpace::evaluateTileConfig(unsigned int) /files0/extended/curz959/scalehls/lib/Transforms/MultipleLevelDSE.cpp:240:23
#20 0x00000000035e550b mlir::scalehls::LoopDesignSpace::initializeLoopDesignSpace(unsigned int) /files0/extended/curz959/scalehls/lib/Transforms/MultipleLevelDSE.cpp:278:3
#21 0x00000000035e8311 mlir::scalehls::ScaleHLSOptimizer::exploreDesignSpace(mlir::FuncOp, bool, llvm::StringRef, llvm::StringRef) /files0/extended/curz959/scalehls/lib/Transforms/MultipleLevelDSE.cpp:0:11
#22 0x00000000035e8c49 mlir::scalehls::ScaleHLSOptimizer::applyMultipleLevelDSE(mlir::FuncOp, bool, llvm::StringRef, llvm::StringRef) /files0/extended/curz959/scalehls/lib/Transforms/MultipleLevelDSE.cpp:819:7
#23 0x00000000035ebd6b (anonymous namespace)::MultipleLevelDSE::runOnOperation() /files0/extended/curz959/scalehls/lib/Transforms/MultipleLevelDSE.cpp:894:5
#24 0x00000000041f0aa8 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /files0/extended/curz959/scalehls/polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:402:21
#25 0x00000000041f1095 mlir::detail::OpToOpPassAdaptor::runPipeline(llvm::iterator_range<llvm::pointee_iterator<std::unique_ptr<mlir::Pass, std::default_delete<mlir::Pass> >*, mlir::Pass> >, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /files0/extended/curz959/scalehls/polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:461:16
#26 0x00000000041f277e mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) /files0/extended/curz959/scalehls/polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:703:10
#27 0x00000000041f266e mlir::PassManager::run(mlir::Operation*) /files0/extended/curz959/scalehls/polygeist/llvm-project/mlir/lib/Pass/Pass.cpp:683:60
#28 0x000000000359c978 performActions(llvm::raw_ostream&, bool, bool, llvm::SourceMgr&, mlir::MLIRContext*, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>) /files0/extended/curz959/scalehls/polygeist/llvm-project/mlir/lib/Support/MlirOptMain.cpp:79:17
#29 0x000000000359b784 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, bool, bool, bool, bool, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, llvm::ThreadPool*) /files0/extended/curz959/scalehls/polygeist/llvm-project/mlir/lib/Support/MlirOptMain.cpp:119:12
#30 0x000000000359b539 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) /files0/extended/curz959/scalehls/polygeist/llvm-project/mlir/lib/Support/MlirOptMain.cpp:169:10
#31 0x000000000359b948 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) /files0/extended/curz959/scalehls/polygeist/llvm-project/mlir/lib/Support/MlirOptMain.cpp:189:10
#32 0x000000000359c607 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) /files0/extended/curz959/scalehls/polygeist/llvm-project/mlir/lib/Support/MlirOptMain.cpp:293:14
#33 0x00000000019f0968 main /files0/extended/curz959/scalehls/tools/scalehls-opt/scalehls-opt.cpp:16:23
#34 0x00007f66121120b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b3)
#35 0x00000000019f082e _start (/files0/extended/curz959/scalehls/build/bin/scalehls-opt+0x19f082e)
Aborted

What is going wrong here?

P.S. which version of Xilinx tools do you currently support?

@hanchenye
Copy link
Collaborator

Hi, thanks for catching this. I can reproduce the error and it seems the DSE has issue when a loop at a specific position is fully unrolled. Will take a look and get back to you soon!

@SerenaC94
Copy link
Author

The same thing happens with N=8

@hanchenye
Copy link
Collaborator

Has fixed on my local branch, I'll merge to the main after resolving some conflicts soon.

@SerenaC94
Copy link
Author

Great, thanks!

@hanchenye
Copy link
Collaborator

Fixed in 9ac0314.

@SerenaC94
Copy link
Author

The crash was fixed, but now scaleHLS generates a C++ file with the same content as the input one, no pragmas and no unrolling/tiling. Is that expected?

@hanchenye
Copy link
Collaborator

@SerenaC94 No, that's not. Your example works correctly on my end. Do you mind to put your test file and terminal command here?

@SerenaC94
Copy link
Author

Sorry I just found a mistake on my end. It works fine

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

2 participants