diff options
author | Jim Flynn <jim.flynn@arm.com> | 2020-06-22 20:41:43 +0100 |
---|---|---|
committer | James Conroy <james.conroy@arm.com> | 2020-06-23 09:14:51 +0000 |
commit | 0204f09cb7462c675c45c76cd13d677d67f73589 (patch) | |
tree | 880f018f376b04652730715d1bc3fbaff1f90df7 /src/profiling/test | |
parent | 1f45dc3e7f955a6d75c8516ba6fd7eade2b03cb7 (diff) | |
download | armnn-0204f09cb7462c675c45c76cd13d677d67f73589.tar.gz |
IVGCVSW-5022 Fix master intermittent failure by providing surge buffer capacity
Change-Id: I028aec48d89d7348836223029aa1e8c315f160fa
Signed-off-by: Jim Flynn <jim.flynn@arm.com>
Diffstat (limited to 'src/profiling/test')
-rw-r--r-- | src/profiling/test/BufferTests.cpp | 70 | ||||
-rw-r--r-- | src/profiling/test/ProfilingMocks.hpp | 2 |
2 files changed, 72 insertions, 0 deletions
diff --git a/src/profiling/test/BufferTests.cpp b/src/profiling/test/BufferTests.cpp index cba209c9a2..0225d750a7 100644 --- a/src/profiling/test/BufferTests.cpp +++ b/src/profiling/test/BufferTests.cpp @@ -146,6 +146,21 @@ BOOST_AUTO_TEST_CASE(BufferExhaustionTest) BOOST_TEST(packetBuffer.get()); // Cannot reserve buffer when buffer is not available + // NOTE: because the buffer manager now has surge capacity of + // initial size * 3 we should be able to reserve three + // buffers before exhaustion + packetBuffer = bufferManager.Reserve(512, reservedSize); + + // Successfully reserved the second buffer with requested size + BOOST_TEST(reservedSize == 512); + BOOST_TEST(packetBuffer.get()); + + packetBuffer = bufferManager.Reserve(512, reservedSize); + + // Successfully reserved the third buffer with requested size + BOOST_TEST(reservedSize == 512); + BOOST_TEST(packetBuffer.get()); + auto reservedBuffer = bufferManager.Reserve(512, reservedSize); BOOST_TEST(reservedSize == 0); BOOST_TEST(!reservedBuffer.get()); @@ -175,6 +190,19 @@ BOOST_AUTO_TEST_CASE(BufferReserveMultipleTest) BOOST_TEST(reservedSize2 == 512); BOOST_TEST(packetBuffer2.get()); + // NOTE: the buffer now has a surge capacity of initial size * 3 + // so we can grab 9 of them prior to exhaustion now + for (unsigned int i = 0; i < 6 ; ++i) + { + // grab another six buffers to exhaust the surge capacity + unsigned int reservedSize = 0; + auto packetBuffer = bufferManager.Reserve(512, reservedSize); + + // Successfully reserved the third buffer with requested size + BOOST_TEST(reservedSize == 512); + BOOST_TEST(packetBuffer.get()); + } + // Cannot reserve when buffer is not available unsigned int reservedSize3 = 0; auto reservedBuffer = bufferManager.Reserve(512, reservedSize3); @@ -199,6 +227,20 @@ BOOST_AUTO_TEST_CASE(BufferReleaseTest) BOOST_TEST(reservedSize1 == 128); BOOST_TEST(packetBuffer1.get()); + // NOTE: now that we have a surge capacity of up to + // initial size * 3 we need to allocate four more + // buffers to exhaust the manager + for (unsigned int i = 0; i < 4 ; ++i) + { + // grab another six buffers to exhaust the surge capacity + unsigned int reservedSize = 0; + auto packetBuffer = bufferManager.Reserve(512, reservedSize); + + // Successfully reserved the third buffer with requested size + BOOST_TEST(reservedSize == 512); + BOOST_TEST(packetBuffer.get()); + } + // Cannot reserve when buffer is not available unsigned int reservedSize2 = 0; auto reservedBuffer = bufferManager.Reserve(512, reservedSize2); @@ -229,6 +271,20 @@ BOOST_AUTO_TEST_CASE(BufferCommitTest) BOOST_TEST(reservedSize1 == 128); BOOST_TEST(packetBuffer1.get()); + // NOTE: now that we have a surge capacity of up to + // initial size * 3 we need to allocate four more + // buffers to exhaust the manager + for (unsigned int i = 0; i < 4 ; ++i) + { + // grab another six buffers to exhaust the surge capacity + unsigned int reservedSize = 0; + auto packetBuffer = bufferManager.Reserve(512, reservedSize); + + // Successfully reserved the third buffer with requested size + BOOST_TEST(reservedSize == 512); + BOOST_TEST(packetBuffer.get()); + } + unsigned int reservedSize2 = 0; auto reservedBuffer = bufferManager.Reserve(512, reservedSize2); BOOST_TEST(reservedSize2 == 0); @@ -263,6 +319,20 @@ BOOST_AUTO_TEST_CASE(BufferMarkReadTest) BOOST_TEST(reservedSize1 == 128); BOOST_TEST(packetBuffer1.get()); + // NOTE: now that we have a surge capacity of up to + // initial size * 3 we need to allocate four more + // buffers to exhaust the manager + for (unsigned int i = 0; i < 4 ; ++i) + { + // grab another six buffers to exhaust the surge capacity + unsigned int reservedSize = 0; + auto packetBuffer = bufferManager.Reserve(512, reservedSize); + + // Successfully reserved the third buffer with requested size + BOOST_TEST(reservedSize == 512); + BOOST_TEST(packetBuffer.get()); + } + // Cannot reserve when buffer is not available unsigned int reservedSize2 = 0; auto reservedBuffer = bufferManager.Reserve(512, reservedSize2); diff --git a/src/profiling/test/ProfilingMocks.hpp b/src/profiling/test/ProfilingMocks.hpp index fe8fbd7db9..e4f71f932c 100644 --- a/src/profiling/test/ProfilingMocks.hpp +++ b/src/profiling/test/ProfilingMocks.hpp @@ -193,6 +193,8 @@ public: unsigned char* GetWritableData() override { return m_Data.get(); } + void Destroy() override {m_Data.reset(nullptr); m_Size = 0; m_MaxSize =0;} + private: unsigned int m_MaxSize; unsigned int m_Size; |