Skip to content

Commit 9efb909

Browse files
authored
Arm backend: Fix CPU cycle counters over backend delegate code (#10393)
### Summary This fixes a bug where we renamed the weak functions but not the non-weak versions. ### Test plan Tests by manually looking at the logs when running and detecting that cycles was not zero. Signed-off-by: Zingo Andersen <[email protected]>
1 parent 032ba6c commit 9efb909

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

backends/arm/runtime/EthosUBackend.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
144144

145145
EXECUTORCH_PROF_SCOPE(event_tracer, "EthosUBackend::execute()");
146146

147+
// CollectArm_CPU_Cycles is just used to save the numbers of CPU cycles
148+
// used, If etdump is used the EXECUTORCH_PROF_SCOPE() above will do the
149+
// same. If not, this is a cheap way of getting some stats and the
150+
// CollectArm_CPU_Cycles object can safely be removed in production code.
151+
//
152+
// The EthosUBackendExecuteCallbacks class uses the C++
153+
// constructor/destructor to make sure that EthosUBackend_execute_begin()
154+
// and EthosUBackend_execute_end() is called while CollectArm_CPU_Cycles is
155+
// in scope. e.g. We meassure from now until we exit this metod (in any way
156+
// we might do it).
157+
EthosUBackendExecuteCallbacks CollectArm_CPU_Cycles;
158+
147159
ExecutionHandle* execution_handle = (ExecutionHandle*)input_handle;
148160
VelaHandles handles;
149161

examples/arm/executor_runner/arm_perf_monitor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2024 Arm Limited and/or its affiliates.
1+
/* Copyright 2024-2025 Arm Limited and/or its affiliates.
22
*
33
* This source code is licensed under the BSD-style license found in the
44
* LICENSE file in the root directory of this source tree.
@@ -98,14 +98,14 @@ void ethosu_inference_end(struct ethosu_driver* drv, void*) {
9898
}
9999

100100
// Callback invoked at start of ArmBackend::execute()
101-
void ArmBackend_execute_begin() {
101+
void EthosUBackend_execute_begin() {
102102
// Save Cortex-M cycle clock to calculate total CPU cycles used in
103103
// ArmBackend_execute_end()
104104
ethosu_ArmBackendExecuteCycleCountStart = ARM_PMU_Get_CCNTR();
105105
}
106106

107107
// Callback invoked at end of ArmBackend::execute()
108-
void ArmBackend_execute_end() {
108+
void EthosUBackend_execute_end() {
109109
// Add Cortex-M cycle clock used during this ArmBackend::execute()
110110
ethosu_ArmBackendExecuteCycleCount +=
111111
(ARM_PMU_Get_CCNTR() - ethosu_ArmBackendExecuteCycleCountStart);

0 commit comments

Comments
 (0)