Skip to content

Commit 1828deb

Browse files
authored
[mlir][gpu] Deprecate gpu::Serialization* passes. (#65857)
Deprecate the `gpu-to-cubin` & `gpu-to-hsaco` passes in favor of the `TargetAttr` workflow. This patch removes remaining upstream uses of the aforementioned passes, including the option to use them in `mlir-opt`. A future patch will remove these passes entirely. The passes can be re-enabled in `mlir-opt` by adding the CMake flag: `-DMLIR_ENABLE_DEPRECATED_GPU_SERIALIZATION=1`.
1 parent 4ee7cf7 commit 1828deb

File tree

14 files changed

+23
-230
lines changed

14 files changed

+23
-230
lines changed

mlir/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ else()
114114
endif()
115115
add_definitions(-DMLIR_ROCM_CONVERSIONS_ENABLED=${MLIR_ENABLE_ROCM_CONVERSIONS})
116116

117+
set(MLIR_ENABLE_DEPRECATED_GPU_SERIALIZATION 0 CACHE BOOL "Enable deprecated GPU serialization passes")
117118
set(MLIR_ENABLE_CUDA_RUNNER 0 CACHE BOOL "Enable building the mlir CUDA runner")
118119
set(MLIR_ENABLE_ROCM_RUNNER 0 CACHE BOOL "Enable building the mlir ROCm runner")
119120
set(MLIR_ENABLE_SPIRV_CPU_RUNNER 0 CACHE BOOL "Enable building the mlir SPIR-V cpu runner")

mlir/include/mlir/Dialect/GPU/Transforms/Passes.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,17 @@ class SerializeToBlobPass : public OperationPass<gpu::GPUModuleOp> {
134134

135135
/// Register pass to serialize GPU kernel functions to a CUBIN binary
136136
/// annotation.
137+
LLVM_DEPRECATED("use Target attributes instead", "")
137138
void registerGpuSerializeToCubinPass();
138139

139140
/// Register pass to serialize GPU kernel functions to a HSAco binary
140141
/// annotation.
142+
LLVM_DEPRECATED("use Target attributes instead", "")
141143
void registerGpuSerializeToHsacoPass();
142144

143145
/// Create an instance of the GPU kernel function to CUBIN binary serialization
144146
/// pass with optLevel (default level 2).
147+
LLVM_DEPRECATED("use Target attributes instead", "")
145148
std::unique_ptr<Pass> createGpuSerializeToCubinPass(StringRef triple,
146149
StringRef chip,
147150
StringRef features,
@@ -150,6 +153,7 @@ std::unique_ptr<Pass> createGpuSerializeToCubinPass(StringRef triple,
150153

151154
/// Create an instance of the GPU kernel function to HSAco binary serialization
152155
/// pass.
156+
LLVM_DEPRECATED("use Target attributes instead", "")
153157
std::unique_ptr<Pass> createGpuSerializeToHsacoPass(StringRef triple,
154158
StringRef arch,
155159
StringRef features,

mlir/include/mlir/InitAllPasses.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ inline void registerAllPasses() {
6565
bufferization::registerBufferizationPasses();
6666
func::registerFuncPasses();
6767
registerGPUPasses();
68-
registerGpuSerializeToCubinPass();
69-
registerGpuSerializeToHsacoPass();
7068
registerLinalgPasses();
7169
registerNVGPUPasses();
7270
registerSparseTensorPasses();

mlir/lib/Dialect/SparseTensor/Pipelines/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,3 @@ add_mlir_dialect_library(MLIRSparseTensorPipelines
2727
MLIRVectorToLLVM
2828
MLIRVectorTransforms
2929
)
30-
31-
if(MLIR_ENABLE_CUDA_RUNNER)
32-
# Enable gpu-to-cubin pass.
33-
target_compile_definitions(obj.MLIRSparseTensorPipelines
34-
PRIVATE
35-
MLIR_GPU_TO_CUBIN_PASS_ENABLE=1
36-
)
37-
endif()

mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,13 @@ void mlir::sparse_tensor::buildSparseCompiler(
7878

7979
// Finalize GPU code generation.
8080
if (gpuCodegen) {
81-
#if MLIR_GPU_TO_CUBIN_PASS_ENABLE
82-
pm.addNestedPass<gpu::GPUModuleOp>(createGpuSerializeToCubinPass(
83-
options.gpuTriple, options.gpuChip, options.gpuFeatures));
84-
#endif
81+
GpuNVVMAttachTargetOptions nvvmTargetOptions;
82+
nvvmTargetOptions.triple = options.gpuTriple;
83+
nvvmTargetOptions.chip = options.gpuChip;
84+
nvvmTargetOptions.features = options.gpuFeatures;
85+
pm.addPass(createGpuNVVMAttachTarget(nvvmTargetOptions));
8586
pm.addPass(createGpuToLLVMConversionPass());
87+
pm.addPass(createGpuModuleToBinaryPass());
8688
}
8789

8890
pm.addPass(createReconcileUnrealizedCastsPass());

mlir/test/Conversion/GPUToCUDA/lit.local.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

mlir/test/Conversion/GPUToCUDA/lower-nvvm-kernel-to-cubin.mlir

Lines changed: 0 additions & 25 deletions
This file was deleted.

mlir/test/Conversion/GPUToROCm/lit.local.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

mlir/test/Conversion/GPUToROCm/lower-rocdl-kernel-to-hsaco.mlir

Lines changed: 0 additions & 25 deletions
This file was deleted.

mlir/test/lib/Dialect/GPU/CMakeLists.txt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ set(LIBS
3131
)
3232

3333
add_mlir_library(MLIRGPUTestPasses
34-
TestConvertGPUKernelToCubin.cpp
35-
TestConvertGPUKernelToHsaco.cpp
3634
TestGpuMemoryPromotion.cpp
3735
TestGpuRewrite.cpp
3836
TestLowerToNVVM.cpp
@@ -43,12 +41,3 @@ add_mlir_library(MLIRGPUTestPasses
4341
${LIBS}
4442
)
4543

46-
# This is how it is defined in mlir/lib/Dialect/GPU/CMakeLists.txt
47-
# We probably want something better project-wide
48-
if(MLIR_ENABLE_CUDA_RUNNER)
49-
# Enable gpu-to-cubin pass.
50-
target_compile_definitions(MLIRGPUTestPasses
51-
PRIVATE
52-
MLIR_GPU_TO_CUBIN_PASS_ENABLE=1
53-
)
54-
endif()

mlir/test/lib/Dialect/GPU/TestConvertGPUKernelToCubin.cpp

Lines changed: 0 additions & 73 deletions
This file was deleted.

mlir/test/lib/Dialect/GPU/TestConvertGPUKernelToHsaco.cpp

Lines changed: 0 additions & 72 deletions
This file was deleted.

mlir/tools/mlir-opt/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,11 @@ llvm_update_compile_flags(mlir-opt)
9191

9292
mlir_check_all_link_libraries(mlir-opt)
9393
export_executable_symbols_for_plugins(mlir-opt)
94+
95+
if(MLIR_ENABLE_DEPRECATED_GPU_SERIALIZATION)
96+
# Enable deprecated serialization passes.
97+
target_compile_definitions(mlir-opt
98+
PRIVATE
99+
MLIR_DEPRECATED_GPU_SERIALIZATION_ENABLE=1
100+
)
101+
endif()

mlir/tools/mlir-opt/mlir-opt.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ void registerTestCallGraphPass();
8080
void registerTestCfAssertPass();
8181
void registerTestConstantFold();
8282
void registerTestControlFlowSink();
83-
void registerTestGpuSerializeToCubinPass();
84-
void registerTestGpuSerializeToHsacoPass();
8583
void registerTestDataLayoutPropagation();
8684
void registerTestDataLayoutQuery();
8785
void registerTestDeadCodeAnalysisPass();
@@ -204,11 +202,7 @@ void registerTestPasses() {
204202
mlir::test::registerTestDiagnosticsPass();
205203
mlir::test::registerTestDialectConversionPasses();
206204
#if MLIR_CUDA_CONVERSIONS_ENABLED
207-
mlir::test::registerTestGpuSerializeToCubinPass();
208205
mlir::test::registerTestLowerToNVVM();
209-
#endif
210-
#if MLIR_ROCM_CONVERSIONS_ENABLED
211-
mlir::test::registerTestGpuSerializeToHsacoPass();
212206
#endif
213207
mlir::test::registerTestDecomposeCallGraphTypes();
214208
mlir::test::registerTestDataLayoutPropagation();
@@ -270,6 +264,10 @@ void registerTestPasses() {
270264

271265
int main(int argc, char **argv) {
272266
registerAllPasses();
267+
#if MLIR_DEPRECATED_GPU_SERIALIZATION_ENABLE == 1
268+
registerGpuSerializeToCubinPass();
269+
registerGpuSerializeToHsacoPass();
270+
#endif
273271
#ifdef MLIR_INCLUDE_TESTS
274272
registerTestPasses();
275273
#endif

0 commit comments

Comments
 (0)