* Set default capture period to 10mSec.
* Validate capture period in PeriodicCounterSelectionCommandHandler
pull it up to 10mSec if it is lower.
* Fix segmentation fault in GatordMock when receive thread closes.
Signed-off-by: Colm Donelan <Colm.Donelan@arm.com>
Change-Id: I9f7ddc70bd99c102c5baef872d28329976a4dc07
, m_OutgoingCaptureFile("")
, m_IncomingCaptureFile("")
, m_FileOnly(false)
- , m_CapturePeriod(150u)
+ , m_CapturePeriod(LOWEST_CAPTURE_PERIOD)
{}
bool m_EnableProfiling;
constexpr unsigned int MaxNumOfTensorDimensions = 5U;
+// The lowest performance data capture interval we support is 10 miliseconds.
+constexpr unsigned int LOWEST_CAPTURE_PERIOD = 10000u;
+
/// @enum Status enumeration
/// @var Status::Successful
/// @var Status::Failure
#include "PeriodicCounterSelectionCommandHandler.hpp"
#include "ProfilingUtils.hpp"
+#include <armnn/Types.hpp>
#include <boost/numeric/conversion/cast.hpp>
#include <boost/format.hpp>
ParseData(packet, captureData);
// Get the capture data
- const uint32_t capturePeriod = captureData.GetCapturePeriod();
+ uint32_t capturePeriod = captureData.GetCapturePeriod();
+ // Validate that the capture period is within the acceptable range.
+ if (capturePeriod > 0 && capturePeriod < LOWEST_CAPTURE_PERIOD)
+ {
+ capturePeriod = LOWEST_CAPTURE_PERIOD;
+ }
const std::vector<uint16_t>& counterIds = captureData.GetCounterIds();
// Check whether the selected counter UIDs are valid
#include <SendTimelinePacket.hpp>
#include <armnn/Conversion.hpp>
+#include <armnn/Types.hpp>
#include <armnn/Utils.hpp>
uint32_t sizeOfUint16 = numeric_cast<uint32_t>(sizeof(uint16_t));
// Data with period and counters
- uint32_t period1 = 10;
+ uint32_t period1 = armnn::LOWEST_CAPTURE_PERIOD;
uint32_t dataLength1 = 8;
uint32_t offset = 0;
offset += sizeOfUint32;
uint32_t period = ReadUint32(readBuffer, offset);
- BOOST_TEST(((headerWord0 >> 26) & 0x3F) == 0); // packet family
- BOOST_TEST(((headerWord0 >> 16) & 0x3FF) == 4); // packet id
- BOOST_TEST(headerWord1 == 8); // data lenght
- BOOST_TEST(period == 10); // capture period
+ BOOST_TEST(((headerWord0 >> 26) & 0x3F) == 0); // packet family
+ BOOST_TEST(((headerWord0 >> 16) & 0x3FF) == 4); // packet id
+ BOOST_TEST(headerWord1 == 8); // data length
+ BOOST_TEST(period == armnn::LOWEST_CAPTURE_PERIOD); // capture period
uint16_t counterId = 0;
offset += sizeOfUint32;
mockBuffer.MarkRead(readBuffer);
// Data with period only
- uint32_t period2 = 11;
+ uint32_t period2 = 9000; // We'll specify a value below LOWEST_CAPTURE_PERIOD. It should be pulled upwards.
uint32_t dataLength2 = 4;
std::unique_ptr<unsigned char[]> uniqueData2 = std::make_unique<unsigned char[]>(dataLength2);
const std::vector<uint16_t> counterIdsB = holder.GetCaptureData().GetCounterIds();
- BOOST_TEST(holder.GetCaptureData().GetCapturePeriod() == period2);
+ // Value should have been pulled up from 9000 to LOWEST_CAPTURE_PERIOD.
+ BOOST_TEST(holder.GetCaptureData().GetCapturePeriod() == armnn::LOWEST_CAPTURE_PERIOD);
BOOST_TEST(counterIdsB.size() == 0);
readBuffer = mockBuffer.GetReadableBuffer();
offset += sizeOfUint32;
period = ReadUint32(readBuffer, offset);
- BOOST_TEST(((headerWord0 >> 26) & 0x3F) == 0); // packet family
- BOOST_TEST(((headerWord0 >> 16) & 0x3FF) == 4); // packet id
- BOOST_TEST(headerWord1 == 4); // data length
- BOOST_TEST(period == 11); // capture period
+ BOOST_TEST(((headerWord0 >> 26) & 0x3F) == 0); // packet family
+ BOOST_TEST(((headerWord0 >> 16) & 0x3FF) == 4); // packet id
+ BOOST_TEST(headerWord1 == 4); // data length
+ BOOST_TEST(period == armnn::LOWEST_CAPTURE_PERIOD); // capture period
}
BOOST_AUTO_TEST_CASE(CheckConnectionAcknowledged)
std::cout << "Parsing command file: " << CommandFile << std::endl;
- while (std::getline(infile, line))
+ while (mockService.ReceiveThreadRunning() && std::getline(infile, line))
{
std::istringstream iss(line);
void GatordMockService::WaitForReceivingThread()
{
- m_CloseReceivingThread.store(true);
+ // The receiving thread may already have died.
+ if (m_CloseReceivingThread != true)
+ {
+ m_CloseReceivingThread.store(true);
+ }
// Check that the receiving thread is running
if (m_ListeningThread.joinable())
{
void GatordMockService::WaitCommand(uint timeout)
{
- std::this_thread::sleep_for(std::chrono::microseconds(timeout));
-
+ // Wait for a maximum of timeout microseconds or if the receive thread has closed.
+ // There is a certain level of rounding involved in this timing.
+ uint iterations = timeout / 1000;
+ std::cout << std::dec << "Wait command with timeout of " << timeout << " iterations = " << iterations << std::endl;
+ uint count = 0;
+ while ((this->ReceiveThreadRunning() && (count < iterations)))
+ {
+ std::this_thread::sleep_for(std::chrono::microseconds(1000));
+ ++count;
+ }
if (m_EchoPackets)
{
std::cout << std::dec << "Wait command with timeout of " << timeout << " microseconds completed. " << std::endl;
GatordMockService(armnn::profiling::CommandHandlerRegistry& registry, bool echoPackets)
: m_HandlerRegistry(registry)
, m_EchoPackets(echoPackets)
+ , m_CloseReceivingThread(false)
{
m_PacketsReceivedCount.store(0, std::memory_order_relaxed);
}
/// command handling code is added.
void WaitForReceivingThread();
+ // @return true only if the receive thread is closed or closing.
+ bool ReceiveThreadRunning()
+ {
+ return !m_CloseReceivingThread.load();
+ }
+
/// Send the counter list to ArmNN.
void SendPeriodicCounterSelectionList(uint32_t period, std::vector<uint16_t> counters);