diff options
author | Aron Virginas-Tar <Aron.Virginas-Tar@arm.com> | 2018-10-12 13:00:55 +0100 |
---|---|---|
committer | Matthew Bentham <matthew.bentham@arm.com> | 2018-10-22 16:57:53 +0100 |
commit | 3b278e9261bd0de67c82f7d6c36731f118124f52 (patch) | |
tree | 3750ee01827809141752302e94d4d25a21f88492 /src/backends/cl/OpenClTimer.hpp | |
parent | d3360cd490eafc76ceddb6760054bd80444179c1 (diff) | |
download | armnn-3b278e9261bd0de67c82f7d6c36731f118124f52.tar.gz |
IVGCVSW-1938: Move backend-specific source files to the corresponding backend
Change-Id: I558a9a007604afc55e536d877f8da7d0215cc9c3
Diffstat (limited to 'src/backends/cl/OpenClTimer.hpp')
-rw-r--r-- | src/backends/cl/OpenClTimer.hpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/backends/cl/OpenClTimer.hpp b/src/backends/cl/OpenClTimer.hpp new file mode 100644 index 0000000000..a7ae1387d9 --- /dev/null +++ b/src/backends/cl/OpenClTimer.hpp @@ -0,0 +1,59 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include "Instrument.hpp" + +#include <arm_compute/runtime/CL/CLScheduler.h> +#include <arm_compute/core/CL/OpenCL.h> + +#include <vector> +#include <list> + +namespace armnn +{ + +/// OpenClTimer instrument that times all OpenCl kernels executed between calls to Start() and Stop(). +class OpenClTimer : public Instrument +{ +public: + OpenClTimer(); + ~OpenClTimer() = default; + + /// Start the OpenCl timer + void Start() override; + + /// Stop the OpenCl timer + void Stop() override; + + /// Get the name of the timer + /// \return Name of the timer + const char* GetName() const override { return "OpenClKernelTimer"; } + + /// Get the recorded measurements. This will be a list of the execution durations for all the OpenCl kernels. + /// \return Recorded measurements + std::vector<Measurement> GetMeasurements() const override; + +private: + using CLScheduler = arm_compute::CLScheduler; + using CLSymbols = arm_compute::CLSymbols; + using ClEvent = cl::Event; + using ClEnqueueFunc = decltype(CLSymbols::clEnqueueNDRangeKernel_ptr); + + /// Stores info about the OpenCl kernel + struct KernelInfo + { + KernelInfo(const std::string& name, cl_event& event) : m_Name(name), m_Event(event) {} + + std::string m_Name; + ClEvent m_Event; + }; + + std::list<KernelInfo> m_Kernels; ///< List of all kernels executed + ClEnqueueFunc m_OriginalEnqueueFunction; ///< Keep track of original OpenCl function +}; + +} //namespace armnn
\ No newline at end of file |