• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include <atomic>
9 
10 #include <armnn/utility/IgnoreUnused.hpp>
11 
12 namespace armnn
13 {
14 
15 namespace  profiling
16 {
17 
18 enum class ProfilingState
19 {
20     Uninitialised,
21     NotConnected,
22     WaitingForAck,
23     Active
24 };
25 
26 class ProfilingStateMachine
27 {
28 public:
ProfilingStateMachine()29     ProfilingStateMachine() : m_State(ProfilingState::Uninitialised) {}
ProfilingStateMachine(ProfilingState state)30     ProfilingStateMachine(ProfilingState state) : m_State(state) {}
31 
32     ProfilingState GetCurrentState() const;
33     void TransitionToState(ProfilingState newState);
34     void Reset();
35 
IsOneOfStates(ProfilingState state1)36     bool IsOneOfStates(ProfilingState state1)
37     {
38         IgnoreUnused(state1);
39         return false;
40     }
41 
42     template<typename T, typename... Args >
IsOneOfStates(T state1,T state2,Args...args)43     bool IsOneOfStates(T state1, T state2, Args... args)
44     {
45         if (state1 == state2)
46         {
47             return true;
48         }
49         else
50         {
51             return IsOneOfStates(state1, args...);
52         }
53     }
54 
55 private:
56     std::atomic<ProfilingState> m_State;
57 };
58 
GetProfilingStateName(ProfilingState state)59 constexpr char const* GetProfilingStateName(ProfilingState state)
60 {
61     switch (state)
62     {
63         case ProfilingState::Uninitialised: return "Uninitialised";
64         case ProfilingState::NotConnected:  return "NotConnected";
65         case ProfilingState::WaitingForAck: return "WaitingForAck";
66         case ProfilingState::Active:        return "Active";
67         default:                            return "Unknown";
68     }
69 }
70 
71 } // namespace profiling
72 
73 } // namespace armnn
74 
75