test(ocl): fix buffer pool allocator tests

do not use stack memory in tests

remove check for offset > 0 (offset==0 is a valid pooled buffer offset)

Related-To: NEO-9690

Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
Dominik Dabek
2023-12-21 14:04:50 +00:00
committed by Compute-Runtime-Automation
parent 4ff760baf2
commit 4697eb8e8c

View File

@@ -362,8 +362,8 @@ TEST_F(AggregatedSmallBuffersEnabledTest, givenCopyHostPointerWhenCreatingBuffer
context->setSpecialQueue(commandQueue, rootDeviceIndex);
flags = CL_MEM_COPY_HOST_PTR;
unsigned char dataToCopy[PoolAllocator::smallBufferThreshold];
hostPtr = dataToCopy;
auto dataToCopy = std::unique_ptr<unsigned char[]>(new unsigned char[PoolAllocator::smallBufferThreshold]);
hostPtr = dataToCopy.get();
EXPECT_TRUE(poolAllocator->isAggregatedSmallBuffersEnabled(context.get()));
EXPECT_EQ(1u, poolAllocator->bufferPools.size());
@@ -430,7 +430,6 @@ TEST_F(AggregatedSmallBuffersKernelTest, givenBufferFromPoolWhenOffsetSubbufferI
std::unique_ptr<Buffer> buffer(Buffer::create(context.get(), flags, size, hostPtr, retVal));
EXPECT_EQ(retVal, CL_SUCCESS);
EXPECT_NE(buffer, nullptr);
EXPECT_GT(buffer->getOffset(), 0u);
cl_buffer_region region;
region.origin = 0xc0;
region.size = 32;
@@ -547,8 +546,8 @@ TEST_F(AggregatedSmallBuffersEnabledApiTest, givenSmallBufferWhenCreatingBufferT
TEST_F(AggregatedSmallBuffersEnabledApiTest, givenUseHostPointerWhenCreatingBufferThenDoNotUsePool) {
flags |= CL_MEM_USE_HOST_PTR;
unsigned char hostData[PoolAllocator::smallBufferThreshold];
hostPtr = hostData;
auto hostData = std::unique_ptr<unsigned char[]>(new unsigned char[PoolAllocator::smallBufferThreshold]);
hostPtr = hostData.get();
cl_mem smallBuffer = clCreateBuffer(clContext, flags, size, hostPtr, &retVal);
EXPECT_EQ(retVal, CL_SUCCESS);
EXPECT_NE(smallBuffer, nullptr);
@@ -634,9 +633,9 @@ TEST_F(AggregatedSmallBuffersEnabledApiTest, givenSubBufferNotFromPoolAndAggrega
TEST_F(AggregatedSmallBuffersEnabledApiTest, givenCopyHostPointerWhenCreatingBufferThenUsePoolAndCopyHostPointer) {
flags |= CL_MEM_COPY_HOST_PTR;
unsigned char dataToCopy[PoolAllocator::smallBufferThreshold];
auto dataToCopy = std::unique_ptr<unsigned char[]>(new unsigned char[PoolAllocator::smallBufferThreshold]);
dataToCopy[0] = 123;
hostPtr = dataToCopy;
hostPtr = dataToCopy.get();
auto contextRefCountBefore = context->getRefInternalCount();
cl_mem smallBuffer = clCreateBuffer(clContext, flags, size, hostPtr, &retVal);
EXPECT_EQ(context->getRefInternalCount(), contextRefCountBefore + 1);
@@ -672,7 +671,6 @@ TEST_F(AggregatedSmallBuffersSubBufferApiTest, givenBufferFromPoolWhenCreateSubB
EXPECT_EQ(retVal, CL_SUCCESS);
EXPECT_NE(buffer, nullptr);
MockBuffer *mockBuffer = static_cast<MockBuffer *>(buffer);
EXPECT_GT(mockBuffer->offset, 0u);
EXPECT_EQ(ptrOffset(poolAllocator->bufferPools[0].mainStorage->getCpuAddress(), mockBuffer->getOffset()), mockBuffer->getCpuAddress());
cl_buffer_region region{};