-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MLIR] Dump sass #110227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[MLIR] Dump sass #110227
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR dump sass by using nvdiasm
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-llvm Author: Guray Ozen (grypp) ChangesThis PR dump sass by using nvdiasm Full diff: https://github.com/llvm/llvm-project/pull/110227.diff 2 Files Affected:
diff --git a/mlir/lib/Target/LLVM/NVVM/Target.cpp b/mlir/lib/Target/LLVM/NVVM/Target.cpp
index 806c405ac17dfa..591074a436c4e0 100644
--- a/mlir/lib/Target/LLVM/NVVM/Target.cpp
+++ b/mlir/lib/Target/LLVM/NVVM/Target.cpp
@@ -30,6 +30,7 @@
#include "llvm/Support/Process.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/raw_ostream.h"
#include <cstdlib>
@@ -92,6 +93,7 @@ SerializeGPUModuleBase::SerializeGPUModuleBase(
// If `targetOptions` have an empty toolkitPath use `getCUDAToolkitPath`
if (toolkitPath.empty())
toolkitPath = getCUDAToolkitPath();
+ llvm::errs() << toolkitPath;
// Append the files in the target attribute.
if (ArrayAttr files = target.getLink())
@@ -401,6 +403,26 @@ NVPTXSerializer::compileToBinary(const std::string &ptxCode) {
/*MemoryLimit=*/0,
/*ErrMsg=*/&message))
return emitLogError("`ptxas`");
+#define DEBUG_TYPE "dump-sass"
+ LLVM_DEBUG({
+ std::optional<std::string> nvdisasm = findTool("nvdisasm");
+ SmallVector<StringRef> nvdisasmArgs(
+ {StringRef("nvdisasm"), StringRef(cubinFile.first)});
+ if (llvm::sys::ExecuteAndWait(nvdisasm.value(), nvdisasmArgs,
+ /*Env=*/std::nullopt,
+ /*Redirects=*/redirects,
+ /*SecondsToWait=*/0,
+ /*MemoryLimit=*/0,
+ /*ErrMsg=*/&message))
+ return emitLogError("`nvdisasm`");
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> logBuffer =
+ llvm::MemoryBuffer::getFile(logFile->first);
+ if (logBuffer && !(*logBuffer)->getBuffer().empty()) {
+ llvm::dbgs() << "Output:\n" << (*logBuffer)->getBuffer() << "\n";
+ llvm::dbgs().flush();
+ }
+ });
+#undef DEBUG_TYPE
// Invoke `fatbin`.
message.clear();
@@ -532,8 +554,8 @@ NVPTXSerializer::moduleToObject(llvm::Module &llvmModule) {
return SerializeGPUModuleBase::moduleToObject(llvmModule);
#if !LLVM_HAS_NVPTX_TARGET
- getOperation()->emitError(
- "The `NVPTX` target was not built. Please enable it when building LLVM.");
+ getOperation()->emitError("The `NVPTX` target was not built. Please enable "
+ "it when building LLVM.");
return std::nullopt;
#endif // LLVM_HAS_NVPTX_TARGET
diff --git a/mlir/test/Integration/Dialect/SparseTensor/GPU/CUDA/dump-ptx.mlir b/mlir/test/Integration/Dialect/SparseTensor/GPU/CUDA/dump-ptx.mlir
index 0cc5d8645bb364..2f7e00e927eca8 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/GPU/CUDA/dump-ptx.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/GPU/CUDA/dump-ptx.mlir
@@ -1,5 +1,5 @@
// RUN: mlir-opt %s \
-// RUN: | mlir-opt -gpu-lower-to-nvvm-pipeline -debug-only=serialize-to-isa \
+// RUN: | mlir-opt -gpu-lower-to-nvvm-pipeline -debug-only=serialize-to-isa -debug-only=dump-sass \
// RUN: 2>&1 | FileCheck %s
// CHECK: Generated by LLVM NVPTX Back-End
|
joker-eph
approved these changes
Sep 27, 2024
mlir/test/Integration/Dialect/SparseTensor/GPU/CUDA/dump-ptx.mlir
Outdated
Show resolved
Hide resolved
joker-eph
approved these changes
Sep 27, 2024
mlir/test/Integration/Dialect/SparseTensor/GPU/CUDA/dump-ptx.mlir
Outdated
Show resolved
Hide resolved
Sterling-Augustine
pushed a commit
to Sterling-Augustine/llvm-project
that referenced
this pull request
Sep 27, 2024
This PR dump sass by using nvdiasm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR dump sass by using nvdiasm