Commit Graph

6 Commits

Author SHA1 Message Date
Tristan Konolige adcf199294 [PROFILING] Various fixes for profile_function (#10850)
Check that the function to be profiled is actually defined.

Check that the MetricCollector used actually can time the region
requested.

Default to using the module's entry_name instead of "main".
2022-03-31 17:13:28 -07:00
Tristan Konolige 8c2360e435 [PROFILING] Add ability to profile a single function_profiling (#9553)
* [PROFILING] Add ability to profile a single function_profiling

Add a new function `tvm.runtime.profiling.profile_function` which
collects performance metrics for a single function in an IRModule. For
example, collecting performance counters using `PAPIMetricCollector`.
This is helpful for optimizing kernels and schedules for a single
operator.

* fix docs

* configurable number of warmup iterations. avoid allocating when stopping collectors
2022-01-10 08:19:21 +09:00
Lunderberg 1526ad1f61 [UnitTest][Flaky] In test_report_serialization, compare csv. (#9275)
* [UnitTest][Flaky] In test_report_serialization, compare csv.

`str(report)` calls `ReportNode::AsTable()`, which includes aggregate
values.  Otherwise negligible differences in the computed value can be
rounded differently after the round trip.  This was first [noticed in
CI](https://ci.tlcpack.ai/blue/organizations/jenkins/tvm/detail/PR-9194/7/pipeline/#step-246-log-1217)
for an unrelated PR.  Testing locally, this failure mode occurred 2
times out of 3000 trials.

Switching to `report.csv()` avoids this issue, as it does not include
aggregates.

* Switched back to using AsTable(), but with column sums disabled.

The .csv column headers are in arbitrary order, and do not test
whether the `device_metrics` field has been serialized/deserialized
correctly.

* Added explicit sorting of columns to Report::AsTable
2021-10-23 06:25:58 +09:00
Tristan Konolige c650f9ac15 [PROFILING] Profiling over RPC (#8885)
* [PROFILING] Profiling over RPC

Allow for profiling over RPC by serializing the returned report before
sending it. Also remove collectors argument when profiling over rpc
because it cannot be serialized.

* lint

* fixes

* add comments
2021-09-09 14:53:31 +09:00
Tristan Konolige bce0db55d7 [PROFILING] Add json output to profiling reports (#8503)
* [PROFILING] Add json output to profiling reports

* format json in comments
2021-07-24 15:57:40 +09:00
Tristan Konolige d67514bd60 [PROFILING] Use PAPI to collect hardware performance counters on CPU and CUDA (#7983)
* [PROFILING] Use PAPI to collect hardware performance counters on CPU and CUDA

This PR adds an optional dependency on PAPI
(https://bitbucket.org/icl/papi/) in order to collect hardware
performance counters on CPU and CUDA. These performance counters include
data like total cycles, instructions executed, and cache misses. Users
can control which performance counters are collected by setting the
TVM_PAPI_${DEVICE}_METRICS environment variable to a semicolon separated
list of metrics.

* Update CMakeLists.txt

Co-authored-by: Leandro Nunes <leandro.nunes@arm.com>

* move thread pool reset out of crt

* add docs

* comments

* formatting

* forgot one doc

* kDLGPU -> kDLCUDA

* Refactor API to more closely match pass instrument's.

* forgot files

* formatting

* more lint

* fix docs

* optional loading of papi metric collector in python

* more formatting

* fix check

* update docs and default value

* formatting

* addressing andrews comments

* fix docs

* address comments

* move shared initialization code into private function

* move most definitions from papi header to implementation file

Co-authored-by: Leandro Nunes <leandro.nunes@arm.com>
2021-07-13 09:52:44 -07:00