-
Notifications
You must be signed in to change notification settings - Fork 348
Timing tool that adds the flag “--enable-timing" for a detailed report #2801
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
Conversation
Can one of the admins verify this patch? |
@jenkins-droid test this please |
Can one of the admins verify this patch? |
…art a detailed timing report for the entire onnx-mlir execution process, including setup in main() in onnx-mlir.cpp, input file processing before compilation, the passes run in the pass manager, and finally, the lower level compilation/generation stages (LLVM, Object, Shared Library, JNI). This tool will print the detailed execution report as a tree of all the timed stages to the terminal with the (wall time) and (relative percentage of program execution) for each timed stage and the total execution time of the onnx-mlir compiler. I used the DefaultTimingManager from llvm-project “timing.cpp” and timing scopes to time and name essential code sections where work is being done. Signed-off-by: Paramvir Sran <[email protected]>
Can one of the admins verify this patch? |
7480da9
to
b6d7fb0
Compare
Can one of the admins verify this patch? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great feature! Thank you very much for working on this!
Just some comments. They are mainly about changing text messages. Please fix DCO also so that it can be merged.
CMakeLists.txt
Outdated
@@ -7,7 +7,7 @@ project(onnx-mlir) | |||
|
|||
option(ONNX_MLIR_BUILD_TESTS "Build ONNX-MLIR test executables. If OFF, just generate build targets." ON) | |||
option(ONNX_MLIR_CCACHE_BUILD "Set to ON for a ccache enabled build." OFF) | |||
option(ONNX_MLIR_ENABLE_STABLEHLO "Enable StableHLO support." ON) | |||
option(ONNX_MLIR_ENABLE_STABLEHLO "Enable StableHLO support." OFF) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the final commit, please change this back to ON.
"terminal.integrated.defaultProfile.linux": "bash", | ||
"cmake.mergedCompileCommands": "${workspaceFolder}/compile_commands.json", | ||
"cmakeExplorer.suiteDelimiter": ".", | ||
"cmakeExplorer.debugConfig": "(gdb) Launch", | ||
"editor.formatOnSave": true, | ||
"[cpp]": { | ||
"editor.defaultFormatter": "xaver.clang-format", | ||
"editor.tabSize": 2 | ||
"editor.tabSize":2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this space redundant? It looks like an accidental change.
src/Compiler/CompilerOptions.cpp
Outdated
@@ -546,6 +547,12 @@ static llvm::cl::opt<OptReport, true> optReportOpt("opt-report", | |||
clEnumVal(Simd, "Provide report on how SIMD is applied to ONNX ops.")), | |||
llvm::cl::init(OptReport::NoReport), llvm::cl::cat(OnnxMlirOptions)); | |||
|
|||
static llvm::cl::opt<bool, true> enable_timing("enable-timing", | |||
llvm::cl::desc("Enable pass timing (default is false)\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe Enable compile timing
is easier to understand.
src/Compiler/CompilerOptions.cpp
Outdated
@@ -579,6 +586,7 @@ static llvm::cl::opt<bool, true> useOldBufferizationOpt("use-old-bufferization", | |||
llvm::cl::location(useOldBufferization), llvm::cl::init(true), | |||
llvm::cl::cat(OnnxMlirOptions)); | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this redundant line.
src/Compiler/CompilerUtils.cpp
Outdated
#include "llvm/Target/TargetMachine.h" | ||
#include <fstream> | ||
#include <memory> | ||
#include <regex> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you include these three lines first? They are from C++, and we often include them first before mlir stuffs.
src/onnx-mlir.cpp
Outdated
initCompilerConfig(); | ||
|
||
// timing manager reporting enabled via "--enable-timing" compiler flag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typos: timing
=> Timing
src/onnx-mlir.cpp
Outdated
initCompilerConfig(); | ||
|
||
// timing manager reporting enabled via "--enable-timing" compiler flag | ||
// mlir::applyDefaultTimingManagerCLOptions(timingManager); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be removed?
src/onnx-mlir.cpp
Outdated
// mlir::applyDefaultTimingManagerCLOptions(timingManager); | ||
timingManager.setEnabled(enableTiming); | ||
rootScope = timingManager.getRootScope(); | ||
auto setupScope = rootScope.nest("[onnx-mlir] Preparing for Compilation"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setupScope
=> setupTiming
.
Perhaps, change the message to [onnx-mlir] Loading Dialects
src/onnx-mlir.cpp
Outdated
@@ -71,7 +74,8 @@ int main(int argc, char *argv[]) { | |||
LLVM_DEBUG(llvm::dbgs() << "multithreading is disabled\n"); | |||
} | |||
loadDialects(context); | |||
|
|||
setupScope.stop(); | |||
auto inputFileScope = rootScope.nest("[onnx-mlir] Processing of Input File"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inputFileScope
=> inputFileTiming
I think [onnx-mlir] Importing Input Model to MLIR
is easier to understand.
timing.diff
Outdated
@@ -0,0 +1,143 @@ | |||
diff --git a/src/Compiler/CompilerUtils.cpp b/src/Compiler/CompilerUtils.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this file.
@ParamvirSran follow the instruction here to fix DCO: https://github.com/onnx/onnx-mlir/pull/2801/checks?check_run_id=24080750134. For Clang Format, you can run |
Signed-off-by: Paramvir Sran <[email protected]>
b6d7fb0
to
c7f84b1
Compare
Can one of the admins verify this patch? |
@jenkins-droid test this please |
Signed-off-by: Paramvir Sran <[email protected]>
Can one of the admins verify this patch? |
Signed-off-by: Paramvir Sran <[email protected]>
Can one of the admins verify this patch? |
@jenkins-droid test this please |
Signed-off-by: Paramvir Sran <[email protected]>
Can one of the admins verify this patch? |
@jenkins-droid test this please |
src/Compiler/CompilerUtils.cpp
Outdated
@@ -146,8 +153,7 @@ int Command::exec(std::string wdir) const { | |||
llvm::errs() << llvm::join(argsRef, " ") << "\n" | |||
<< "Error message: " << errMsg << "\n" | |||
<< "Program path: " << _path << "\n" | |||
<< "Command execution failed." | |||
<< "\n"; | |||
<< "Command execution failed." << "\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this change, it caused clang-format failed.
src/Compiler/CompilerUtils.cpp
Outdated
@@ -568,8 +578,7 @@ static int compileModuleToJniJar( | |||
#define NOEXECSTACK \ | |||
{} | |||
#else | |||
#define NOEXECSTACK \ | |||
{ "-z", "noexecstack" } | |||
#define NOEXECSTACK {"-z", "noexecstack"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this change, it caused clang-format failed.
auto ElementsAttrBuilder::getElementsProperties(ElementsAttr elements) | ||
-> ElementsProperties { | ||
auto ElementsAttrBuilder::getElementsProperties( | ||
ElementsAttr elements) -> ElementsProperties { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this change, it caused clang-format failed.
src/Compiler/CompilerUtils.cpp
Outdated
@@ -49,6 +53,9 @@ | |||
using namespace mlir; | |||
using namespace onnx_mlir; | |||
|
|||
mlir::DefaultTimingManager timingManager; | |||
mlir::TimingScope rootScope; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change rootScope
to rootTimingScope
.
Signed-off-by: Paramvir Sran <[email protected]>
Can one of the admins verify this patch? |
Signed-off-by: Paramvir Sran <[email protected]>
Can one of the admins verify this patch? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for adding this useful option!
Signed-off-by: Paramvir Sran <[email protected]>
Can one of the admins verify this patch? |
Signed-off-by: Paramvir Sran <[email protected]>
Can one of the admins verify this patch? |
@jenkins-droid test this please |
Jenkins Linux s390x Build #14756 [push] Timing tool that adds th... started at 01:06 |
Jenkins Linux ppc64le Build #13751 [push] Timing tool that adds th... started at 01:17 |
Jenkins Linux amd64 Build #14726 [push] Timing tool that adds th... started at 00:06 |
Jenkins Linux amd64 Build #14726 [push] Timing tool that adds th... passed after 1 hr 11 min |
Jenkins Linux s390x Build #14756 [push] Timing tool that adds th... passed after 1 hr 23 min |
Jenkins Linux ppc64le Build #13751 [push] Timing tool that adds th... passed after 1 hr 59 min |
Detailed timing report printed to the terminal for the entire onnx-mlir execution process, including setup in main() in onnx-mlir.cpp, input file processing before compilation, the passes run in the pass manager, and finally, the lower level compilation/generation stages (LLVM, Object, Shared Library, JNI). This tool will print the detailed execution report as a tree of all the timed stages to the terminal with the (wall time) and (relative percentage of program execution) for each timed stage and the total execution time of the onnx-mlir compiler. I used the DefaultTimingManager from llvm-project “timing.cpp” and timing scopes to time and name essential code sections where work is being done.
Example:
