mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 04:12:57 +08:00
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:
committed by
Compute-Runtime-Automation
parent
4ff760baf2
commit
4697eb8e8c
@@ -362,8 +362,8 @@ TEST_F(AggregatedSmallBuffersEnabledTest, givenCopyHostPointerWhenCreatingBuffer
|
|||||||
context->setSpecialQueue(commandQueue, rootDeviceIndex);
|
context->setSpecialQueue(commandQueue, rootDeviceIndex);
|
||||||
|
|
||||||
flags = CL_MEM_COPY_HOST_PTR;
|
flags = CL_MEM_COPY_HOST_PTR;
|
||||||
unsigned char dataToCopy[PoolAllocator::smallBufferThreshold];
|
auto dataToCopy = std::unique_ptr<unsigned char[]>(new unsigned char[PoolAllocator::smallBufferThreshold]);
|
||||||
hostPtr = dataToCopy;
|
hostPtr = dataToCopy.get();
|
||||||
|
|
||||||
EXPECT_TRUE(poolAllocator->isAggregatedSmallBuffersEnabled(context.get()));
|
EXPECT_TRUE(poolAllocator->isAggregatedSmallBuffersEnabled(context.get()));
|
||||||
EXPECT_EQ(1u, poolAllocator->bufferPools.size());
|
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));
|
std::unique_ptr<Buffer> buffer(Buffer::create(context.get(), flags, size, hostPtr, retVal));
|
||||||
EXPECT_EQ(retVal, CL_SUCCESS);
|
EXPECT_EQ(retVal, CL_SUCCESS);
|
||||||
EXPECT_NE(buffer, nullptr);
|
EXPECT_NE(buffer, nullptr);
|
||||||
EXPECT_GT(buffer->getOffset(), 0u);
|
|
||||||
cl_buffer_region region;
|
cl_buffer_region region;
|
||||||
region.origin = 0xc0;
|
region.origin = 0xc0;
|
||||||
region.size = 32;
|
region.size = 32;
|
||||||
@@ -547,8 +546,8 @@ TEST_F(AggregatedSmallBuffersEnabledApiTest, givenSmallBufferWhenCreatingBufferT
|
|||||||
|
|
||||||
TEST_F(AggregatedSmallBuffersEnabledApiTest, givenUseHostPointerWhenCreatingBufferThenDoNotUsePool) {
|
TEST_F(AggregatedSmallBuffersEnabledApiTest, givenUseHostPointerWhenCreatingBufferThenDoNotUsePool) {
|
||||||
flags |= CL_MEM_USE_HOST_PTR;
|
flags |= CL_MEM_USE_HOST_PTR;
|
||||||
unsigned char hostData[PoolAllocator::smallBufferThreshold];
|
auto hostData = std::unique_ptr<unsigned char[]>(new unsigned char[PoolAllocator::smallBufferThreshold]);
|
||||||
hostPtr = hostData;
|
hostPtr = hostData.get();
|
||||||
cl_mem smallBuffer = clCreateBuffer(clContext, flags, size, hostPtr, &retVal);
|
cl_mem smallBuffer = clCreateBuffer(clContext, flags, size, hostPtr, &retVal);
|
||||||
EXPECT_EQ(retVal, CL_SUCCESS);
|
EXPECT_EQ(retVal, CL_SUCCESS);
|
||||||
EXPECT_NE(smallBuffer, nullptr);
|
EXPECT_NE(smallBuffer, nullptr);
|
||||||
@@ -634,9 +633,9 @@ TEST_F(AggregatedSmallBuffersEnabledApiTest, givenSubBufferNotFromPoolAndAggrega
|
|||||||
|
|
||||||
TEST_F(AggregatedSmallBuffersEnabledApiTest, givenCopyHostPointerWhenCreatingBufferThenUsePoolAndCopyHostPointer) {
|
TEST_F(AggregatedSmallBuffersEnabledApiTest, givenCopyHostPointerWhenCreatingBufferThenUsePoolAndCopyHostPointer) {
|
||||||
flags |= CL_MEM_COPY_HOST_PTR;
|
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;
|
dataToCopy[0] = 123;
|
||||||
hostPtr = dataToCopy;
|
hostPtr = dataToCopy.get();
|
||||||
auto contextRefCountBefore = context->getRefInternalCount();
|
auto contextRefCountBefore = context->getRefInternalCount();
|
||||||
cl_mem smallBuffer = clCreateBuffer(clContext, flags, size, hostPtr, &retVal);
|
cl_mem smallBuffer = clCreateBuffer(clContext, flags, size, hostPtr, &retVal);
|
||||||
EXPECT_EQ(context->getRefInternalCount(), contextRefCountBefore + 1);
|
EXPECT_EQ(context->getRefInternalCount(), contextRefCountBefore + 1);
|
||||||
@@ -672,7 +671,6 @@ TEST_F(AggregatedSmallBuffersSubBufferApiTest, givenBufferFromPoolWhenCreateSubB
|
|||||||
EXPECT_EQ(retVal, CL_SUCCESS);
|
EXPECT_EQ(retVal, CL_SUCCESS);
|
||||||
EXPECT_NE(buffer, nullptr);
|
EXPECT_NE(buffer, nullptr);
|
||||||
MockBuffer *mockBuffer = static_cast<MockBuffer *>(buffer);
|
MockBuffer *mockBuffer = static_cast<MockBuffer *>(buffer);
|
||||||
EXPECT_GT(mockBuffer->offset, 0u);
|
|
||||||
EXPECT_EQ(ptrOffset(poolAllocator->bufferPools[0].mainStorage->getCpuAddress(), mockBuffer->getOffset()), mockBuffer->getCpuAddress());
|
EXPECT_EQ(ptrOffset(poolAllocator->bufferPools[0].mainStorage->getCpuAddress(), mockBuffer->getOffset()), mockBuffer->getCpuAddress());
|
||||||
|
|
||||||
cl_buffer_region region{};
|
cl_buffer_region region{};
|
||||||
|
|||||||
Reference in New Issue
Block a user