Limit buffers sizes to leave some memory for the platform (#1172)

Some conformance tests use directly the size returned by the runtime
for max memory size to allocate buffers.
This doesn't leave enough memory for the system to run the tests.
This commit is contained in:
arm-wk
2024-08-06 17:32:08 +01:00
committed by GitHub
parent 995e46590e
commit f47354680f
10 changed files with 186 additions and 170 deletions

View File

@@ -188,27 +188,15 @@ int allocate_size(cl_context context, cl_command_queue *queue,
// one we don't end up returning a garbage value
*number_of_mems = 0;
error = clGetDeviceInfo(device_id, CL_DEVICE_MAX_MEM_ALLOC_SIZE,
sizeof(max_individual_allocation_size),
&max_individual_allocation_size, NULL);
test_error_abort(error,
"clGetDeviceInfo failed for CL_DEVICE_MAX_MEM_ALLOC_SIZE");
error = clGetDeviceInfo(device_id, CL_DEVICE_GLOBAL_MEM_SIZE,
sizeof(global_mem_size), &global_mem_size, NULL);
test_error_abort(error,
"clGetDeviceInfo failed for CL_DEVICE_GLOBAL_MEM_SIZE");
max_individual_allocation_size =
get_device_info_max_mem_alloc_size(device_id);
global_mem_size = get_device_info_global_mem_size(device_id);
if (global_mem_size > (cl_ulong)SIZE_MAX)
{
global_mem_size = (cl_ulong)SIZE_MAX;
}
// log_info("Device reports CL_DEVICE_MAX_MEM_ALLOC_SIZE=%llu bytes (%gMB),
// CL_DEVICE_GLOBAL_MEM_SIZE=%llu bytes (%gMB).\n",
// max_individual_allocation_size,
// toMB(max_individual_allocation_size), global_mem_size,
// toMB(global_mem_size));
if (size_to_allocate > global_mem_size)
{
log_error("Can not allocate more than the global memory size.\n");