Narumol Prangnawarat | 15effd8 | 2019-10-22 14:17:11 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2019 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
Jim Flynn | 00f3aaf | 2019-10-24 11:58:06 +0100 | [diff] [blame] | 8 | #include "IProfilingGuidGenerator.hpp" |
Narumol Prangnawarat | 15effd8 | 2019-10-22 14:17:11 +0100 | [diff] [blame] | 9 | |
Jim Flynn | ab84575 | 2019-10-25 13:17:30 +0100 | [diff] [blame^] | 10 | #include <functional> |
| 11 | |
Narumol Prangnawarat | 15effd8 | 2019-10-22 14:17:11 +0100 | [diff] [blame] | 12 | namespace armnn |
| 13 | { |
| 14 | |
| 15 | namespace profiling |
| 16 | { |
| 17 | |
Jim Flynn | 00f3aaf | 2019-10-24 11:58:06 +0100 | [diff] [blame] | 18 | class ProfilingGuidGenerator : public IProfilingGuidGenerator |
Narumol Prangnawarat | 15effd8 | 2019-10-22 14:17:11 +0100 | [diff] [blame] | 19 | { |
| 20 | public: |
| 21 | /// Construct a generator with the default address space static/dynamic partitioning |
Jim Flynn | ab84575 | 2019-10-25 13:17:30 +0100 | [diff] [blame^] | 22 | ProfilingGuidGenerator() : m_Sequence(0) {} |
Narumol Prangnawarat | 15effd8 | 2019-10-22 14:17:11 +0100 | [diff] [blame] | 23 | |
| 24 | /// Return the next random Guid in the sequence |
Jim Flynn | 00f3aaf | 2019-10-24 11:58:06 +0100 | [diff] [blame] | 25 | // NOTE: dummy implementation for the moment |
Jim Flynn | ab84575 | 2019-10-25 13:17:30 +0100 | [diff] [blame^] | 26 | inline ProfilingDynamicGuid NextGuid() override |
| 27 | { |
| 28 | ProfilingDynamicGuid guid(m_Sequence); |
| 29 | m_Sequence++; |
| 30 | return guid; |
| 31 | } |
Narumol Prangnawarat | 15effd8 | 2019-10-22 14:17:11 +0100 | [diff] [blame] | 32 | |
Jim Flynn | 00f3aaf | 2019-10-24 11:58:06 +0100 | [diff] [blame] | 33 | /// Create a ProfilingStaticGuid based on a hash of the string |
| 34 | // NOTE: dummy implementation for the moment |
Jim Flynn | ab84575 | 2019-10-25 13:17:30 +0100 | [diff] [blame^] | 35 | inline ProfilingStaticGuid GenerateStaticId(const std::string& str) override |
| 36 | { |
| 37 | uint64_t guid = static_cast<uint64_t>(m_StringHasher(str)); |
| 38 | return guid; |
| 39 | } |
| 40 | |
| 41 | private: |
| 42 | std::hash<std::string> m_StringHasher; |
| 43 | uint64_t m_Sequence; |
Narumol Prangnawarat | 15effd8 | 2019-10-22 14:17:11 +0100 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | } // namespace profiling |
| 47 | |
| 48 | } // namespace armnn |