blob: d13e6c2b6a1127cd2d19fc6a5ba462e9d9a5bbe3 [file] [log] [blame]
Jens Elofssona9817a12021-05-18 11:30:35 +02001/*
Kristofer Jonsson265b7eb2022-09-29 12:01:28 +02002 * SPDX-FileCopyrightText: Copyright 2021-2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
Jens Elofssona9817a12021-05-18 11:30:35 +02003 *
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 Moberg07cf70b2021-07-07 11:08:17 +020020#include "ethosu_log.h"
Kristofer Jonssone4f09e52021-11-26 16:13:58 +010021#include <inttypes.h>
Jens Elofssona9817a12021-05-18 11:30:35 +020022#include <stdio.h>
23
Kristofer Jonsson265b7eb2022-09-29 12:01:28 +020024EthosUMonitor::EthosUMonitor(Backend __backend) : backend(__backend) {}
Jens Elofssona9817a12021-05-18 11:30:35 +020025
26void EthosUMonitor::monitorSample(ethosu_driver *drv) {
Kristofer Jonsson265b7eb2022-09-29 12:01:28 +020027 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 Elofssona9817a12021-05-18 11:30:35 +020044 }
45 }
46}
47
48void EthosUMonitor::release(ethosu_driver *drv) {
49 ETHOSU_PMU_Disable(drv);
50}