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".
* [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
* [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
* [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
* [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>