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

[cmake] Fix CMake target dependencies for C++ layer #3325

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

antiagainst
Copy link
Collaborator

This commit wires up some missing dependencies when we are not turning TRITON_BUILD_PYTHON_MODULE on:

  • Still include third_party CodeGen backends
  • Properly query triton_libs, dialect_libs, conversion_libs
  • Exclude third_party python directories if not building Python

This enables a development flow where the focus is on the lower C++ layer. For such cases we can iterate fast with normal CMake and ninja. It also makes it easier to leverage CMake to generate compile_commands.json for workflows where we use Clangd in editors in terminals.

With this, the following commands fully works:

cmake -GNinja -S . -B build-debug \
  -DTRITON_BUILD_PYTHON_MODULE=OFF \
  -DTRITON_CODEGEN_BACKENDS="amd;nvidia" \
  -DCMAKE_BUILD_TYPE=Debug \
  -DLLVM_INCLUDE_DIRS=$HOME/llvm/build-mlir/include \
  -DLLVM_LIBRARY_DIR=$HOME/llvm/build-mlir/lib \
  -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
  -DCMAKE_LINKER=lld \
  -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld \
  -DCMAKE_MODULE_LINKER_FLAGS=-fuse-ld=lld \
  -DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld \
  -DCMAKE_C_COMPILER_LAUNCHER=ccache \
  -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
  -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

cmake --build build-debug

@antiagainst antiagainst requested a review from ptillet as a code owner March 8, 2024 08:18
@antiagainst antiagainst marked this pull request as draft March 8, 2024 08:18
This commit wires up some missing dependencies when we are not
turning `TRITON_BUILD_PYTHON_MODULE` on:

- Still include third_party CodeGen backends
- Properly query `triton_libs`, `dialect_libs`, `conversion_libs`
- Exclude third_party python directories if not building Python

This enables a development flow where the focus is on the lower
C++ layer. For such cases we can iterate fast with normal CMake
and ninja. It also makes it easier to leverage CMake to generate
`compile_commands.json` for workflows where we use Clangd in
editors in terminals.

With this, the following commands fully works:

```
cmake -GNinja -S . -B build-debug \
  -DTRITON_BUILD_PYTHON_MODULE=OFF \
  -DTRITON_CODEGEN_BACKENDS="amd;nvidia" \
  -DCMAKE_BUILD_TYPE=Debug \
  -DLLVM_INCLUDE_DIRS=$HOME/llvm/build-mlir/include \
  -DLLVM_LIBRARY_DIR=$HOME/llvm/build-mlir/lib \
  -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
  -DCMAKE_LINKER=lld \
  -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld \
  -DCMAKE_MODULE_LINKER_FLAGS=-fuse-ld=lld \
  -DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld \
  -DCMAKE_C_COMPILER_LAUNCHER=ccache \
  -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
  -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

cmake --build build-debug
```
Copy link
Collaborator

@ThomasRaoux ThomasRaoux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Lei!

@ThomasRaoux ThomasRaoux marked this pull request as ready for review March 8, 2024 22:52
@ThomasRaoux ThomasRaoux merged commit 678bbe2 into triton-lang:main Mar 8, 2024
4 checks passed
@antiagainst antiagainst deleted the cmake-compilation branch March 9, 2024 04:46
htyu pushed a commit to htyu/triton that referenced this pull request Mar 20, 2024
This commit wires up some missing dependencies when we are not turning
`TRITON_BUILD_PYTHON_MODULE` on:

- Still include third_party CodeGen backends
- Properly query `triton_libs`, `dialect_libs`, `conversion_libs`
- Exclude third_party python directories if not building Python

This enables a development flow where the focus is on the lower C++
layer. For such cases we can iterate fast with normal CMake and ninja.
It also makes it easier to leverage CMake to generate
`compile_commands.json` for workflows where we use Clangd in editors in
terminals.

With this, the following commands fully works:

```
cmake -GNinja -S . -B build-debug \
  -DTRITON_BUILD_PYTHON_MODULE=OFF \
  -DTRITON_CODEGEN_BACKENDS="amd;nvidia" \
  -DCMAKE_BUILD_TYPE=Debug \
  -DLLVM_INCLUDE_DIRS=$HOME/llvm/build-mlir/include \
  -DLLVM_LIBRARY_DIR=$HOME/llvm/build-mlir/lib \
  -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
  -DCMAKE_LINKER=lld \
  -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld \
  -DCMAKE_MODULE_LINKER_FLAGS=-fuse-ld=lld \
  -DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld \
  -DCMAKE_C_COMPILER_LAUNCHER=ccache \
  -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
  -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

cmake --build build-debug
```
karupayun pushed a commit to openxla/triton that referenced this pull request Apr 3, 2024
This commit wires up some missing dependencies when we are not turning
`TRITON_BUILD_PYTHON_MODULE` on:

- Still include third_party CodeGen backends
- Properly query `triton_libs`, `dialect_libs`, `conversion_libs`
- Exclude third_party python directories if not building Python

This enables a development flow where the focus is on the lower C++
layer. For such cases we can iterate fast with normal CMake and ninja.
It also makes it easier to leverage CMake to generate
`compile_commands.json` for workflows where we use Clangd in editors in
terminals.

With this, the following commands fully works:

```
cmake -GNinja -S . -B build-debug \
  -DTRITON_BUILD_PYTHON_MODULE=OFF \
  -DTRITON_CODEGEN_BACKENDS="amd;nvidia" \
  -DCMAKE_BUILD_TYPE=Debug \
  -DLLVM_INCLUDE_DIRS=$HOME/llvm/build-mlir/include \
  -DLLVM_LIBRARY_DIR=$HOME/llvm/build-mlir/lib \
  -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
  -DCMAKE_LINKER=lld \
  -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld \
  -DCMAKE_MODULE_LINKER_FLAGS=-fuse-ld=lld \
  -DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld \
  -DCMAKE_C_COMPILER_LAUNCHER=ccache \
  -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
  -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

cmake --build build-debug
```
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

Successfully merging this pull request may close these issues.

2 participants