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

Polygeist and CIRCT are out of sync #4

Open
oroppas opened this issue Dec 17, 2021 · 3 comments
Open

Polygeist and CIRCT are out of sync #4

oroppas opened this issue Dec 17, 2021 · 3 comments

Comments

@oroppas
Copy link

oroppas commented Dec 17, 2021

Hi,

I frequently update CIRCT. Polygeist is not in sync with CIRCT's MLIR.
I've recently got the following error where AbstractOperation no longer exists in
Polygeist/llvm-project/mlir/include/mlir/IR/OperationSupport.h

[1/4] Building CXX object tools/mlir-clang/CMakeFiles/mlir-clang.dir/Lib/utils.cc.o
FAILED: tools/mlir-clang/CMakeFiles/mlir-clang.dir/Lib/utils.cc.o
/usr/sbin/c++ -DGTEST_HAS_RTTI=0 -DLLVM_OBJ_ROOT=\"/home/ryutas/packages/circt/build\" -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/ryutas/packages/circt/circt/llvm/llvm/include -I/home/ryutas/packages/circt/build/include -I/home/ryutas/packages/circt/circt/llvm/clang/include -I/home/ryutas/packages/circt/build/tools/clang/include -I/home/ryutas/packages/circt/circt/llvm/mlir/include -I/home/ryutas/packages/circt/build/tools/mlir/include -I/home/ryutas/packages/circt-hls/circt-hls/Polygeist/include -I/home/ryutas/packages/circt-hls/circt-hls/Polygeist/build/include -I/home/ryutas/packages/circt-hls/circt-hls/Polygeist/llvm-project/llvm/../clang/include -I/home/ryutas/packages/circt-hls/circt-hls/Polygeist/build/tools/clang/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wimplicit-fallthrough -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wmisleading-indentation -fdiagnostics-color -g   -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS  -fno-exceptions -fno-rtti -std=gnu++14 -MD -MT tools/mlir-clang/CMakeFiles/mlir-clang.dir/Lib/utils.cc.o -MF tools/mlir-clang/CMakeFiles/mlir-clang.dir/Lib/utils.cc.o.d -o tools/mlir-clang/CMakeFiles/mlir-clang.dir/Lib/utils.cc.o -c /home/ryutas/packages/circt-hls/circt-hls/Polygeist/tools/mlir-clang/Lib/utils.cc
/home/ryutas/packages/circt-hls/circt-hls/Polygeist/tools/mlir-clang/Lib/utils.cc: In function ‘mlir::Operation* mlirclang::buildLinalgOp(const mlir::AbstractOperation*, mlir::OpBuilder&, llvm::SmallVectorImpl<mlir::Value>&, llvm::SmallVectorImpl<mlir::Value>&)’:
/home/ryutas/packages/circt-hls/circt-hls/Polygeist/tools/mlir-clang/Lib/utils.cc:34:22: error: invalid use of incomplete type ‘const class mlir::AbstractOperation’
   34 |   StringRef name = op->name;
      |                      ^~
In file included from /home/ryutas/packages/circt-hls/circt-hls/Polygeist/tools/mlir-clang/Lib/utils.cc:9:
/home/ryutas/packages/circt-hls/circt-hls/Polygeist/tools/mlir-clang/Lib/utils.h:19:7: note: forward declaration of ‘class mlir::AbstractOperation’
   19 | class AbstractOperation;
      |       ^~~~~~~~~~~~~~~~~
/home/ryutas/packages/circt-hls/circt-hls/Polygeist/tools/mlir-clang/Lib/utils.cc: In function ‘mlir::Operation* mlirclang::replaceFuncByOperation(mlir::FuncOp, llvm::StringRef, mlir::OpBuilder&, llvm::SmallVectorImpl<mlir::Value>&, llvm::SmallVectorImpl<mlir::Value>&)’:
/home/ryutas/packages/circt-hls/circt-hls/Polygeist/tools/mlir-clang/Lib/utils.cc:53:52: error: incomplete type ‘mlir::AbstractOperation’ used in nested name specifier
   53 |   const AbstractOperation *op = AbstractOperation::lookup(opName, ctx);
      |                                                    ^~~~~~
/home/ryutas/packages/circt-hls/circt-hls/Polygeist/tools/mlir-clang/Lib/utils.cc:59:47: error: invalid use of incomplete type ‘const class mlir::AbstractOperation’
   59 |   OperationState opState(b.getUnknownLoc(), op->name, input,
      |                                               ^~
In file included from /home/ryutas/packages/circt-hls/circt-hls/Polygeist/tools/mlir-clang/Lib/utils.cc:9:
/home/ryutas/packages/circt-hls/circt-hls/Polygeist/tools/mlir-clang/Lib/utils.h:19:7: note: forward declaration of ‘class mlir::AbstractOperation’
   19 | class AbstractOperation;
      |       ^~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.

Any suggestions to resolve this conflict?

@mortbopet
Copy link
Member

I run into the same issue, and unfortunately think that until Polygeist transforms into more of a publicly maintained project, the best option is to have separate LLVM builds for circt and polygeist. This is also why i updated the README and myself am using two separate builds.

@oroppas
Copy link
Author

oroppas commented Dec 21, 2021

Thank you for the comment. Just to clarify, "as a fallback use the internal LLVM submodule of Polygeist" in README means to build Polygeist as follows? (assuming the current directory is circt-hls/Polygeist)

cmake -G Ninja \
      -B build \
      -S llvm-project/llvm \
      -DCMAKE_BUILD_TYPE=Debug \
      -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
      -DLLVM_TARGETS_TO_BUILD="host" \
      -DLLVM_ENABLE_PROJECTS="clang;mlir" \
      -DLLVM_EXTERNAL_PROJECTS="polygeist" \
      -DLLVM_EXTERNAL_POLYGEIST_SOURCE_DIR=. \
      -DLLVM_ENABLE_ASSERTIONS=ON

@mortbopet
Copy link
Member

I think that would work, yes. What i do locally is build polygeist and LLVM separately, and point Polygeist to the LLVM build.

I do the same locally as what is done in CI (still working on getting CI to pass - it's very slow and there are some slight issues. But, things are working locally for me!).

- name: Polygeist LLVM+MLIR build
if: steps.cache-polygeist-llvm.outputs.cache-hit != 'true'
env:
CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }}
run: |
mkdir -p Polygeist/llvm-project/build
cd Polygeist/llvm-project/build
cmake ../llvm -GNinja \
-DLLVM_ENABLE_PROJECTS="llvm;clang;mlir;openmp" \
-DBUILD_SHARED_LIBS=ON \
-DLLVM_ENABLE_LLD=ON \
-DLLVM_OPTIMIZED_TABLEGEN=ON \
-DCMAKE_BUILD_TYPE=${{ matrix.build }} \
-DCMAKE_CXX_FLAGS="-Wno-c++11-narrowing"
ninja -j$(nproc)

and polygeist building:

- name: Build Polygeist
if: steps.cache-polygeist.outputs.cache-hit != 'true'
env:
CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }}
run: |
mkdir -p Polygeist/build
cd Polygeist/build
cmake -G Ninja .. \
-DMLIR_DIR=$PWD/../llvm-project/build/lib/cmake/mlir \
-DCLANG_DIR=$PWD/../llvm-project/build/lib/cmake/clang \
-DLLVM_TARGETS_TO_BUILD="host" \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_BUILD_TYPE=${{ matrix.build }}
ninja -j$(nproc)
ninja mlir-clang

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