Skip to content

Commit 57b8be4

Browse files
authored
Revert [mlir][Target] Improve ROCDL gpu serialization API (#95790)
Reverts #95456
1 parent 4bf160e commit 57b8be4

File tree

4 files changed

+136
-193
lines changed

4 files changed

+136
-193
lines changed

mlir/include/mlir/Target/LLVM/ROCDL/Utils.h

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,6 @@ namespace ROCDL {
2727
/// 5. Returns an empty string.
2828
StringRef getROCMPath();
2929

30-
/// Helper enum for specifying the AMD GCN device libraries required for
31-
/// compilation.
32-
enum class AMDGCNLibraries : uint32_t {
33-
None = 0,
34-
Ockl = 1,
35-
Ocml = 2,
36-
OpenCL = 4,
37-
Hip = 8,
38-
LastLib = Hip,
39-
LLVM_MARK_AS_BITMASK_ENUM(LastLib),
40-
All = (LastLib << 1) - 1
41-
};
42-
4330
/// Base class for all ROCDL serializations from GPU modules into binary
4431
/// strings. By default this class serializes into LLVM bitcode.
4532
class SerializeGPUModuleBase : public LLVM::ModuleToObject {
@@ -62,8 +49,8 @@ class SerializeGPUModuleBase : public LLVM::ModuleToObject {
6249
/// Returns the bitcode files to be loaded.
6350
ArrayRef<std::string> getFileList() const;
6451

65-
/// Appends standard ROCm device libraries to `fileList`.
66-
LogicalResult appendStandardLibs(AMDGCNLibraries libs);
52+
/// Appends standard ROCm device libraries like `ocml.bc`, `ockl.bc`, etc.
53+
LogicalResult appendStandardLibs();
6754

6855
/// Loads the bitcode files in `fileList`.
6956
virtual std::optional<SmallVector<std::unique_ptr<llvm::Module>>>
@@ -76,20 +63,15 @@ class SerializeGPUModuleBase : public LLVM::ModuleToObject {
7663
LogicalResult handleBitcodeFile(llvm::Module &module) override;
7764

7865
protected:
79-
/// Adds `oclc` control variables to the LLVM module.
80-
void addControlVariables(llvm::Module &module, AMDGCNLibraries libs,
81-
bool wave64, bool daz, bool finiteOnly,
82-
bool unsafeMath, bool fastMath, bool correctSqrt,
83-
StringRef abiVer);
66+
/// Appends the paths of common ROCm device libraries to `libs`.
67+
LogicalResult getCommonBitcodeLibs(llvm::SmallVector<std::string> &libs,
68+
SmallVector<char, 256> &libPath,
69+
StringRef isaVersion);
8470

85-
/// Compiles assembly to a binary.
86-
virtual std::optional<SmallVector<char, 0>>
87-
compileToBinary(const std::string &serializedISA);
88-
89-
/// Default implementation of `ModuleToObject::moduleToObject`.
90-
std::optional<SmallVector<char, 0>>
91-
moduleToObjectImpl(const gpu::TargetOptions &targetOptions,
92-
llvm::Module &llvmModule);
71+
/// Adds `oclc` control variables to the LLVM module.
72+
void addControlVariables(llvm::Module &module, bool wave64, bool daz,
73+
bool finiteOnly, bool unsafeMath, bool fastMath,
74+
bool correctSqrt, StringRef abiVer);
9375

9476
/// Returns the assembled ISA.
9577
std::optional<SmallVector<char, 0>> assembleIsa(StringRef isa);
@@ -102,9 +84,6 @@ class SerializeGPUModuleBase : public LLVM::ModuleToObject {
10284

10385
/// List of LLVM bitcode files to link to.
10486
SmallVector<std::string> fileList;
105-
106-
/// AMD GCN libraries to use when linking, the default is using none.
107-
AMDGCNLibraries deviceLibs = AMDGCNLibraries::None;
10887
};
10988
} // namespace ROCDL
11089
} // namespace mlir

mlir/lib/Dialect/GPU/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ if(MLIR_ENABLE_ROCM_CONVERSIONS)
106106
"Building mlir with ROCm support requires the AMDGPU backend")
107107
endif()
108108

109-
set(DEFAULT_ROCM_PATH "" CACHE PATH "Fallback path to search for ROCm installs")
109+
set(DEFAULT_ROCM_PATH "/opt/rocm" CACHE PATH "Fallback path to search for ROCm installs")
110110
target_compile_definitions(obj.MLIRGPUTransforms
111111
PRIVATE
112112
__DEFAULT_ROCM_PATH__="${DEFAULT_ROCM_PATH}"

mlir/lib/Target/LLVM/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,17 @@ add_mlir_dialect_library(MLIRROCDLTarget
123123
)
124124

125125
if(MLIR_ENABLE_ROCM_CONVERSIONS)
126+
if (NOT ("AMDGPU" IN_LIST LLVM_TARGETS_TO_BUILD))
127+
message(SEND_ERROR
128+
"Building mlir with ROCm support requires the AMDGPU backend")
129+
endif()
130+
126131
if (DEFINED ROCM_PATH)
127132
set(DEFAULT_ROCM_PATH "${ROCM_PATH}" CACHE PATH "Fallback path to search for ROCm installs")
128133
elseif(DEFINED ENV{ROCM_PATH})
129134
set(DEFAULT_ROCM_PATH "$ENV{ROCM_PATH}" CACHE PATH "Fallback path to search for ROCm installs")
130135
else()
131-
set(DEFAULT_ROCM_PATH "" CACHE PATH "Fallback path to search for ROCm installs")
136+
set(DEFAULT_ROCM_PATH "/opt/rocm" CACHE PATH "Fallback path to search for ROCm installs")
132137
endif()
133138
message(VERBOSE "MLIR Default ROCM toolkit path: ${DEFAULT_ROCM_PATH}")
134139

0 commit comments

Comments
 (0)