Skip to content

[bazel] Add a bazel flag to enable building MLIR with CUDA support #88856

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

Merged
merged 1 commit into from
Apr 23, 2024

Conversation

apaszke
Copy link
Member

@apaszke apaszke commented Apr 16, 2024

This makes it possible to specify --@llvm-project//mlir:enable_cuda=true on the bazel command line and get a build that includes NVIDIA GPU support in MLIR.

@apaszke apaszke requested a review from rupprecht as a code owner April 16, 2024 08:37
@llvmbot llvmbot added the bazel "Peripheral" support tier build system: utils/bazel label Apr 16, 2024
@rupprecht rupprecht requested review from chsigg and akuegel April 18, 2024 11:16
@chsigg
Copy link
Contributor

chsigg commented Apr 18, 2024

Does this flag correspond to one of the CMake flags? Should it have a similar name, or be referenced in a comment?

I assume this flag will not be tested in CI. Have you tested it locally? Does it trigger a dependency on the CUDA toolkit?

@apaszke
Copy link
Member Author

apaszke commented Apr 22, 2024

Does this flag correspond to one of the CMake flags?

It corresponds to this part of the CMake config.

Have you tested it locally? Does it trigger a dependency on the CUDA toolkit?

Yes, I have tested the flag locally. It doesn't actually add a dependency on the CUDA toolkit, but only enables a number of MLIR passes that are otherwise #ifdefed away by MLIR_ENABLE_CUDA_CONVERSIONS.

@chsigg
Copy link
Contributor

chsigg commented Apr 22, 2024

Thanks Adam.

Ok, it seems that if_cuda_available doesn't trigger MLIR_ENABLE_NVPTXCOMPILER (yet), which would require a CUDA toolkit to be available.

What about converting to NVVM binary though, doesn't this call expect to find CUDA tools?

@apaszke
Copy link
Member Author

apaszke commented Apr 22, 2024

It does, but it's a run-time dependency. Which shouldn't affect the build significantly and after all... I'd expect that if someone enables this flag then it's on them to provide all the tools necessary.

@chsigg
Copy link
Contributor

chsigg commented Apr 22, 2024

I'd expect that if someone enables this flag then it's on them to provide all the tools necessary.

I would expect that people will use a flag if it's there. I'm not saying we shouldn't land this as is and in the current state it looks clean. I was just trying to understand what is already supported. E.g., it doesn't trigger any new tests that would require a CUDA toolkit to be found.

I would expect though that proper CUDA support with bazel would pull the toolkit as an external dependency. But that's clearly a separate next step.

@chsigg chsigg merged commit bc72048 into llvm:main Apr 23, 2024
@apaszke apaszke deleted the cuda-flag branch April 23, 2024 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bazel "Peripheral" support tier build system: utils/bazel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants