diff options
Diffstat (limited to 'applications/baremetal/main.cpp')
-rw-r--r-- | applications/baremetal/main.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/applications/baremetal/main.cpp b/applications/baremetal/main.cpp index 4c0bf50..0c89058 100644 --- a/applications/baremetal/main.cpp +++ b/applications/baremetal/main.cpp @@ -33,6 +33,11 @@ #include "model.h" #include "output.h" +#ifdef ETHOSU +#include <ethosu_monitor.hpp> +#include <pmu_ethosu.h> +#endif + using namespace std; /**************************************************************************** @@ -49,6 +54,39 @@ InferenceProcess::InferenceProcess inferenceProcess(TFLuTensorArena, TENSOR_AREN uint8_t outputData[sizeof(expectedOutputData)] __attribute__((aligned(16), section("output_data_sec"))); +#ifdef ETHOSU +namespace { +std::vector<ethosu_pmu_event_type> pmuEventConfig{ETHOSU_PMU_CYCLE, ETHOSU_PMU_NPU_ACTIVE}; +const uint32_t delayMs = SystemCoreClock / 60ul; +struct ethosu_driver *ethosuDrv; +EthosUMonitor ethosuMonitor(0, EthosUMonitor::Backend::EVENT_RECORDER); +} // namespace + +extern "C" { + +void SysTick_Handler(void) { + ethosuMonitor.monitorSample(ethosuDrv); +} + +void ethosu_inference_begin(struct ethosu_driver *drv, const void *) { + ethosuDrv = drv; + ethosuMonitor.configure(drv, pmuEventConfig); + + // Enable polling + SysTick_Config(delayMs); +} + +void ethosu_inference_end(struct ethosu_driver *drv, const void *) { + // Disable polling + SysTick->CTRL = 0; + + ethosuDrv = 0; + ethosuMonitor.monitorSample(drv); + ethosuMonitor.release(drv); +} +} +#endif + int runInference() { // Load inference data vector<InferenceProcess::DataPtr> input; @@ -79,6 +117,9 @@ int runInference() { } int main() { +#ifdef ETHOSU + EventRecorderInitialize(EventRecordAll, 1); +#endif int ret = runInference(); return ret; } |