Skip to content

Commit 4398a22

Browse files
MikaOvOgrypp
andauthored
[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 <[email protected]>
1 parent e2e776c commit 4398a22

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mlir/lib/Target/LLVM/NVVM/Target.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,6 @@ NVPTXSerializer::moduleToObject(llvm::Module &llvmModule) {
672672
llvm::Timer moduleToObjectTimer(
673673
"moduleToObjectTimer",
674674
"Timer for perf llvm-ir -> isa and isa -> binary.");
675-
moduleToObjectTimer.startTimer();
676675
// Return LLVM IR if the compilation target is `offload`.
677676
#define DEBUG_TYPE "serialize-to-llvm"
678677
LLVM_DEBUG({
@@ -699,16 +698,17 @@ NVPTXSerializer::moduleToObject(llvm::Module &llvmModule) {
699698
<< triple << ", can't optimize with LLVM\n";
700699
return std::nullopt;
701700
}
701+
moduleToObjectTimer.startTimer();
702702
std::optional<std::string> serializedISA =
703703
translateToISA(llvmModule, **targetMachine);
704+
moduleToObjectTimer.stopTimer();
705+
llvmToISATimeInMs = moduleToObjectTimer.getTotalTime().getWallTime() * 1000;
706+
moduleToObjectTimer.clear();
704707
if (!serializedISA) {
705708
getOperation().emitError() << "Failed translating the module to ISA.";
706709
return std::nullopt;
707710
}
708711

709-
moduleToObjectTimer.stopTimer();
710-
llvmToISATimeInMs = moduleToObjectTimer.getTotalTime().getWallTime() * 1000;
711-
moduleToObjectTimer.clear();
712712
if (isaCallback)
713713
isaCallback(serializedISA.value());
714714

0 commit comments

Comments
 (0)