Skip to content

Commit 099045a

Browse files
[mlir][nvvm] Expose MLIR_NVPTXCOMPILER_ENABLED in mlir-config.h. (#84007)
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 be15a6b commit 099045a

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
@@ -36,6 +36,9 @@
3636
and targets. */
3737
#cmakedefine01 MLIR_ENABLE_CUDA_CONVERSIONS
3838

39+
/* If set, enables features that depend on the NVIDIA's PTX compiler. */
40+
#cmakedefine01 MLIR_ENABLE_NVPTXCOMPILER
41+
3942
/* If set, enables ROCm-related features in ROCM-related transforms, pipelines,
4043
and targets. */
4144
#cmakedefine01 MLIR_ENABLE_ROCM_CONVERSIONS

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
@@ -432,7 +432,7 @@ NVPTXSerializer::compileToBinary(const std::string &ptxCode) {
432432
return SmallVector<char, 0>(fatbin.begin(), fatbin.end());
433433
}
434434

435-
#if MLIR_NVPTXCOMPILER_ENABLED == 1
435+
#if MLIR_ENABLE_NVPTXCOMPILER
436436
#include "nvPTXCompiler.h"
437437

438438
#define RETURN_ON_NVPTXCOMPILER_ERROR(expr) \
@@ -511,7 +511,7 @@ NVPTXSerializer::compileToBinaryNVPTX(const std::string &ptxCode) {
511511
RETURN_ON_NVPTXCOMPILER_ERROR(nvPTXCompilerDestroy(&compiler));
512512
return binary;
513513
}
514-
#endif // MLIR_NVPTXCOMPILER_ENABLED == 1
514+
#endif // MLIR_ENABLE_NVPTXCOMPILER
515515

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

560-
// Compile to binary.
561-
#if MLIR_NVPTXCOMPILER_ENABLED == 1
560+
// Compile to binary.
561+
#if MLIR_ENABLE_NVPTXCOMPILER
562562
return compileToBinaryNVPTX(*serializedISA);
563563
#else
564564
return compileToBinary(*serializedISA);
565-
#endif // MLIR_NVPTXCOMPILER_ENABLED == 1
565+
#endif // MLIR_ENABLE_NVPTXCOMPILER
566566
}
567567
#endif // MLIR_ENABLE_CUDA_CONVERSIONS
568568

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@ expand_template(
3838
"#cmakedefine01 MLIR_ENABLE_PDL_IN_PATTERNMATCH": "#define MLIR_ENABLE_PDL_IN_PATTERNMATCH 1",
3939
"#cmakedefine01 MLIR_ENABLE_ROCM_CONVERSIONS": "#define MLIR_ENABLE_ROCM_CONVERSIONS 0",
4040
} | if_cuda_available(
41-
{"#cmakedefine01 MLIR_ENABLE_CUDA_CONVERSIONS": "#define MLIR_ENABLE_CUDA_CONVERSIONS 1"},
42-
{"#cmakedefine01 MLIR_ENABLE_CUDA_CONVERSIONS": "#define MLIR_ENABLE_CUDA_CONVERSIONS 0"},
41+
{
42+
"#cmakedefine01 MLIR_ENABLE_CUDA_CONVERSIONS": "#define MLIR_ENABLE_CUDA_CONVERSIONS 1",
43+
"#cmakedefine01 MLIR_ENABLE_NVPTXCOMPILER": "#define MLIR_ENABLE_NVPTXCOMPILER 1",
44+
},
45+
{
46+
"#cmakedefine01 MLIR_ENABLE_CUDA_CONVERSIONS": "#define MLIR_ENABLE_CUDA_CONVERSIONS 0",
47+
"#cmakedefine01 MLIR_ENABLE_NVPTXCOMPILER": "#define MLIR_ENABLE_NVPTXCOMPILER 0",
48+
},
4349
),
4450
template = "include/mlir/Config/mlir-config.h.cmake",
4551
)

0 commit comments

Comments
 (0)