backend
describes which backend to use, and can be either PRINTF
or EVENT_RECORDER
configure(driver, eventIds)
eventIds
. The maximum number of PMU registers to monitor is 4.release(driver)
monitorSample(driver)
configure
and logs them using the selected backend.An example on how to use Ethos-U monitor can be found in the baremetal application in the ethosu-core-platform repository.
The functions ethosu_inference_begin
and ethosu_inference_end
are defined as weak symbols in ethosu_driver.c.
They are called by the Ethos-U driver before and after the Ethos-U custom operator is executed. In the example application a timer source is configured to periodically trigger an interrupt, on which the the configured PMU registers are sampled one by one and recorded using EventRecorder as backend. Note that the events in this example are logged from an interrupt context which will impact the execution time.
Below is a sequence diagram showing a simplified version of how the different components interact.
.
For each of the configured PMU registers, an event is recorded using the EventRecord2 function. Each event consists of two int32-values and an id.
In the example application, the following PMU registers are recorded: | EventID | Value 1 | Value 2 | | ------- | ------- | ------- | | Id1 | ETHOSU_PMU_CYCLE | Register value | | Id2 | ETHOSU_PMU_NPU_ACTIVE | Register value |
Id1
and Id2
are defined by the eventRecordIds
parameter in the constructor of Ethos-U monitor. Value 1
is the PMU register number, as represented by the ethosu_pmu_event_type enum. Value 2
is the value of the PMU register when read by the monitorSample
function.
When using printf
the register values are printed on the format ethosu_pmu_cntr<counter_no> : <register_value>
, where counter_no
is the index (0-3) of the configured PMU register, and register_value
is the value of the PMU register.