Do not create buffer when size is too big.

Resolves: NEO-3131
Change-Id: Icd37e7bc62719be5956b6a9435ab2fe7e0962c00
Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
Krzysztof Gibala
2019-05-24 13:37:42 +02:00
committed by sys_ocldev
parent b98b51b0d9
commit 7830be3090
2 changed files with 26 additions and 7 deletions

View File

@@ -208,6 +208,24 @@ TEST_F(clCreateBufferTests, GivenMemWriteOnlyFlagAndMemReadWriteFlagWhenCreating
ASSERT_EQ(CL_INVALID_VALUE, retVal);
}
TEST_F(clCreateBufferTests, GivenBufferSizeOverMaxMemAllocSizeWhenCreatingBufferThenInvalidBufferSizeErrorIsReturned) {
auto pDevice = pContext->getDevice(0);
size_t size = static_cast<size_t>(pDevice->getDeviceInfo().maxMemAllocSize) + 1;
auto buffer = clCreateBuffer(pContext, CL_MEM_ALLOC_HOST_PTR, size, nullptr, &retVal);
EXPECT_EQ(CL_INVALID_BUFFER_SIZE, retVal);
EXPECT_EQ(nullptr, buffer);
}
TEST_F(clCreateBufferTests, GivenBufferSizeOverMaxMemAllocSizeWhenCreateBufferWithPropertiesINTELThenInvalidBufferSizeErrorIsReturned) {
auto pDevice = pContext->getDevice(0);
size_t size = static_cast<size_t>(pDevice->getDeviceInfo().maxMemAllocSize) + 1;
auto buffer = clCreateBufferWithPropertiesINTEL(pContext, nullptr, size, nullptr, &retVal);
EXPECT_EQ(CL_INVALID_BUFFER_SIZE, retVal);
EXPECT_EQ(nullptr, buffer);
}
TEST_F(clCreateBufferTests, GivenNullHostPointerAndMemCopyHostPtrFlagWhenCreatingBufferThenNullIsReturned) {
cl_mem_flags flags = CL_MEM_USE_HOST_PTR;
static const unsigned int bufferSize = 16;