[Mlir-commits] [mlir] 40aef79 - [MLIR][GPU] Add debug output to enable dumping GPU assembly
Krzysztof Drewniak
llvmlistbot at llvm.org
Thu Jan 20 12:52:21 PST 2022
Author: Krzysztof Drewniak
Date: 2022-01-20T20:52:12Z
New Revision: 40aef79db0b02b171a65b3a13053ae963a3e8753
URL: https://github.com/llvm/llvm-project/commit/40aef79db0b02b171a65b3a13053ae963a3e8753
DIFF: https://github.com/llvm/llvm-project/commit/40aef79db0b02b171a65b3a13053ae963a3e8753.diff
LOG: [MLIR][GPU] Add debug output to enable dumping GPU assembly
- Set the DEBUG_TYPE of SerializeToBlob to serialize-to-blob
- Add debug output to print the assembly or PTX for GPU modules before
they are assembled and linked
Note that, as SerializeToBlob is a superclass of SerializeToCubin and
SerializeToHsaco, --debug-only=serialize-to-blom will dump the
intermediate compiler result for both of these passes.
In addition, if LLVM options such as --stop-after are used to control
the GPU kernel compilation process, the debug output will contain the
appropriate intermediate IR.
Reviewed By: herhut
Differential Revision: https://reviews.llvm.org/D117519
Added:
Modified:
mlir/include/mlir/Dialect/GPU/Passes.h
mlir/lib/Dialect/GPU/Transforms/SerializeToBlob.cpp
mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/GPU/Passes.h b/mlir/include/mlir/Dialect/GPU/Passes.h
index c9b396edfdeb0..c9c6f8668b4d3 100644
--- a/mlir/include/mlir/Dialect/GPU/Passes.h
+++ b/mlir/include/mlir/Dialect/GPU/Passes.h
@@ -102,6 +102,13 @@ void registerGpuSerializeToCubinPass();
/// annotation.
void registerGpuSerializeToHsacoPass();
+/// Create an instance of the GPU kernel function to HSAco binary serialization
+/// pass.
+std::unique_ptr<Pass> createGpuSerializeToHsacoPass(StringRef triple,
+ StringRef arch,
+ StringRef features,
+ int optLevel);
+
/// Generate the code for registering passes.
#define GEN_PASS_REGISTRATION
#include "mlir/Dialect/GPU/Passes.h.inc"
diff --git a/mlir/lib/Dialect/GPU/Transforms/SerializeToBlob.cpp b/mlir/lib/Dialect/GPU/Transforms/SerializeToBlob.cpp
index 6ae4662006089..8dadb630f4a94 100644
--- a/mlir/lib/Dialect/GPU/Transforms/SerializeToBlob.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/SerializeToBlob.cpp
@@ -21,6 +21,10 @@
#include "llvm/Support/TargetSelect.h"
#include "llvm/Target/TargetMachine.h"
+#include <string>
+
+#define DEBUG_TYPE "serialize-to-blob"
+
using namespace mlir;
std::string gpu::getDefaultGpuBinaryAnnotation() { return "gpu.binary"; }
@@ -76,6 +80,12 @@ void gpu::SerializeToBlobPass::runOnOperation() {
std::string targetISA = std::move(maybeTargetISA.getValue());
+ LLVM_DEBUG({
+ llvm::dbgs() << "ISA for module: " << getOperation().getNameAttr() << "\n";
+ llvm::dbgs() << targetISA << "\n";
+ llvm::dbgs().flush();
+ });
+
// Serialize the target ISA.
std::unique_ptr<std::vector<char>> blob = serializeISA(targetISA);
if (!blob)
diff --git a/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp b/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
index 75d14d2bb93ea..d9209b9012dd5 100644
--- a/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
@@ -479,6 +479,17 @@ void mlir::registerGpuSerializeToHsacoPass() {
"", 2);
});
}
+
+/// Create an instance of the GPU kernel function to HSAco binary serialization
+/// pass.
+std::unique_ptr<Pass> mlir::createGpuSerializeToHsacoPass(StringRef triple,
+ StringRef arch,
+ StringRef features,
+ int optLevel) {
+ return std::make_unique<SerializeToHsacoPass>(triple, arch, features,
+ optLevel);
+}
+
#else // MLIR_GPU_TO_HSACO_PASS_ENABLE
void mlir::registerGpuSerializeToHsacoPass() {}
#endif // MLIR_GPU_TO_HSACO_PASS_ENABLE
More information about the Mlir-commits
mailing list