2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // See LICENSE file in the project root for full license information.
8 #include "Instrument.hpp"
10 #include "arm_compute/runtime/CL/CLScheduler.h"
11 #include "arm_compute/core/CL/OpenCL.h"
19 /// OpenClTimer instrument that times all OpenCl kernels executed between calls to Start() and Stop().
20 class OpenClTimer : public Instrument
24 ~OpenClTimer() = default;
26 /// Start the OpenCl timer
27 void Start() override;
29 /// Stop the OpenCl timer
32 /// Get the name of the timer
33 /// \return Name of the timer
34 const char* GetName() const override { return "OpenClKernelTimer"; }
36 /// Get the recorded measurements. This will be a list of the execution durations for all the OpenCl kernels.
37 /// \return Recorded measurements
38 std::vector<Measurement> GetMeasurements() const override;
41 using CLScheduler = arm_compute::CLScheduler;
42 using CLSymbols = arm_compute::CLSymbols;
43 using ClEvent = cl::Event;
44 using ClEnqueueFunc = decltype(CLSymbols::clEnqueueNDRangeKernel_ptr);
46 /// Stores info about the OpenCl kernel
49 KernelInfo(const std::string& name, cl_event& event) : m_Name(name), m_Event(event) {}
55 std::list<KernelInfo> m_Kernels; ///< List of all kernels executed
56 ClEnqueueFunc m_OriginalEnqueueFunction; ///< Keep track of original OpenCl function