blob: fdd712102e019ecc0a1bbfd0623e893a0b93e788 [file] [log] [blame]
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +01001/*
2 * Copyright (c) 2021 Arm Limited. All rights reserved.
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/****************************************************************************
20 * Includes
21 ****************************************************************************/
22
23#include "command_stream.hpp"
24
25#include <stdio.h>
26
27using namespace std;
28using namespace EthosU::CommandStream;
29
30/****************************************************************************
31 * Data
32 ****************************************************************************/
Anton Moberg908a07c2021-04-08 09:50:57 +020033// clang-format off
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +010034__attribute__((section(".sram.data"), aligned(16))) char commandStream[] = {
35 DRIVER_ACTION_MAGIC()
36 DRIVER_ACTION_NOP()
37 DRIVER_ACTION_NOP()
38 DRIVER_ACTION_COMMAND_STREAM(1)
39
40 NPU_OP_STOP(0)
Anton Moberg908a07c2021-04-08 09:50:57 +020041}; // clang-format on
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +010042
43/****************************************************************************
44 * Functions
45 ****************************************************************************/
46
47int main() {
Anton Moberg908a07c2021-04-08 09:50:57 +020048 CommandStream cs(DataPointer(commandStream, sizeof(commandStream)),
49 BasePointers(),
50 PmuEvents({ETHOSU_PMU_CYCLE, ETHOSU_PMU_NPU_IDLE, ETHOSU_PMU_NPU_ACTIVE}));
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +010051
52 const size_t repeat = 1000;
53
54 // Clear PMU
55 cs.getPmu().clear();
56
57 // Run inference
Anton Moberg908a07c2021-04-08 09:50:57 +020058 int ret = cs.run(repeat);
Kristofer Jonssonb5f7cfe2021-03-10 17:13:52 +010059 uint64_t cycleCount = cs.getPmu().getCycleCount();
60
61 // Print PMU counters
62 cs.getPmu().print();
63 printf("cycleCount=%llu, cycleCountPerJob=%llu\n", cycleCount, cycleCount / repeat);
64
65 return ret;
66}