This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Add simple runner utilities for timing
ClosedPublic

Authored by bondhugula on Mar 27 2020, 2:49 AM.

Details

Summary

Add utilities print_flops, rtclock for timing / benchmarking. Add
mlir_runner_utils_dir test conf variable.

Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>

Diff Detail

Event Timeline

bondhugula created this revision.Mar 27 2020, 2:49 AM

Fix casing for timeval

ftynse requested changes to this revision.Mar 27 2020, 7:30 AM
ftynse added a subscriber: ftynse.
ftynse added inline comments.
mlir/lib/ExecutionEngine/RunnerUtils.cpp
17

We need some conditional compilation mechanism here, MLIR needs to be buildable on other systems than Linux.

This revision now requires changes to proceed.Mar 27 2020, 7:30 AM

Address review comment - conditional compile excluding WIN32

bondhugula marked an inline comment as done.Mar 27 2020, 8:15 AM

Thanks for noticing. PTAL.

ftynse added inline comments.Mar 27 2020, 8:37 AM
mlir/test/mlir-cpu-runner/sgemm_naive_codegen.mlir
16

This test will fail on Windows because the linker in JIT won't resolve this function. Consider returning 0.0 from the function and printing a message instead?

bondhugula marked 2 inline comments as done.Mar 27 2020, 10:20 PM
bondhugula added inline comments.
mlir/test/mlir-cpu-runner/sgemm_naive_codegen.mlir
16

Thanks, done.

bondhugula marked an inline comment as done.

Emit error message for the timer util on Win32

Ping reviewers @herhut @ftynse - thanks.

ftynse accepted this revision.Mar 31 2020, 12:56 AM
ftynse added inline comments.
mlir/lib/ExecutionEngine/RunnerUtils.cpp
110

Ultra-nit: the code below uses C-style I/O, let's be consistent here.

mlir/test/mlir-cpu-runner/sgemm_naive_codegen.mlir
2

Do we actually need the entire sgemm with non-trivial pipeline to test the flops printing utility?

This revision is now accepted and ready to land.Mar 31 2020, 12:56 AM
bondhugula marked 4 inline comments as done.Mar 31 2020, 2:25 AM

Thanks for the review.

mlir/lib/ExecutionEngine/RunnerUtils.cpp
110

Thanks - changed to C style.

mlir/test/mlir-cpu-runner/sgemm_naive_codegen.mlir
2

This is for both - flops printing and timing. We don't need sgemm in particular; could have used say sdot as something minimal where the FLOPS would still be meaningful. But I reduced the problem size to something really small - so it shouldn't matter (exec time is 0.002s), and this could be an additional integration test for mlir-cpu-runner.

bondhugula marked 2 inline comments as done.Mar 31 2020, 10:14 AM
This revision was automatically updated to reflect the committed changes.