Jens Elofsson | a9817a1 | 2021-05-18 11:30:35 +0200 | [diff] [blame] | 1 | /* |
Kristofer Jonsson | 265b7eb | 2022-09-29 12:01:28 +0200 | [diff] [blame] | 2 | * SPDX-FileCopyrightText: Copyright 2021-2022 Arm Limited and/or its affiliates <open-source-office@arm.com> |
Jens Elofsson | a9817a1 | 2021-05-18 11:30:35 +0200 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: Apache-2.0 |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the License); you may |
| 7 | * not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
| 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | #include "ethosu_monitor.hpp" |
Anton Moberg | 07cf70b | 2021-07-07 11:08:17 +0200 | [diff] [blame] | 20 | #include "ethosu_log.h" |
Kristofer Jonsson | e4f09e5 | 2021-11-26 16:13:58 +0100 | [diff] [blame] | 21 | #include <inttypes.h> |
Jens Elofsson | a9817a1 | 2021-05-18 11:30:35 +0200 | [diff] [blame] | 22 | #include <stdio.h> |
| 23 | |
Kristofer Jonsson | 265b7eb | 2022-09-29 12:01:28 +0200 | [diff] [blame] | 24 | EthosUMonitor::EthosUMonitor(Backend __backend) : backend(__backend) {} |
Jens Elofsson | a9817a1 | 2021-05-18 11:30:35 +0200 | [diff] [blame] | 25 | |
| 26 | void EthosUMonitor::monitorSample(ethosu_driver *drv) { |
Kristofer Jonsson | 265b7eb | 2022-09-29 12:01:28 +0200 | [diff] [blame] | 27 | switch (backend) { |
| 28 | case EVENT_RECORDER: { |
| 29 | EthosuEventRecord record = {ETHOSU_PMU_Get_CCNTR(drv), |
| 30 | ETHOSU_PMU_Get_QREAD(drv), |
| 31 | ETHOSU_PMU_Get_STATUS(drv), |
| 32 | {{ethosuEventIds[0], ETHOSU_PMU_Get_EVCNTR(drv, 0)}, |
| 33 | {ethosuEventIds[1], ETHOSU_PMU_Get_EVCNTR(drv, 1)}, |
| 34 | {ethosuEventIds[2], ETHOSU_PMU_Get_EVCNTR(drv, 2)}, |
| 35 | {ethosuEventIds[3], ETHOSU_PMU_Get_EVCNTR(drv, 3)}}}; |
| 36 | |
| 37 | EventRecordData(EventID(EventLevelDetail, EthosuEventComponentNo, 0), &record, sizeof(record)); |
| 38 | break; |
| 39 | } |
| 40 | case PRINTF: |
| 41 | default: |
| 42 | for (size_t i = 0; i < numEvents; i++) { |
| 43 | LOG("ethosu_pmu_cntr%zd : %" PRIu32 "\n", i, ETHOSU_PMU_Get_EVCNTR(drv, 0)); |
Jens Elofsson | a9817a1 | 2021-05-18 11:30:35 +0200 | [diff] [blame] | 44 | } |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | void EthosUMonitor::release(ethosu_driver *drv) { |
| 49 | ETHOSU_PMU_Disable(drv); |
| 50 | } |