blob: ad3159f2013b9d6204e4ce228ecdd99aae191cd0 [file] [log] [blame]
Narumol Prangnawarat15effd82019-10-22 14:17:11 +01001//
2// Copyright © 2019 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
Jim Flynn00f3aaf2019-10-24 11:58:06 +01008#include "IProfilingGuidGenerator.hpp"
Narumol Prangnawarat15effd82019-10-22 14:17:11 +01009
Jim Flynnab845752019-10-25 13:17:30 +010010#include <functional>
11
Narumol Prangnawarat15effd82019-10-22 14:17:11 +010012namespace armnn
13{
14
15namespace profiling
16{
17
Jim Flynn00f3aaf2019-10-24 11:58:06 +010018class ProfilingGuidGenerator : public IProfilingGuidGenerator
Narumol Prangnawarat15effd82019-10-22 14:17:11 +010019{
20public:
21 /// Construct a generator with the default address space static/dynamic partitioning
Jim Flynnab845752019-10-25 13:17:30 +010022 ProfilingGuidGenerator() : m_Sequence(0) {}
Narumol Prangnawarat15effd82019-10-22 14:17:11 +010023
24 /// Return the next random Guid in the sequence
Jim Flynn00f3aaf2019-10-24 11:58:06 +010025 // NOTE: dummy implementation for the moment
Jim Flynnab845752019-10-25 13:17:30 +010026 inline ProfilingDynamicGuid NextGuid() override
27 {
Narumol Prangnawarat94a30882019-10-30 12:48:31 +000028 // NOTE: skipping the zero for testing purposes
29 ProfilingDynamicGuid guid(++m_Sequence);
Jim Flynnab845752019-10-25 13:17:30 +010030 return guid;
31 }
Narumol Prangnawarat15effd82019-10-22 14:17:11 +010032
Jim Flynn00f3aaf2019-10-24 11:58:06 +010033 /// Create a ProfilingStaticGuid based on a hash of the string
34 // NOTE: dummy implementation for the moment
Jim Flynnab845752019-10-25 13:17:30 +010035 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
41private:
42 std::hash<std::string> m_StringHasher;
43 uint64_t m_Sequence;
Narumol Prangnawarat15effd82019-10-22 14:17:11 +010044};
45
46} // namespace profiling
47
48} // namespace armnn