diff --git a/mlir/include/mlir/Dialect/GPU/Passes.h b/mlir/include/mlir/Dialect/GPU/Passes.h index c9b396edfdeb..c9c6f8668b4d 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 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 6ae466200608..8dadb630f4a9 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 + +#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> blob = serializeISA(targetISA); if (!blob) diff --git a/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp b/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp index 75d14d2bb93e..d9209b9012dd 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 mlir::createGpuSerializeToHsacoPass(StringRef triple, + StringRef arch, + StringRef features, + int optLevel) { + return std::make_unique(triple, arch, features, + optLevel); +} + #else // MLIR_GPU_TO_HSACO_PASS_ENABLE void mlir::registerGpuSerializeToHsacoPass() {} #endif // MLIR_GPU_TO_HSACO_PASS_ENABLE