[Mlir-commits] [mlir] 4398a22 - [mlir][target] Adjust the start and end position of the moduleToObject timer (#132693)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Mar 24 03:35:19 PDT 2025
Author: Zichen Lu
Date: 2025-03-24T11:35:14+01:00
New Revision: 4398a222ad0861ead5aeea66e76ac28757b6389d
URL: https://github.com/llvm/llvm-project/commit/4398a222ad0861ead5aeea66e76ac28757b6389d
DIFF: https://github.com/llvm/llvm-project/commit/4398a222ad0861ead5aeea66e76ac28757b6389d.diff
LOG: [mlir][target] Adjust the start and end position of the moduleToObject timer (#132693)
We hope that the timer can be cleared normally when the target-format is
`offload`, so as to avoid output like this:
```
===-------------------------------------------------------------------------===
Miscellaneous Ungrouped Timers
===-------------------------------------------------------------------------===
---Wall Time--- --- Name ---
----- Timer for perf llvm-ir -> isa and isa -> binary.
...
```
Co-authored-by: Guray Ozen <guray.ozen at gmail.com>
Added:
Modified:
mlir/lib/Target/LLVM/NVVM/Target.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Target/LLVM/NVVM/Target.cpp b/mlir/lib/Target/LLVM/NVVM/Target.cpp
index 5a2b829fbd1bd..cccb2c276ae37 100644
--- a/mlir/lib/Target/LLVM/NVVM/Target.cpp
+++ b/mlir/lib/Target/LLVM/NVVM/Target.cpp
@@ -672,7 +672,6 @@ NVPTXSerializer::moduleToObject(llvm::Module &llvmModule) {
llvm::Timer moduleToObjectTimer(
"moduleToObjectTimer",
"Timer for perf llvm-ir -> isa and isa -> binary.");
- moduleToObjectTimer.startTimer();
// Return LLVM IR if the compilation target is `offload`.
#define DEBUG_TYPE "serialize-to-llvm"
LLVM_DEBUG({
@@ -699,16 +698,17 @@ NVPTXSerializer::moduleToObject(llvm::Module &llvmModule) {
<< triple << ", can't optimize with LLVM\n";
return std::nullopt;
}
+ moduleToObjectTimer.startTimer();
std::optional<std::string> serializedISA =
translateToISA(llvmModule, **targetMachine);
+ moduleToObjectTimer.stopTimer();
+ llvmToISATimeInMs = moduleToObjectTimer.getTotalTime().getWallTime() * 1000;
+ moduleToObjectTimer.clear();
if (!serializedISA) {
getOperation().emitError() << "Failed translating the module to ISA.";
return std::nullopt;
}
- moduleToObjectTimer.stopTimer();
- llvmToISATimeInMs = moduleToObjectTimer.getTotalTime().getWallTime() * 1000;
- moduleToObjectTimer.clear();
if (isaCallback)
isaCallback(serializedISA.value());
More information about the Mlir-commits
mailing list