daphne-eu / daphne

DAPHNE: An Open and Extensible System Infrastructure for Integrated Data Analysis Pipelines
Apache License 2.0
67 stars 62 forks source link

Vectorized Pipeline fails with -O3 #635

Open philipportner opened 1 year ago

philipportner commented 1 year ago

Description

When passing 3 as the optLevel to mlir::makeOptimizingTransformer in DaphneIrExecuter.cpp:202, the vectorized pipeline produces an error when executing the test in test/api/cli/vectorized/pipeline_7.daphne. This test performs a vectorized matmul with transposed row vector as RHS.

Reproducing the issue

Applying the following patch to main (5cca09c1c491227c95ba181e982e24c4d195f6f8) reproduces the runtime assertion when executing daphne --vec test/api/cli/vectorized/pipeline_7.daphne

diff --git a/src/compiler/execution/DaphneIrExecutor.cpp b/src/compiler/execution/DaphneIrExecutor.cpp
index 2376ad20..d709aedd 100644
--- a/src/compiler/execution/DaphneIrExecutor.cpp
+++ b/src/compiler/execution/DaphneIrExecutor.cpp
@@ -199,7 +199,7 @@ std::unique_ptr<mlir::ExecutionEngine> DaphneIrExecutor::createExecutionEngine(m
 {
     if (module) {
         // An optimization pipeline to use within the execution engine.
-        auto optPipeline = mlir::makeOptimizingTransformer(0, 0, nullptr);
+        auto optPipeline = mlir::makeOptimizingTransformer(3, 0, nullptr);
         std::vector<llvm::StringRef> sharedLibRefs;
         // This next line adds to our Linux platform lock-in
         std::string daphne_executable_dir(std::filesystem::canonical("/proc/self/exe").parent_path());

Error logs

daphne: daphne/src/runtime/local/kernels/MatMul.cpp:256: static void MatMul<DenseMatrix<ValueType>, DenseMatrix<ValueType>, DenseMatrix<ValueType> >::apply(DenseMatrix<ValueType>*&, const DenseMatrix<ValueType>*, const DenseMatrix<ValueType>*, bool, bool, DaphneContext*) [with T = double]: 

Assertion `(nc1 == nr2) && "#cols of lhs and #rows of rhs must be the same"' failed.

[error]: Got an abort signal from the execution engine. Most likely an exception in a shared library. Check logs!
[error]: Execution error: Returning from signal 6

Not all vector splits handled
Not all vector splits handled
Not all vector splits handled

UNREACHABLE executed at UNREACHABLE executeddaphne/src/runtime/local/vectorized/Tasks.h: at daphne/src/runtime/local/vectorized/Tasks.h:110110Not all vector splits handled
UNREACHABLE executed at daphne/src/runtime/local/vectorized/Tasks.h!
:UNREACHABLE executed110!
 at daphne/src/runtime/local/vectorized/Tasks.h:!110!

[error]: Got an abort signal from the execution engine. Most likely an exception in a shared library. Check logs!
[error]: Got an abort signal from the execution engine. Most likely an exception in a shared library. Check logs!
[error]: Got an abort signal from the execution engine. Most likely an exception in a shared library. Check logs!
[error]: Got an abort signal from the execution engine. Most likely an exception in a shared library. Check logs!

[1]    437598 segmentation fault (core dumped)  daphne --vec test/api/cli/vectorized/pipeline_7.daphne
philipportner commented 1 year ago

May be related to #447