Skip to content

Commit 9ddf3b8

Browse files
authored
[mlir][gpu] Remove old GPU serialization passes (#94998)
This patch removes the last vestiges of the old gpu serialization pipeline. To compile GPU code use target attributes instead. See [Compilation overview | 'gpu' Dialect - MLIR docs](https://mlir.llvm.org/docs/Dialects/GPU/#compilation-overview) for additional information on the target attributes compilation pipeline that replaced the old serialization pipeline.
1 parent 4abbf99 commit 9ddf3b8

File tree

9 files changed

+1
-731
lines changed

9 files changed

+1
-731
lines changed

mlir/docs/Dialects/GPU.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ complex lifetime analysis following the principles of MLIR that promote
3737
structure and representing analysis results in the IR.
3838

3939
## GPU Compilation
40-
### Deprecation notice
41-
The `--gpu-to-(cubin|hsaco)` passes will be deprecated in a future release.
42-
4340
### Compilation overview
4441
The compilation process in the GPU dialect has two main stages: GPU module
4542
serialization and offloading operations translation. Together these stages can

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
#ifndef MLIR_CONFIG_H
2121
#define MLIR_CONFIG_H
2222

23-
/* If set, enable deprecated serialization passes. */
24-
#cmakedefine01 MLIR_DEPRECATED_GPU_SERIALIZATION_ENABLE
25-
2623
/* Enable expensive checks to detect invalid pattern API usage. Failed checks
2724
manifest as fatal errors or invalid memory accesses (e.g., accessing
2825
deallocated memory) that cause a crash. Running with ASAN is recommended for

mlir/include/mlir/Conversion/Passes.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ def GpuToLLVMConversionPass : Pass<"gpu-to-llvm", "ModuleOp"> {
478478
/*default=*/"false",
479479
"Use bare pointers to pass memref arguments to kernels. "
480480
"The kernel must use the same setting for this option."
481-
>
481+
>
482482
];
483483

484484
let dependentDialects = [

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

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -91,75 +91,12 @@ namespace gpu {
9191
LogicalResult transformGpuModulesToBinaries(
9292
Operation *op, OffloadingLLVMTranslationAttrInterface handler = nullptr,
9393
const gpu::TargetOptions &options = {});
94-
95-
/// Base pass class to serialize kernel functions through LLVM into
96-
/// user-specified IR and add the resulting blob as module attribute.
97-
class SerializeToBlobPass : public OperationPass<gpu::GPUModuleOp> {
98-
public:
99-
SerializeToBlobPass(TypeID passID);
100-
SerializeToBlobPass(const SerializeToBlobPass &other);
101-
102-
void runOnOperation() final;
103-
104-
protected:
105-
/// Hook allowing the application of optimizations before codegen
106-
/// By default, does nothing
107-
virtual LogicalResult optimizeLlvm(llvm::Module &llvmModule,
108-
llvm::TargetMachine &targetMachine);
109-
110-
/// Translates the 'getOperation()' result to an LLVM module.
111-
virtual std::unique_ptr<llvm::Module>
112-
translateToLLVMIR(llvm::LLVMContext &llvmContext);
113-
114-
private:
115-
/// Creates the LLVM target machine to generate the ISA.
116-
std::unique_ptr<llvm::TargetMachine> createTargetMachine();
117-
118-
/// Translates the module to ISA
119-
std::optional<std::string> translateToISA(llvm::Module &llvmModule,
120-
llvm::TargetMachine &targetMachine);
121-
122-
/// Serializes the target ISA to binary form.
123-
virtual std::unique_ptr<std::vector<char>>
124-
serializeISA(const std::string &isa) = 0;
125-
126-
protected:
127-
Option<std::string> triple{*this, "triple",
128-
::llvm::cl::desc("Target triple")};
129-
Option<std::string> chip{*this, "chip",
130-
::llvm::cl::desc("Target architecture")};
131-
Option<std::string> features{*this, "features",
132-
::llvm::cl::desc("Target features")};
133-
Option<int> optLevel{*this, "opt-level",
134-
llvm::cl::desc("Optimization level for compilation"),
135-
llvm::cl::init(2)};
136-
Option<std::string> gpuBinaryAnnotation{
137-
*this, "gpu-binary-annotation",
138-
llvm::cl::desc("Annotation attribute string for GPU binary"),
139-
llvm::cl::init(getDefaultGpuBinaryAnnotation())};
140-
Option<bool> dumpPtx{*this, "dump-ptx",
141-
::llvm::cl::desc("Dump generated PTX"),
142-
llvm::cl::init(false)};
143-
};
14494
} // namespace gpu
14595

14696
//===----------------------------------------------------------------------===//
14797
// Registration
14898
//===----------------------------------------------------------------------===//
14999

150-
/// Register pass to serialize GPU kernel functions to a HSAco binary
151-
/// annotation.
152-
LLVM_DEPRECATED("use Target attributes instead", "")
153-
void registerGpuSerializeToHsacoPass();
154-
155-
/// Create an instance of the GPU kernel function to HSAco binary serialization
156-
/// pass.
157-
LLVM_DEPRECATED("use Target attributes instead", "")
158-
std::unique_ptr<Pass> createGpuSerializeToHsacoPass(StringRef triple,
159-
StringRef arch,
160-
StringRef features,
161-
int optLevel);
162-
163100
/// Collect a set of patterns to decompose memrefs ops.
164101
void populateGpuDecomposeMemrefsPatterns(RewritePatternSet &patterns);
165102

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ namespace gpu {
2828
class GPUFuncOp;
2929
class LaunchOp;
3030

31-
/// Returns the default annotation name for GPU binary blobs.
32-
std::string getDefaultGpuBinaryAnnotation();
33-
3431
/// Returns the matching vector combining kind.
3532
vector::CombiningKind convertReductionKind(gpu::AllReduceOperation mode);
3633
} // namespace gpu

mlir/lib/Dialect/GPU/CMakeLists.txt

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
if (MLIR_ENABLE_ROCM_CONVERSIONS)
2-
set(AMDGPU_LIBS
3-
IRReader
4-
IPO
5-
linker
6-
MCParser
7-
AMDGPUAsmParser
8-
AMDGPUCodeGen
9-
AMDGPUDesc
10-
AMDGPUInfo
11-
target
12-
)
13-
endif()
14-
151
add_mlir_dialect_library(MLIRGPUDialect
162
IR/GPUDialect.cpp
173
IR/InferIntRangeInterfaceImpls.cpp
@@ -51,8 +37,6 @@ add_mlir_dialect_library(MLIRGPUTransforms
5137
Transforms/NVVMAttachTarget.cpp
5238
Transforms/ParallelLoopMapper.cpp
5339
Transforms/ROCDLAttachTarget.cpp
54-
Transforms/SerializeToBlob.cpp
55-
Transforms/SerializeToHsaco.cpp
5640
Transforms/ShuffleRewriter.cpp
5741
Transforms/SPIRVAttachTarget.cpp
5842
Transforms/SubgroupReduceLowering.cpp
@@ -63,12 +47,6 @@ add_mlir_dialect_library(MLIRGPUTransforms
6347
ADDITIONAL_HEADER_DIRS
6448
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/GPU
6549

66-
LINK_COMPONENTS
67-
Core
68-
MC
69-
Target
70-
${AMDGPU_LIBS}
71-
7250
DEPENDS
7351
MLIRGPUPassIncGen
7452
MLIRParallelLoopMapperEnumsGen
@@ -78,15 +56,12 @@ add_mlir_dialect_library(MLIRGPUTransforms
7856
MLIRArithDialect
7957
MLIRAsyncDialect
8058
MLIRBufferizationDialect
81-
MLIRBuiltinToLLVMIRTranslation
8259
MLIRDataLayoutInterfaces
8360
MLIRExecutionEngineUtils
8461
MLIRGPUDialect
8562
MLIRIR
8663
MLIRIndexDialect
8764
MLIRLLVMDialect
88-
MLIRGPUToLLVMIRTranslation
89-
MLIRLLVMToLLVMIRTranslation
9065
MLIRMemRefDialect
9166
MLIRNVVMTarget
9267
MLIRPass
@@ -101,21 +76,3 @@ add_mlir_dialect_library(MLIRGPUTransforms
10176

10277
add_subdirectory(TransformOps)
10378
add_subdirectory(Pipelines)
104-
105-
if(MLIR_ENABLE_ROCM_CONVERSIONS)
106-
if (NOT ("AMDGPU" IN_LIST LLVM_TARGETS_TO_BUILD))
107-
message(SEND_ERROR
108-
"Building mlir with ROCm support requires the AMDGPU backend")
109-
endif()
110-
111-
set(DEFAULT_ROCM_PATH "/opt/rocm" CACHE PATH "Fallback path to search for ROCm installs")
112-
target_compile_definitions(obj.MLIRGPUTransforms
113-
PRIVATE
114-
__DEFAULT_ROCM_PATH__="${DEFAULT_ROCM_PATH}"
115-
)
116-
117-
target_link_libraries(MLIRGPUTransforms
118-
PRIVATE
119-
MLIRROCDLToLLVMIRTranslation
120-
)
121-
endif()

mlir/lib/Dialect/GPU/Transforms/SerializeToBlob.cpp

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

0 commit comments

Comments
 (0)