diff --git a/runtime/device/device_caps.cpp b/runtime/device/device_caps.cpp index 5dc40c1ef9..79613886fa 100644 --- a/runtime/device/device_caps.cpp +++ b/runtime/device/device_caps.cpp @@ -235,7 +235,7 @@ void Device::initializeCaps() { deviceInfo.preferredInteropUserSync = 1u; // OpenCL 1.2 requires 128MB minimum - deviceInfo.maxMemAllocSize = std::min(std::max(deviceInfo.globalMemSize, static_cast(128llu * MB)), this->hardwareCapabilities.maxMemAllocSize); + deviceInfo.maxMemAllocSize = std::min(std::max(deviceInfo.globalMemSize / 2, static_cast(128llu * MB)), this->hardwareCapabilities.maxMemAllocSize); deviceInfo.maxConstantBufferSize = deviceInfo.maxMemAllocSize; diff --git a/runtime/mem_obj/buffer.cpp b/runtime/mem_obj/buffer.cpp index 216a9ed8dd..2af83a030f 100644 --- a/runtime/mem_obj/buffer.cpp +++ b/runtime/mem_obj/buffer.cpp @@ -90,7 +90,7 @@ void Buffer::validateInputAndCreateBuffer(cl_context &context, } auto pDevice = pContext->getDevice(0); - if (size == 0 || size > pDevice->getDeviceInfo().maxMemAllocSize) { + if (size == 0 || size > pDevice->getHardwareCapabilities().maxMemAllocSize) { retVal = CL_INVALID_BUFFER_SIZE; return; } diff --git a/unit_tests/api/cl_create_buffer_tests.cpp b/unit_tests/api/cl_create_buffer_tests.cpp index 2adece273f..1c9623405f 100644 --- a/unit_tests/api/cl_create_buffer_tests.cpp +++ b/unit_tests/api/cl_create_buffer_tests.cpp @@ -210,7 +210,7 @@ TEST_F(clCreateBufferTests, GivenMemWriteOnlyFlagAndMemReadWriteFlagWhenCreating TEST_F(clCreateBufferTests, GivenBufferSizeOverMaxMemAllocSizeWhenCreatingBufferThenInvalidBufferSizeErrorIsReturned) { auto pDevice = pContext->getDevice(0); - size_t size = static_cast(pDevice->getDeviceInfo().maxMemAllocSize) + 1; + size_t size = static_cast(pDevice->getHardwareCapabilities().maxMemAllocSize) + 1; auto buffer = clCreateBuffer(pContext, CL_MEM_ALLOC_HOST_PTR, size, nullptr, &retVal); EXPECT_EQ(CL_INVALID_BUFFER_SIZE, retVal); @@ -219,7 +219,7 @@ TEST_F(clCreateBufferTests, GivenBufferSizeOverMaxMemAllocSizeWhenCreatingBuffer TEST_F(clCreateBufferTests, GivenBufferSizeOverMaxMemAllocSizeWhenCreateBufferWithPropertiesINTELThenInvalidBufferSizeErrorIsReturned) { auto pDevice = pContext->getDevice(0); - size_t size = static_cast(pDevice->getDeviceInfo().maxMemAllocSize) + 1; + size_t size = static_cast(pDevice->getHardwareCapabilities().maxMemAllocSize) + 1; auto buffer = clCreateBufferWithPropertiesINTEL(pContext, nullptr, size, nullptr, &retVal); EXPECT_EQ(CL_INVALID_BUFFER_SIZE, retVal); diff --git a/unit_tests/device/device_caps_tests.cpp b/unit_tests/device/device_caps_tests.cpp index e2485d7eca..fcf5b3b5e3 100644 --- a/unit_tests/device/device_caps_tests.cpp +++ b/unit_tests/device/device_caps_tests.cpp @@ -341,7 +341,7 @@ TEST(Device_GetCaps, givenGlobalMemSizeWhenCalculatingMaxAllocSizeThenAdjustToHW auto &hwHelper = HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily); hwHelper.setupHardwareCapabilities(&hwCaps, *platformDevices[0]); - uint64_t expectedSize = std::max((caps.globalMemSize), static_cast(128ULL * MemoryConstants::megaByte)); + uint64_t expectedSize = std::max((caps.globalMemSize / 2), static_cast(128ULL * MemoryConstants::megaByte)); expectedSize = std::min(expectedSize, hwCaps.maxMemAllocSize); EXPECT_EQ(caps.maxMemAllocSize, expectedSize);