ArmNN  NotReleased
OpenClTimer.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include <Instrument.hpp>
9 
10 #include <arm_compute/runtime/CL/CLScheduler.h>
11 #include <arm_compute/core/CL/OpenCL.h>
12 
13 #include <vector>
14 #include <list>
15 
16 namespace armnn
17 {
18 
20 class OpenClTimer : public Instrument
21 {
22 public:
23  OpenClTimer();
24  ~OpenClTimer() = default;
25 
27  void Start() override;
28 
30  void Stop() override;
31 
34  const char* GetName() const override { return "OpenClKernelTimer"; }
35 
38  std::vector<Measurement> GetMeasurements() const override;
39 
40 private:
41  using CLScheduler = arm_compute::CLScheduler;
42  using CLSymbols = arm_compute::CLSymbols;
43  using ClEvent = cl::Event;
44  using ClEnqueueFunc = decltype(CLSymbols::clEnqueueNDRangeKernel_ptr);
45 
47  struct KernelInfo
48  {
49  KernelInfo(const std::string& name, cl_event& event) : m_Name(name), m_Event(event) {}
50 
51  std::string m_Name;
52  ClEvent m_Event;
53  };
54 
55  std::list<KernelInfo> m_Kernels;
56  ClEnqueueFunc m_OriginalEnqueueFunction;
57 };
58 
59 } //namespace armnn
~OpenClTimer()=default
void Stop() override
Stop the OpenCl timer.
Definition: OpenClTimer.cpp:75
const char * GetName() const override
Definition: OpenClTimer.hpp:34
OpenClTimer instrument that times all OpenCl kernels executed between calls to Start() and Stop()...
Definition: OpenClTimer.hpp:20
std::vector< Measurement > GetMeasurements() const override
Definition: OpenClTimer.cpp:80
void Start() override
Start the OpenCl timer.
Definition: OpenClTimer.cpp:20