Skip to content

[mlir][nvvm] Expose MLIR_NVPTXCOMPILER_ENABLED in mlir-config.h. #84007

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
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mlir/include/mlir/Config/mlir-config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,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
Expand Down
1 change: 0 additions & 1 deletion mlir/lib/Target/LLVM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions mlir/lib/Target/LLVM/NVVM/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,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) \
Expand Down Expand Up @@ -510,7 +510,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) {
Expand Down Expand Up @@ -556,12 +556,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

Expand Down
10 changes: 8 additions & 2 deletions utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,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",
)
Expand Down