143 arm::pipe::PacketVersionResolver packetVersionResolver;
145 ReadCounterVals readCounterVals;
147 MockBackendSendCounterPacket sendCounterPacket;
157 std::unique_ptr<armnn::profiling::IBackendProfiling> cpuBackendProfilingPtr =
158 std::make_unique<BackendProfiling>(options, profilingService, cpuAccId);
159 std::unique_ptr<armnn::profiling::IBackendProfiling> gpuBackendProfilingPtr =
160 std::make_unique<BackendProfiling>(options, profilingService, gpuAccId);
162 std::shared_ptr<armnn::profiling::IBackendProfilingContext> cpuProfilingContextPtr =
163 std::make_shared<armnn::MockBackendProfilingContext>(cpuBackendProfilingPtr);
164 std::shared_ptr<armnn::profiling::IBackendProfilingContext> gpuProfilingContextPtr =
165 std::make_shared<armnn::MockBackendProfilingContext>(gpuBackendProfilingPtr);
168 std::shared_ptr<armnn::profiling::IBackendProfilingContext>> backendProfilingContexts;
170 backendProfilingContexts[cpuAccId] = cpuProfilingContextPtr;
171 backendProfilingContexts[gpuAccId] = gpuProfilingContextPtr;
173 uint16_t globalId = 5;
183 backendProfilingContexts[cpuAccId] = cpuProfilingContextPtr;
184 backendProfilingContexts[gpuAccId] = gpuProfilingContextPtr;
187 counterIdMap, backendProfilingContexts);
189 uint16_t maxArmnnCounterId = 4;
193 packetVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue(),
194 backendProfilingContexts,
198 periodicCounterCapture,
207 uint32_t period = 12345u;
209 std::vector<uint16_t> cpuCounters{5, 6, 7};
210 std::vector<uint16_t> gpuCounters{8, 9, 10};
213 periodicCounterSelectionCommandHandler(
PacketWriter(period, gpuCounters));
214 periodicCounterCapture.Stop();
216 std::set<armnn::BackendId> activeIds = holder.GetCaptureData().GetActiveBackends();
217 BOOST_CHECK(activeIds.size() == 1);
218 BOOST_CHECK(activeIds.find(gpuAccId) != activeIds.end());
220 std::vector<Timestamp> recievedTimestamp = sendCounterPacket.GetTimestamps();
222 BOOST_CHECK(recievedTimestamp[0].timestamp == period);
223 BOOST_CHECK(recievedTimestamp.size() == 1);
224 BOOST_CHECK(recievedTimestamp[0].counterValues.size() == gpuCounters.size());
225 for (
unsigned long i=0; i< gpuCounters.size(); ++i)
227 BOOST_CHECK(recievedTimestamp[0].counterValues[i].counterId == gpuCounters[i]);
228 BOOST_CHECK(recievedTimestamp[0].counterValues[i].counterValue == i + 1u);
230 sendCounterPacket.ClearTimestamps();
233 periodicCounterSelectionCommandHandler(
PacketWriter(period, cpuCounters));
234 periodicCounterCapture.Stop();
236 activeIds = holder.GetCaptureData().GetActiveBackends();
237 BOOST_CHECK(activeIds.size() == 1);
238 BOOST_CHECK(activeIds.find(cpuAccId) != activeIds.end());
240 recievedTimestamp = sendCounterPacket.GetTimestamps();
242 BOOST_CHECK(recievedTimestamp[0].timestamp == period);
243 BOOST_CHECK(recievedTimestamp.size() == 1);
244 BOOST_CHECK(recievedTimestamp[0].counterValues.size() == cpuCounters.size());
245 for (
unsigned long i=0; i< cpuCounters.size(); ++i)
247 BOOST_CHECK(recievedTimestamp[0].counterValues[i].counterId == cpuCounters[i]);
248 BOOST_CHECK(recievedTimestamp[0].counterValues[i].counterValue == i + 1u);
250 sendCounterPacket.ClearTimestamps();
254 periodicCounterSelectionCommandHandler(
PacketWriter(period, {cpuCounters[0], gpuCounters[2],
255 gpuCounters[1], cpuCounters[1], gpuCounters[0]}));
256 periodicCounterCapture.Stop();
258 activeIds = holder.GetCaptureData().GetActiveBackends();
259 BOOST_CHECK(activeIds.size() == 2);
260 BOOST_CHECK(activeIds.find(cpuAccId) != activeIds.end());
261 BOOST_CHECK(activeIds.find(gpuAccId) != activeIds.end());
263 recievedTimestamp = sendCounterPacket.GetTimestamps();
265 BOOST_CHECK(recievedTimestamp[0].timestamp == period);
266 BOOST_CHECK(recievedTimestamp[1].timestamp == period);
268 BOOST_CHECK(recievedTimestamp.size() == 2);
269 BOOST_CHECK(recievedTimestamp[0].counterValues.size() == 2);
270 BOOST_CHECK(recievedTimestamp[1].counterValues.size() == gpuCounters.size());
272 BOOST_CHECK(recievedTimestamp[0].counterValues[0].counterId == cpuCounters[0]);
273 BOOST_CHECK(recievedTimestamp[0].counterValues[0].counterValue == 1u);
274 BOOST_CHECK(recievedTimestamp[0].counterValues[1].counterId == cpuCounters[1]);
275 BOOST_CHECK(recievedTimestamp[0].counterValues[1].counterValue == 2u);
277 for (
unsigned long i=0; i< gpuCounters.size(); ++i)
279 BOOST_CHECK(recievedTimestamp[1].counterValues[i].counterId == gpuCounters[i]);
280 BOOST_CHECK(recievedTimestamp[1].counterValues[i].counterValue == i + 1u);
283 sendCounterPacket.ClearTimestamps();
286 std::vector<uint16_t> counterValues;
287 counterValues.insert(counterValues.begin(), cpuCounters.begin(), cpuCounters.end());
288 counterValues.insert(counterValues.begin(), gpuCounters.begin(), gpuCounters.end());
290 periodicCounterSelectionCommandHandler(
PacketWriter(period, counterValues));
291 periodicCounterCapture.Stop();
293 activeIds = holder.GetCaptureData().GetActiveBackends();
294 BOOST_CHECK(activeIds.size() == 2);
295 BOOST_CHECK(activeIds.find(cpuAccId) != activeIds.end());
296 BOOST_CHECK(activeIds.find(gpuAccId) != activeIds.end());
298 recievedTimestamp = sendCounterPacket.GetTimestamps();
300 BOOST_CHECK(recievedTimestamp[0].counterValues.size() == cpuCounters.size());
301 for (
unsigned long i=0; i< cpuCounters.size(); ++i)
303 BOOST_CHECK(recievedTimestamp[0].counterValues[i].counterId == cpuCounters[i]);
304 BOOST_CHECK(recievedTimestamp[0].counterValues[i].counterValue == i + 1u);
307 BOOST_CHECK(recievedTimestamp[1].counterValues.size() == gpuCounters.size());
308 for (
unsigned long i=0; i< gpuCounters.size(); ++i)
310 BOOST_CHECK(recievedTimestamp[1].counterValues[i].counterId == gpuCounters[i]);
311 BOOST_CHECK(recievedTimestamp[1].counterValues[i].counterValue == i + 1u);
313 sendCounterPacket.ClearTimestamps();
316 counterValues = {0, 0, 200, cpuCounters[2], gpuCounters[0],3 ,30, cpuCounters[0],cpuCounters[2], gpuCounters[1], 3,
317 90, 0, 30, gpuCounters[0], gpuCounters[0]};
319 periodicCounterSelectionCommandHandler(
PacketWriter(period, counterValues));
320 periodicCounterCapture.Stop();
322 activeIds = holder.GetCaptureData().GetActiveBackends();
323 BOOST_CHECK(activeIds.size() == 2);
324 BOOST_CHECK(activeIds.find(cpuAccId) != activeIds.end());
325 BOOST_CHECK(activeIds.find(gpuAccId) != activeIds.end());
327 recievedTimestamp = sendCounterPacket.GetTimestamps();
329 BOOST_CHECK(recievedTimestamp.size() == 2);
331 BOOST_CHECK(recievedTimestamp[0].counterValues.size() == 2);
333 BOOST_CHECK(recievedTimestamp[0].counterValues[0].counterId == cpuCounters[0]);
334 BOOST_CHECK(recievedTimestamp[0].counterValues[0].counterValue == 1u);
335 BOOST_CHECK(recievedTimestamp[0].counterValues[1].counterId == cpuCounters[2]);
336 BOOST_CHECK(recievedTimestamp[0].counterValues[1].counterValue == 3u);
338 BOOST_CHECK(recievedTimestamp[1].counterValues.size() == 2);
340 BOOST_CHECK(recievedTimestamp[1].counterValues[0].counterId == gpuCounters[0]);
341 BOOST_CHECK(recievedTimestamp[1].counterValues[0].counterValue == 1u);
342 BOOST_CHECK(recievedTimestamp[1].counterValues[1].counterId == gpuCounters[1]);
343 BOOST_CHECK(recievedTimestamp[1].counterValues[1].counterValue == 2u);
345 sendCounterPacket.ClearTimestamps();
348 periodicCounterSelectionCommandHandler(
PacketWriter(period, {}));
349 periodicCounterCapture.Stop();
351 activeIds = holder.GetCaptureData().GetActiveBackends();
352 BOOST_CHECK(activeIds.size() == 0);
354 recievedTimestamp = sendCounterPacket.GetTimestamps();
355 BOOST_CHECK(recievedTimestamp.size() == 0);
357 sendCounterPacket.ClearTimestamps();
360 periodicCounterSelectionCommandHandler(
PacketWriter(0, counterValues));
361 periodicCounterCapture.Stop();
363 activeIds = holder.GetCaptureData().GetActiveBackends();
364 BOOST_CHECK(activeIds.size() == 0);
366 recievedTimestamp = sendCounterPacket.GetTimestamps();
367 BOOST_CHECK(recievedTimestamp.size() == 0);
void RegisterMapping(uint16_t globalCounterId, uint16_t backendCounterId, const armnn::BackendId &backendId) override
GPU Execution: OpenCL: ArmCompute.
arm::pipe::Packet PacketWriter(uint32_t period, std::vector< uint16_t > countervalues)
CPU Execution: NEON: ArmCompute.
void TransitionToState(ProfilingState newState)
ExternalProfilingOptions m_ProfilingOptions