intel / graph-compiler

Apache License 2.0
23 stars 14 forks source link

FP constant lowering assertion failure #182

Open kurapov-peter opened 1 month ago

kurapov-peter commented 1 month ago

./TestApiOps --gtest_filter="*.matMul"

Fails with:

TestApiOps: /home/jovyan/graph-compiler/externals/llvm-project/llvm/lib/IR/Type.cpp:108: static llvm::Type* llvm::Type::getFloatingPointTy(llvm::LLVMContext&, const llvm::fltSemantics&): Assertion `&S == &APFloat::PPCDoubleDouble() && "Unknown FP format"' failed.
Aborted (core dumped)
kurapov-peter commented 1 month ago

Complete stack trace:

#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737175215296) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=140737175215296) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=140737175215296, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00007ffff768f476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007ffff76757f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x00007ffff767571b in __assert_fail_base (fmt=0x7ffff782a130 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x7ffff100db48 "&S == &APFloat::PPCDoubleDouble() && \"Unknown FP format\"", file=0x7ffff100d9e8 "/home/jovyan/graph-compiler/externals/llvm-project/llvm/lib/IR/Type.cpp", 
    line=108, function=<optimized out>) at ./assert/assert.c:92
#6  0x00007ffff7686e96 in __GI___assert_fail (assertion=0x7ffff100db48 "&S == &APFloat::PPCDoubleDouble() && \"Unknown FP format\"", file=0x7ffff100d9e8 "/home/jovyan/graph-compiler/externals/llvm-project/llvm/lib/IR/Type.cpp", line=108, 
    function=0x7ffff100dae0 "static llvm::Type* llvm::Type::getFloatingPointTy(llvm::LLVMContext&, const llvm::fltSemantics&)") at ./assert/assert.c:101
#7  0x00007fffee0ac0db in llvm::Type::getFloatingPointTy (C=..., S=...) at /home/jovyan/graph-compiler/externals/llvm-project/llvm/lib/IR/Type.cpp:108
#8  0x00007ffff63acb85 in mlir::LLVM::detail::getLLVMConstant (llvmType=0x555555a95580, attr=attr@entry=..., loc=loc@entry=..., moduleTranslation=...) at /home/jovyan/graph-compiler/externals/llvm-project/llvm/include/llvm/IR/Type.h:129
#9  0x00007ffff633b425 in convertOperationImpl (opInst=..., builder=..., moduleTranslation=...) at /home/jovyan/graph-compiler/externals/llvm-project/build/tools/mlir/include/mlir/Dialect/LLVMIR/LLVMConversions.inc:100
#10 0x00007ffff63aaf46 in mlir::LLVM::ModuleTranslation::convertOperation (this=0x7ffffff748a0, op=..., builder=..., recordInsertions=<optimized out>) at /home/jovyan/graph-compiler/externals/llvm-project/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:916
#11 0x00007ffff63b3d15 in mlir::LLVM::ModuleTranslation::convertBlockImpl (this=0x7ffffff748a0, bb=..., ignoreArguments=<optimized out>, builder=..., recordInsertions=true) at /home/jovyan/graph-compiler/externals/llvm-project/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:964
#12 0x00007ffff63b528e in mlir::LLVM::ModuleTranslation::convertOneFunction (this=0x7ffffff748a0, func=...) at /home/jovyan/graph-compiler/externals/llvm-project/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:1374
#13 0x00007ffff63b5ea8 in mlir::LLVM::ModuleTranslation::convertFunctions (this=0x7ffffff748a0) at /home/jovyan/graph-compiler/externals/llvm-project/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:1540
#14 0x00007ffff63bbc4c in mlir::translateModuleToLLVMIR (module=module@entry=0x555555945090, llvmContext=..., name=..., disableVerification=disableVerification@entry=false) at /home/jovyan/graph-compiler/externals/llvm-project/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:1884
#15 0x00007ffff763d3ba in mlir::ExecutionEngine::create (m=0x555555945090, options=..., tm=std::unique_ptr<llvm::TargetMachine> = {...}) at /usr/include/c++/11/bits/char_traits.h:399
#16 0x00007ffff7c58c3e in mlir::gc::JitModule::create (op=0x555555945090, options=...) at /home/jovyan/graph-compiler/lib/gc/ExecutionEngine/Driver/Driver.cpp:60
#17 0x00007ffff7c4a5a1 in dnnl_graph_compiler_executable::dnnl_graph_compiler_executable (this=0x555555941470, context=..., 
    json="{\n  \"version\": \"3.5.0\",\n  \"engine_kind\": \"cpu\",\n  \"fpmath_mode\": \"any\",\n  \"input_ports\": [\n    0,\n    1,\n    2\n  ],\n  \"output_ports\": [\n    3\n  ],\n  \"graph\": [\n    {\n      \"kind\": \"MatMul\",\n      \"att"...)
    at /home/jovyan/graph-compiler/src/dnnl/dnnl_graph_compiler.cpp:55
#18 0x00007ffff7c44f1d in dnnl_graph_compiler_compile (gc=0x55555576ad60, 
    graph_json=0x55555576a990 "{\n  \"version\": \"3.5.0\",\n  \"engine_kind\": \"cpu\",\n  \"fpmath_mode\": \"any\",\n  \"input_ports\": [\n    0,\n    1,\n    2\n  ],\n  \"output_ports\": [\n    3\n  ],\n  \"graph\": [\n    {\n      \"kind\": \"MatMul\",\n      \"att"..., exe=0x7ffffff75cd8)
    at /home/jovyan/graph-compiler/src/dnnl/dnnl_graph_compiler.cpp:200
#19 0x0000555555591ae4 in exec (fileName=0x5555556b94e7 "matmul.json", inputs=0x7ffffff75e30, outputs=0x7ffffff75e10) at /home/jovyan/graph-compiler/test/dnnl/TestApiOps.cpp:33
#20 0x0000555555592514 in TestApiOps_matMul_Test::TestBody (this=0x555555769e80) at /home/jovyan/graph-compiler/test/dnnl/TestApiOps.cpp:100
#21 0x000055555568aa5d in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void> (object=0x555555769e80, method=&virtual testing::Test::TestBody(), location=0x5555556dc6f3 "the test body") at /home/jovyan/graph-compiler/externals/gtest-src/googletest/src/gtest.cc:2612
#22 0x0000555555681acd in testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void> (object=0x555555769e80, method=&virtual testing::Test::TestBody(), location=0x5555556dc6f3 "the test body") at /home/jovyan/graph-compiler/externals/gtest-src/googletest/src/gtest.cc:2648
#23 0x0000555555659750 in testing::Test::Run (this=0x555555769e80) at /home/jovyan/graph-compiler/externals/gtest-src/googletest/src/gtest.cc:2687
#24 0x000055555565a26b in testing::TestInfo::Run (this=0x555555768960) at /home/jovyan/graph-compiler/externals/gtest-src/googletest/src/gtest.cc:2836
#25 0x000055555565ac79 in testing::TestSuite::Run (this=0x555555766e50) at /home/jovyan/graph-compiler/externals/gtest-src/googletest/src/gtest.cc:3015
#26 0x000055555566b24d in testing::internal::UnitTestImpl::RunAllTests (this=0x5555557684b0) at /home/jovyan/graph-compiler/externals/gtest-src/googletest/src/gtest.cc:5920
#27 0x000055555568bbb2 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (object=0x5555557684b0, 
    method=(bool (testing::internal::UnitTestImpl::*)(testing::internal::UnitTestImpl * const)) 0x55555566ae1e <testing::internal::UnitTestImpl::RunAllTests()>, location=0x5555556dd140 "auxiliary test code (environments or event listeners)")
    at /home/jovyan/graph-compiler/externals/gtest-src/googletest/src/gtest.cc:2612
#28 0x0000555555683032 in testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (object=0x5555557684b0, 
    method=(bool (testing::internal::UnitTestImpl::*)(testing::internal::UnitTestImpl * const)) 0x55555566ae1e <testing::internal::UnitTestImpl::RunAllTests()>, location=0x5555556dd140 "auxiliary test code (environments or event listeners)")
    at /home/jovyan/graph-compiler/externals/gtest-src/googletest/src/gtest.cc:2648
#29 0x0000555555669825 in testing::UnitTest::Run (this=0x55555573b7c0 <testing::UnitTest::GetInstance()::instance>) at /home/jovyan/graph-compiler/externals/gtest-src/googletest/src/gtest.cc:5484
#30 0x000055555559526e in RUN_ALL_TESTS () at /home/jovyan/graph-compiler/externals/gtest-src/googletest/include/gtest/gtest.h:2317
#31 0x0000555555594295 in main (argc=1, argv=0x7fffffffe528) at /home/jovyan/graph-compiler/test/dnnl/TestApiOps.cpp:324
AndreyPavlenko commented 1 month ago

The function being processed:

``` llvm.func @compute(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: i64, %arg3: i64, %arg4: i64, %arg5: i64, %arg6: i64, %arg7: !llvm.ptr, %arg8: !llvm.ptr, %arg9: i64, %arg10: i64, %arg11: i64, %arg12: i64, %arg13: i64, %arg14: !llvm.ptr, %arg15: !llvm.ptr, %arg16: i64, %arg17: i64, %arg18: i64, %arg19: !llvm.ptr, %arg20: !llvm.ptr, %arg21: i64, %arg22: i64, %arg23: i64, %arg24: i64, %arg25: i64) attributes {llvm.emit_c_interface} { %0 = llvm.mlir.zero : !llvm.ptr %1 = llvm.mlir.constant(0.000000e+00 : f32) : f32 %2 = llvm.mlir.constant(0 : index) : i64 %3 = llvm.mlir.constant(512 : index) : i64 %4 = llvm.mlir.constant(1 : index) : i64 %5 = llvm.mlir.constant(64 : index) : i64 %6 = llvm.mlir.constant(128 : index) : i64 %7 = llvm.getelementptr %0[32768] : (!llvm.ptr) -> !llvm.ptr, f32 %8 = llvm.ptrtoint %7 : !llvm.ptr to i64 %9 = llvm.add %8, %5 : i64 %10 = llvm.call @malloc(%9) : (i64) -> !llvm.ptr %11 = llvm.ptrtoint %10 : !llvm.ptr to i64 %12 = llvm.sub %5, %4 : i64 %13 = llvm.add %11, %12 : i64 %14 = llvm.urem %13, %5 : i64 %15 = llvm.sub %13, %14 : i64 %16 = llvm.inttoptr %15 : i64 to !llvm.ptr omp.parallel { omp.wsloop { omp.loop_nest (%arg26, %arg27) : i64 = (%2, %2) to (%3, %5) step (%4, %4) { %23 = llvm.intr.stacksave : !llvm.ptr llvm.br ^bb1 ^bb1: // pred: ^bb0 %24 = llvm.mul %arg26, %5 : i64 %25 = llvm.add %24, %arg27 : i64 %26 = llvm.getelementptr %16[%25] : (!llvm.ptr, i64) -> !llvm.ptr, f32 llvm.store %1, %26 : f32, !llvm.ptr llvm.intr.stackrestore %23 : !llvm.ptr llvm.br ^bb2 ^bb2: // pred: ^bb1 omp.yield } omp.terminator } omp.terminator } omp.parallel { omp.wsloop { omp.loop_nest (%arg26, %arg27) : i64 = (%2, %2) to (%3, %5) step (%4, %4) { %23 = llvm.intr.stacksave : !llvm.ptr llvm.br ^bb1 ^bb1: // pred: ^bb0 llvm.br ^bb2(%2 : i64) ^bb2(%24: i64): // 2 preds: ^bb1, ^bb3 %25 = llvm.icmp "slt" %24, %6 : i64 llvm.cond_br %25, ^bb3, ^bb4 ^bb3: // pred: ^bb2 %26 = llvm.mul %24, %3 : i64 %27 = llvm.add %26, %arg26 : i64 %28 = llvm.getelementptr %arg1[%27] : (!llvm.ptr, i64) -> !llvm.ptr, f32 %29 = llvm.load %28 : !llvm.ptr -> f32 %30 = llvm.mul %24, %5 : i64 %31 = llvm.add %30, %arg27 : i64 %32 = llvm.getelementptr %arg8[%31] : (!llvm.ptr, i64) -> !llvm.ptr, f32 %33 = llvm.load %32 : !llvm.ptr -> f32 %34 = llvm.mul %arg26, %5 : i64 %35 = llvm.add %34, %arg27 : i64 %36 = llvm.getelementptr %16[%35] : (!llvm.ptr, i64) -> !llvm.ptr, f32 %37 = llvm.load %36 : !llvm.ptr -> f32 %38 = llvm.fmul %29, %33 : f32 %39 = llvm.fadd %37, %38 : f32 llvm.store %39, %36 : f32, !llvm.ptr %40 = llvm.add %24, %4 : i64 llvm.br ^bb2(%40 : i64) ^bb4: // pred: ^bb2 llvm.intr.stackrestore %23 : !llvm.ptr llvm.br ^bb5 ^bb5: // pred: ^bb4 omp.yield } omp.terminator } omp.terminator } %17 = llvm.call @malloc(%9) : (i64) -> !llvm.ptr %18 = llvm.ptrtoint %17 : !llvm.ptr to i64 %19 = llvm.add %18, %12 : i64 %20 = llvm.urem %19, %5 : i64 %21 = llvm.sub %19, %20 : i64 %22 = llvm.inttoptr %21 : i64 to !llvm.ptr omp.parallel { omp.wsloop { omp.loop_nest (%arg26, %arg27) : i64 = (%2, %2) to (%3, %5) step (%4, %4) { %23 = llvm.intr.stacksave : !llvm.ptr llvm.br ^bb1 ^bb1: // pred: ^bb0 %24 = llvm.getelementptr %arg15[%arg27] : (!llvm.ptr, i64) -> !llvm.ptr, f32 %25 = llvm.load %24 : !llvm.ptr -> f32 %26 = llvm.mul %arg26, %5 : i64 %27 = llvm.add %26, %arg27 : i64 %28 = llvm.getelementptr %22[%27] : (!llvm.ptr, i64) -> !llvm.ptr, f32 llvm.store %25, %28 : f32, !llvm.ptr llvm.intr.stackrestore %23 : !llvm.ptr llvm.br ^bb2 ^bb2: // pred: ^bb1 omp.yield } omp.terminator } omp.terminator } omp.parallel { omp.wsloop { omp.loop_nest (%arg26, %arg27) : i64 = (%2, %2) to (%3, %5) step (%4, %4) { %23 = llvm.intr.stacksave : !llvm.ptr llvm.br ^bb1 ^bb1: // pred: ^bb0 %24 = llvm.mul %arg26, %5 : i64 %25 = llvm.add %24, %arg27 : i64 %26 = llvm.getelementptr %16[%25] : (!llvm.ptr, i64) -> !llvm.ptr, f32 %27 = llvm.load %26 : !llvm.ptr -> f32 %28 = llvm.getelementptr %22[%25] : (!llvm.ptr, i64) -> !llvm.ptr, f32 %29 = llvm.load %28 : !llvm.ptr -> f32 %30 = llvm.fadd %27, %29 : f32 %31 = llvm.getelementptr %arg20[%25] : (!llvm.ptr, i64) -> !llvm.ptr, f32 llvm.store %30, %31 : f32, !llvm.ptr llvm.intr.stackrestore %23 : !llvm.ptr llvm.br ^bb2 ^bb2: // pred: ^bb1 omp.yield } omp.terminator } omp.terminator } llvm.call @free(%17) : (!llvm.ptr) -> () llvm.call @free(%10) : (!llvm.ptr) -> () llvm.return } ```

It fails when processing the line:

%1 = llvm.mlir.constant(0.000000e+00 : f32) : f32
ZhennanQin commented 1 month ago

Seems to be a LLVM bug, I will discuss this with the local llvm team.

lmontigny commented 1 week ago

to verify from iteration 6. no update currently 08/27