-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[MLIR] Adopt LDBG() macro in LLVM/NVVM/Target.cpp #154721
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
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
@llvm/pr-subscribers-mlir-llvm Author: Mehdi Amini (joker-eph) ChangesFull diff: https://github.com/llvm/llvm-project/pull/154721.diff 1 Files Affected:
diff --git a/mlir/lib/Target/LLVM/NVVM/Target.cpp b/mlir/lib/Target/LLVM/NVVM/Target.cpp
index 55c8a64de9ded..62eaadb3d16b1 100644
--- a/mlir/lib/Target/LLVM/NVVM/Target.cpp
+++ b/mlir/lib/Target/LLVM/NVVM/Target.cpp
@@ -24,9 +24,11 @@
#include "mlir/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.h"
#include "mlir/Target/LLVMIR/Dialect/NVVM/NVVMToLLVMIRTranslation.h"
#include "mlir/Target/LLVMIR/Export.h"
+#include "llvm/Support/InterleavedRange.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/Config/Targets.h"
+#include "llvm/Support/DebugLog.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/FormatVariadic.h"
@@ -452,17 +454,11 @@ NVPTXSerializer::compileToBinary(const std::string &ptxCode) {
// Dump tool invocation commands.
#define DEBUG_TYPE "serialize-to-binary"
- LLVM_DEBUG({
- llvm::dbgs() << "Tool invocation for module: "
- << getOperation().getNameAttr() << "\n";
- llvm::dbgs() << "ptxas executable:" << ptxasCompiler.value() << "\n";
- llvm::interleave(ptxasArgs, llvm::dbgs(), " ");
- llvm::dbgs() << "\n";
- if (createFatbin) {
- llvm::interleave(fatbinArgs, llvm::dbgs(), " ");
- llvm::dbgs() << "\n";
- }
- });
+ LDBG() << "Tool invocation for module: " << getOperation().getNameAttr()
+ << "\nptxas executable:" << ptxasCompiler.value()
+ << "\nptxas args: " << llvm::interleaved(ptxasArgs, " ");
+ if (createFatbin)
+ LDBG() << "fatbin args: " << llvm::interleaved(fatbinArgs, " ");
#undef DEBUG_TYPE
// Helper function for printing tool error logs.
@@ -507,7 +503,7 @@ NVPTXSerializer::compileToBinary(const std::string &ptxCode) {
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";
+ LDBG() << "Output:\n" << (*logBuffer)->getBuffer();
llvm::dbgs().flush();
}
});
@@ -529,7 +525,7 @@ NVPTXSerializer::compileToBinary(const std::string &ptxCode) {
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";
+ LDBG() << "Output:\n" << (*logBuffer)->getBuffer();
llvm::dbgs().flush();
}
});
@@ -629,12 +625,11 @@ NVPTXSerializer::compileToBinaryNVPTX(const std::string &ptxCode) {
SmallVector<char> log(logSize + 1, 0);
RETURN_ON_NVPTXCOMPILER_ERROR(
nvPTXCompilerGetInfoLog(compiler, log.data()));
- llvm::dbgs() << "NVPTX compiler invocation for module: "
- << getOperation().getNameAttr() << "\n";
- llvm::dbgs() << "Arguments: ";
- llvm::interleave(cmdOpts.second, llvm::dbgs(), " ");
- llvm::dbgs() << "\nOutput\n" << log.data() << "\n";
- llvm::dbgs().flush();
+ LDBG() << "NVPTX compiler invocation for module: "
+ << getOperation().getNameAttr()
+ << "\nArguments: " << llvm::interleaved(cmdOpts.second, " ")
+ << "\nOutput\n"
+ << log.data();
}
});
#undef DEBUG_TYPE
@@ -678,10 +673,8 @@ NVPTXSerializer::moduleToObject(llvm::Module &llvmModule) {
// Return LLVM IR if the compilation target is `offload`.
#define DEBUG_TYPE "serialize-to-llvm"
LLVM_DEBUG({
- llvm::dbgs() << "LLVM IR for module: " << getOperation().getNameAttr()
- << "\n";
- llvm::dbgs() << llvmModule << "\n";
- llvm::dbgs().flush();
+ LDBG() << "LLVM IR for module: " << getOperation().getNameAttr();
+ LDBG() << llvmModule;
});
#undef DEBUG_TYPE
if (targetOptions.getCompilationTarget() == gpu::CompilationTarget::Offload)
@@ -716,11 +709,8 @@ NVPTXSerializer::moduleToObject(llvm::Module &llvmModule) {
isaCallback(serializedISA.value());
#define DEBUG_TYPE "serialize-to-isa"
- LLVM_DEBUG({
- llvm::dbgs() << "PTX for module: " << getOperation().getNameAttr() << "\n";
- llvm::dbgs() << *serializedISA << "\n";
- llvm::dbgs().flush();
- });
+ LDBG() << "PTX for module: " << getOperation().getNameAttr() << "\n"
+ << *serializedISA;
#undef DEBUG_TYPE
// Return PTX if the compilation target is `assembly`.
|
@llvm/pr-subscribers-mlir Author: Mehdi Amini (joker-eph) ChangesFull diff: https://github.com/llvm/llvm-project/pull/154721.diff 1 Files Affected:
diff --git a/mlir/lib/Target/LLVM/NVVM/Target.cpp b/mlir/lib/Target/LLVM/NVVM/Target.cpp
index 55c8a64de9ded..62eaadb3d16b1 100644
--- a/mlir/lib/Target/LLVM/NVVM/Target.cpp
+++ b/mlir/lib/Target/LLVM/NVVM/Target.cpp
@@ -24,9 +24,11 @@
#include "mlir/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.h"
#include "mlir/Target/LLVMIR/Dialect/NVVM/NVVMToLLVMIRTranslation.h"
#include "mlir/Target/LLVMIR/Export.h"
+#include "llvm/Support/InterleavedRange.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/Config/Targets.h"
+#include "llvm/Support/DebugLog.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/FormatVariadic.h"
@@ -452,17 +454,11 @@ NVPTXSerializer::compileToBinary(const std::string &ptxCode) {
// Dump tool invocation commands.
#define DEBUG_TYPE "serialize-to-binary"
- LLVM_DEBUG({
- llvm::dbgs() << "Tool invocation for module: "
- << getOperation().getNameAttr() << "\n";
- llvm::dbgs() << "ptxas executable:" << ptxasCompiler.value() << "\n";
- llvm::interleave(ptxasArgs, llvm::dbgs(), " ");
- llvm::dbgs() << "\n";
- if (createFatbin) {
- llvm::interleave(fatbinArgs, llvm::dbgs(), " ");
- llvm::dbgs() << "\n";
- }
- });
+ LDBG() << "Tool invocation for module: " << getOperation().getNameAttr()
+ << "\nptxas executable:" << ptxasCompiler.value()
+ << "\nptxas args: " << llvm::interleaved(ptxasArgs, " ");
+ if (createFatbin)
+ LDBG() << "fatbin args: " << llvm::interleaved(fatbinArgs, " ");
#undef DEBUG_TYPE
// Helper function for printing tool error logs.
@@ -507,7 +503,7 @@ NVPTXSerializer::compileToBinary(const std::string &ptxCode) {
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";
+ LDBG() << "Output:\n" << (*logBuffer)->getBuffer();
llvm::dbgs().flush();
}
});
@@ -529,7 +525,7 @@ NVPTXSerializer::compileToBinary(const std::string &ptxCode) {
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";
+ LDBG() << "Output:\n" << (*logBuffer)->getBuffer();
llvm::dbgs().flush();
}
});
@@ -629,12 +625,11 @@ NVPTXSerializer::compileToBinaryNVPTX(const std::string &ptxCode) {
SmallVector<char> log(logSize + 1, 0);
RETURN_ON_NVPTXCOMPILER_ERROR(
nvPTXCompilerGetInfoLog(compiler, log.data()));
- llvm::dbgs() << "NVPTX compiler invocation for module: "
- << getOperation().getNameAttr() << "\n";
- llvm::dbgs() << "Arguments: ";
- llvm::interleave(cmdOpts.second, llvm::dbgs(), " ");
- llvm::dbgs() << "\nOutput\n" << log.data() << "\n";
- llvm::dbgs().flush();
+ LDBG() << "NVPTX compiler invocation for module: "
+ << getOperation().getNameAttr()
+ << "\nArguments: " << llvm::interleaved(cmdOpts.second, " ")
+ << "\nOutput\n"
+ << log.data();
}
});
#undef DEBUG_TYPE
@@ -678,10 +673,8 @@ NVPTXSerializer::moduleToObject(llvm::Module &llvmModule) {
// Return LLVM IR if the compilation target is `offload`.
#define DEBUG_TYPE "serialize-to-llvm"
LLVM_DEBUG({
- llvm::dbgs() << "LLVM IR for module: " << getOperation().getNameAttr()
- << "\n";
- llvm::dbgs() << llvmModule << "\n";
- llvm::dbgs().flush();
+ LDBG() << "LLVM IR for module: " << getOperation().getNameAttr();
+ LDBG() << llvmModule;
});
#undef DEBUG_TYPE
if (targetOptions.getCompilationTarget() == gpu::CompilationTarget::Offload)
@@ -716,11 +709,8 @@ NVPTXSerializer::moduleToObject(llvm::Module &llvmModule) {
isaCallback(serializedISA.value());
#define DEBUG_TYPE "serialize-to-isa"
- LLVM_DEBUG({
- llvm::dbgs() << "PTX for module: " << getOperation().getNameAttr() << "\n";
- llvm::dbgs() << *serializedISA << "\n";
- llvm::dbgs().flush();
- });
+ LDBG() << "PTX for module: " << getOperation().getNameAttr() << "\n"
+ << *serializedISA;
#undef DEBUG_TYPE
// Return PTX if the compilation target is `assembly`.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
No description provided.