MCPcopy Create free account
hub / github.com/ARM-software/armnn / Capture

Method Capture

profiling/client/src/PeriodicCounterCapture.cpp:80–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80void PeriodicCounterCapture::Capture(IReadCounterValues& readCounterValues)
81{
82 do
83 {
84 // Check if the current capture data indicates that there's data capture
85 auto currentCaptureData = ReadCaptureData();
86 const std::vector<uint16_t>& counterIds = currentCaptureData.GetCounterIds();
87 const uint32_t capturePeriod = currentCaptureData.GetCapturePeriod();
88
89 if (capturePeriod == 0)
90 {
91 // No data capture, wait the indicated capture period (milliseconds), if it is not zero
92#if !defined(ARMNN_DISABLE_THREADS)
93 std::this_thread::sleep_for(std::chrono::milliseconds(50u));
94#endif
95 continue;
96 }
97
98 if(counterIds.size() != 0)
99 {
100 std::vector<CounterValue> counterValues;
101
102 auto numCounters = counterIds.size();
103 counterValues.reserve(numCounters);
104
105 // Create a vector of pairs of CounterIndexes and Values
106 for (uint16_t index = 0; index < numCounters; ++index)
107 {
108 auto requestedId = counterIds[index];
109 uint32_t counterValue = 0;
110 try
111 {
112 counterValue = readCounterValues.GetDeltaCounterValue(requestedId);
113 }
114 catch (const arm::pipe::ProfilingException& e)
115 {
116 // Report the error and continue
117 ARM_PIPE_LOG(warning) << "An error has occurred when getting a counter value: "
118 << e.what();
119 continue;
120 }
121
122 counterValues.emplace_back(CounterValue {requestedId, counterValue });
123 }
124
125 // Send Periodic Counter Capture Packet for the Timestamp
126 m_SendCounterPacket.SendPeriodicCounterCapturePacket(GetTimestamp(), counterValues);
127 }
128
129 // Report counter values for each active backend
130 auto activeBackends = currentCaptureData.GetActiveBackends();
131 for_each(activeBackends.begin(), activeBackends.end(), [&](const std::string& backendId)
132 {
133 DispatchPeriodicCounterCapturePacket(
134 backendId, m_BackendProfilingContexts.at(backendId)->ReportCounterValues());
135 });
136
137 // Wait the indicated capture period (microseconds)

Callers

nothing calls this directly

Calls 11

GetTimestampFunction · 0.85
GetCapturePeriodMethod · 0.80
ReportCounterValuesMethod · 0.80
loadMethod · 0.80
sizeMethod · 0.45
reserveMethod · 0.45
GetDeltaCounterValueMethod · 0.45
whatMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected