mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 22:19:02 +00:00
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:
@@ -132,3 +132,42 @@ size_t get_max_param_size(cl_device_id device)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static cl_ulong get_device_info_max_size(cl_device_id device,
|
||||
cl_device_info info,
|
||||
unsigned int divisor)
|
||||
{
|
||||
cl_ulong max_size;
|
||||
|
||||
if (divisor == 0)
|
||||
{
|
||||
throw std::runtime_error("Allocation divisor should not be 0\n");
|
||||
}
|
||||
|
||||
if (clGetDeviceInfo(device, info, sizeof(max_size), &max_size, NULL)
|
||||
!= CL_SUCCESS)
|
||||
{
|
||||
throw std::runtime_error("clGetDeviceInfo failed\n");
|
||||
}
|
||||
return max_size / divisor;
|
||||
}
|
||||
|
||||
cl_ulong get_device_info_max_mem_alloc_size(cl_device_id device,
|
||||
unsigned int divisor)
|
||||
{
|
||||
return get_device_info_max_size(device, CL_DEVICE_MAX_MEM_ALLOC_SIZE,
|
||||
divisor);
|
||||
}
|
||||
|
||||
cl_ulong get_device_info_global_mem_size(cl_device_id device,
|
||||
unsigned int divisor)
|
||||
{
|
||||
return get_device_info_max_size(device, CL_DEVICE_GLOBAL_MEM_SIZE, divisor);
|
||||
}
|
||||
|
||||
cl_ulong get_device_info_max_constant_buffer_size(cl_device_id device,
|
||||
unsigned int divisor)
|
||||
{
|
||||
return get_device_info_max_size(device, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE,
|
||||
divisor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user