Skip to content

Commit 5dc20f5

Browse files
Change max mem alloc size deduction.
- make it half of global mem - change buffer input validation, look for hw limitations instead of computed value of max mem alloc size. Change-Id: Ibbe7eb16d01299b02cef3b1e7234efefbced2197 Signed-off-by: Mrozek, Michal <[email protected]>
1 parent 6a51f1f commit 5dc20f5

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

runtime/device/device_caps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ void Device::initializeCaps() {
235235
deviceInfo.preferredInteropUserSync = 1u;
236236

237237
// OpenCL 1.2 requires 128MB minimum
238-
deviceInfo.maxMemAllocSize = std::min(std::max(deviceInfo.globalMemSize, static_cast<uint64_t>(128llu * MB)), this->hardwareCapabilities.maxMemAllocSize);
238+
deviceInfo.maxMemAllocSize = std::min(std::max(deviceInfo.globalMemSize / 2, static_cast<uint64_t>(128llu * MB)), this->hardwareCapabilities.maxMemAllocSize);
239239

240240
deviceInfo.maxConstantBufferSize = deviceInfo.maxMemAllocSize;
241241

runtime/mem_obj/buffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void Buffer::validateInputAndCreateBuffer(cl_context &context,
9090
}
9191

9292
auto pDevice = pContext->getDevice(0);
93-
if (size == 0 || size > pDevice->getDeviceInfo().maxMemAllocSize) {
93+
if (size == 0 || size > pDevice->getHardwareCapabilities().maxMemAllocSize) {
9494
retVal = CL_INVALID_BUFFER_SIZE;
9595
return;
9696
}

unit_tests/api/cl_create_buffer_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ TEST_F(clCreateBufferTests, GivenMemWriteOnlyFlagAndMemReadWriteFlagWhenCreating
210210

211211
TEST_F(clCreateBufferTests, GivenBufferSizeOverMaxMemAllocSizeWhenCreatingBufferThenInvalidBufferSizeErrorIsReturned) {
212212
auto pDevice = pContext->getDevice(0);
213-
size_t size = static_cast<size_t>(pDevice->getDeviceInfo().maxMemAllocSize) + 1;
213+
size_t size = static_cast<size_t>(pDevice->getHardwareCapabilities().maxMemAllocSize) + 1;
214214

215215
auto buffer = clCreateBuffer(pContext, CL_MEM_ALLOC_HOST_PTR, size, nullptr, &retVal);
216216
EXPECT_EQ(CL_INVALID_BUFFER_SIZE, retVal);
@@ -219,7 +219,7 @@ TEST_F(clCreateBufferTests, GivenBufferSizeOverMaxMemAllocSizeWhenCreatingBuffer
219219

220220
TEST_F(clCreateBufferTests, GivenBufferSizeOverMaxMemAllocSizeWhenCreateBufferWithPropertiesINTELThenInvalidBufferSizeErrorIsReturned) {
221221
auto pDevice = pContext->getDevice(0);
222-
size_t size = static_cast<size_t>(pDevice->getDeviceInfo().maxMemAllocSize) + 1;
222+
size_t size = static_cast<size_t>(pDevice->getHardwareCapabilities().maxMemAllocSize) + 1;
223223

224224
auto buffer = clCreateBufferWithPropertiesINTEL(pContext, nullptr, size, nullptr, &retVal);
225225
EXPECT_EQ(CL_INVALID_BUFFER_SIZE, retVal);

unit_tests/device/device_caps_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ TEST(Device_GetCaps, givenGlobalMemSizeWhenCalculatingMaxAllocSizeThenAdjustToHW
341341
auto &hwHelper = HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily);
342342
hwHelper.setupHardwareCapabilities(&hwCaps, *platformDevices[0]);
343343

344-
uint64_t expectedSize = std::max((caps.globalMemSize), static_cast<uint64_t>(128ULL * MemoryConstants::megaByte));
344+
uint64_t expectedSize = std::max((caps.globalMemSize / 2), static_cast<uint64_t>(128ULL * MemoryConstants::megaByte));
345345
expectedSize = std::min(expectedSize, hwCaps.maxMemAllocSize);
346346

347347
EXPECT_EQ(caps.maxMemAllocSize, expectedSize);

0 commit comments

Comments
 (0)