Skip to content

Commit 3c27600

Browse files
[mlir][nvvm] Expose MLIR_NVPTXCOMPILER_ENABLED in mlir-config.h.
This is another follow-up of #83004, which made the same change for `MLIR_CUDA_CONVERSIONS_ENABLED`. As the previous PR, this PR commit exposes mentioned CMake variable through `mlir-config.h` and uses the macro that is introduced with the same name. This replaces the macro `MLIR_NVPTXCOMPILER_ENABLED`, which the CMake files previously defined manually.
1 parent ff66e9b commit 3c27600

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

mlir/include/mlir/Config/mlir-config.h.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,7 @@
3333
and targets. */
3434
#cmakedefine01 MLIR_ENABLE_CUDA_CONVERSIONS
3535

36+
/* If set, enables features that depend on the NVIDIA's PTX compiler. */
37+
#cmakedefine01 MLIR_ENABLE_NVPTXCOMPILER
38+
3639
#endif

mlir/lib/Target/LLVM/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ if(MLIR_ENABLE_CUDA_CONVERSIONS)
9393
# Define the `CUDAToolkit` path.
9494
target_compile_definitions(obj.MLIRNVVMTarget
9595
PRIVATE
96-
MLIR_NVPTXCOMPILER_ENABLED=${MLIR_ENABLE_NVPTXCOMPILER}
9796
__DEFAULT_CUDATOOLKIT_PATH__="${MLIR_CUDAToolkit_ROOT}"
9897
)
9998
endif()

mlir/lib/Target/LLVM/NVVM/Target.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ NVPTXSerializer::compileToBinary(const std::string &ptxCode) {
431431
return SmallVector<char, 0>(fatbin.begin(), fatbin.end());
432432
}
433433

434-
#if MLIR_NVPTXCOMPILER_ENABLED == 1
434+
#if MLIR_ENABLE_NVPTXCOMPILER
435435
#include "nvPTXCompiler.h"
436436

437437
#define RETURN_ON_NVPTXCOMPILER_ERROR(expr) \
@@ -510,7 +510,7 @@ NVPTXSerializer::compileToBinaryNVPTX(const std::string &ptxCode) {
510510
RETURN_ON_NVPTXCOMPILER_ERROR(nvPTXCompilerDestroy(&compiler));
511511
return binary;
512512
}
513-
#endif // MLIR_NVPTXCOMPILER_ENABLED == 1
513+
#endif // MLIR_ENABLE_NVPTXCOMPILER
514514

515515
std::optional<SmallVector<char, 0>>
516516
NVPTXSerializer::moduleToObject(llvm::Module &llvmModule) {
@@ -556,12 +556,12 @@ NVPTXSerializer::moduleToObject(llvm::Module &llvmModule) {
556556
return SmallVector<char, 0>(bin.begin(), bin.end());
557557
}
558558

559-
// Compile to binary.
560-
#if MLIR_NVPTXCOMPILER_ENABLED == 1
559+
// Compile to binary.
560+
#if MLIR_ENABLE_NVPTXCOMPILER
561561
return compileToBinaryNVPTX(*serializedISA);
562562
#else
563563
return compileToBinary(*serializedISA);
564-
#endif // MLIR_NVPTXCOMPILER_ENABLED == 1
564+
#endif // MLIR_ENABLE_NVPTXCOMPILER
565565
}
566566
#endif // MLIR_ENABLE_CUDA_CONVERSIONS
567567

utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,14 @@ expand_template(
3636
"#cmakedefine MLIR_GREEDY_REWRITE_RANDOMIZER_SEED ${MLIR_GREEDY_REWRITE_RANDOMIZER_SEED}": "/* #undef MLIR_GREEDY_REWRITE_RANDOMIZER_SEED */",
3737
"#cmakedefine01 MLIR_ENABLE_PDL_IN_PATTERNMATCH": "#define MLIR_ENABLE_PDL_IN_PATTERNMATCH 1",
3838
} | if_cuda_available(
39-
{"#cmakedefine01 MLIR_ENABLE_CUDA_CONVERSIONS": "#define MLIR_ENABLE_CUDA_CONVERSIONS 1"},
40-
{"#cmakedefine01 MLIR_ENABLE_CUDA_CONVERSIONS": "#define MLIR_ENABLE_CUDA_CONVERSIONS 0"},
39+
{
40+
"#cmakedefine01 MLIR_ENABLE_CUDA_CONVERSIONS": "#define MLIR_ENABLE_CUDA_CONVERSIONS 1",
41+
"#cmakedefine01 MLIR_ENABLE_NVPTXCOMPILER": "#define MLIR_ENABLE_NVPTXCOMPILER 1",
42+
},
43+
{
44+
"#cmakedefine01 MLIR_ENABLE_CUDA_CONVERSIONS": "#define MLIR_ENABLE_CUDA_CONVERSIONS 0",
45+
"#cmakedefine01 MLIR_ENABLE_NVPTXCOMPILER": "#define MLIR_ENABLE_NVPTXCOMPILER 0",
46+
},
4147
),
4248
template = "include/mlir/Config/mlir-config.h.cmake",
4349
)

0 commit comments

Comments
 (0)