[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.
This commit is contained in:
Ingo Müller
2024-03-06 14:14:53 +01:00
committed by GitHub
parent be15a6b3b6
commit 099045a045
4 changed files with 16 additions and 8 deletions

View File

@@ -36,6 +36,9 @@
and targets. */
#cmakedefine01 MLIR_ENABLE_CUDA_CONVERSIONS
/* If set, enables features that depend on the NVIDIA's PTX compiler. */
#cmakedefine01 MLIR_ENABLE_NVPTXCOMPILER
/* If set, enables ROCm-related features in ROCM-related transforms, pipelines,
and targets. */
#cmakedefine01 MLIR_ENABLE_ROCM_CONVERSIONS

View File

@@ -93,7 +93,6 @@ if(MLIR_ENABLE_CUDA_CONVERSIONS)
# Define the `CUDAToolkit` path.
target_compile_definitions(obj.MLIRNVVMTarget
PRIVATE
MLIR_NVPTXCOMPILER_ENABLED=${MLIR_ENABLE_NVPTXCOMPILER}
__DEFAULT_CUDATOOLKIT_PATH__="${MLIR_CUDAToolkit_ROOT}"
)
endif()

View File

@@ -432,7 +432,7 @@ NVPTXSerializer::compileToBinary(const std::string &ptxCode) {
return SmallVector<char, 0>(fatbin.begin(), fatbin.end());
}
#if MLIR_NVPTXCOMPILER_ENABLED == 1
#if MLIR_ENABLE_NVPTXCOMPILER
#include "nvPTXCompiler.h"
#define RETURN_ON_NVPTXCOMPILER_ERROR(expr) \
@@ -511,7 +511,7 @@ NVPTXSerializer::compileToBinaryNVPTX(const std::string &ptxCode) {
RETURN_ON_NVPTXCOMPILER_ERROR(nvPTXCompilerDestroy(&compiler));
return binary;
}
#endif // MLIR_NVPTXCOMPILER_ENABLED == 1
#endif // MLIR_ENABLE_NVPTXCOMPILER
std::optional<SmallVector<char, 0>>
NVPTXSerializer::moduleToObject(llvm::Module &llvmModule) {
@@ -557,12 +557,12 @@ NVPTXSerializer::moduleToObject(llvm::Module &llvmModule) {
return SmallVector<char, 0>(bin.begin(), bin.end());
}
// Compile to binary.
#if MLIR_NVPTXCOMPILER_ENABLED == 1
// Compile to binary.
#if MLIR_ENABLE_NVPTXCOMPILER
return compileToBinaryNVPTX(*serializedISA);
#else
return compileToBinary(*serializedISA);
#endif // MLIR_NVPTXCOMPILER_ENABLED == 1
#endif // MLIR_ENABLE_NVPTXCOMPILER
}
#endif // MLIR_ENABLE_CUDA_CONVERSIONS

View File

@@ -38,8 +38,14 @@ expand_template(
"#cmakedefine01 MLIR_ENABLE_PDL_IN_PATTERNMATCH": "#define MLIR_ENABLE_PDL_IN_PATTERNMATCH 1",
"#cmakedefine01 MLIR_ENABLE_ROCM_CONVERSIONS": "#define MLIR_ENABLE_ROCM_CONVERSIONS 0",
} | if_cuda_available(
{"#cmakedefine01 MLIR_ENABLE_CUDA_CONVERSIONS": "#define MLIR_ENABLE_CUDA_CONVERSIONS 1"},
{"#cmakedefine01 MLIR_ENABLE_CUDA_CONVERSIONS": "#define MLIR_ENABLE_CUDA_CONVERSIONS 0"},
{
"#cmakedefine01 MLIR_ENABLE_CUDA_CONVERSIONS": "#define MLIR_ENABLE_CUDA_CONVERSIONS 1",
"#cmakedefine01 MLIR_ENABLE_NVPTXCOMPILER": "#define MLIR_ENABLE_NVPTXCOMPILER 1",
},
{
"#cmakedefine01 MLIR_ENABLE_CUDA_CONVERSIONS": "#define MLIR_ENABLE_CUDA_CONVERSIONS 0",
"#cmakedefine01 MLIR_ENABLE_NVPTXCOMPILER": "#define MLIR_ENABLE_NVPTXCOMPILER 0",
},
),
template = "include/mlir/Config/mlir-config.h.cmake",
)