aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorAdam Paszke <adam.paszke@gmail.com>2024-04-23 11:34:48 +0200
committerGitHub <noreply@github.com>2024-04-23 11:34:48 +0200
commitbc7204811dd20e124fbb8713e652fcf70872b0b3 (patch)
tree83acff045a03d047ae457ce82d8a3238ce4c167a /utils
parent8cc34fadec71c358c2c69bbca236294afb259e02 (diff)
downloadllvm-bc7204811dd20e124fbb8713e652fcf70872b0b3.zip
llvm-bc7204811dd20e124fbb8713e652fcf70872b0b3.tar.gz
llvm-bc7204811dd20e124fbb8713e652fcf70872b0b3.tar.bz2
[bazel] Add a bazel flag to enable building MLIR with CUDA support (#88856)
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.
Diffstat (limited to 'utils')
-rw-r--r--utils/bazel/llvm-project-overlay/mlir/BUILD.bazel13
-rw-r--r--utils/bazel/llvm-project-overlay/mlir/build_defs.bzl3
2 files changed, 15 insertions, 1 deletions
diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
index 6c732b8..63b24b9 100644
--- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
@@ -6,6 +6,7 @@
# The MLIR "Multi-Level Intermediate Representation" Compiler Infrastructure
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
+load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load(
":build_defs.bzl",
"cc_headers_only",
@@ -28,6 +29,18 @@ exports_files([
"utils/textmate/mlir.json",
])
+bool_flag(
+ name = "enable_cuda",
+ build_setting_default = False,
+)
+
+config_setting(
+ name = "enable_cuda_config",
+ flag_values = {
+ ":enable_cuda": "True",
+ },
+)
+
expand_template(
name = "mlir_config_h_gen",
out = "include/mlir/Config/mlir-config.h",
diff --git a/utils/bazel/llvm-project-overlay/mlir/build_defs.bzl b/utils/bazel/llvm-project-overlay/mlir/build_defs.bzl
index fe39dbe2..53767fd0 100644
--- a/utils/bazel/llvm-project-overlay/mlir/build_defs.bzl
+++ b/utils/bazel/llvm-project-overlay/mlir/build_defs.bzl
@@ -6,7 +6,8 @@
def if_cuda_available(if_true, if_false = []):
return select({
- # CUDA is not yet supported.
+ # CUDA auto-detection is not yet supported.
+ "//mlir:enable_cuda_config": if_true,
"//conditions:default": if_false,
})