mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +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;
|
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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -48,4 +48,16 @@ std::string get_device_name(cl_device_id device);
|
|||||||
// Returns the maximum size in bytes for Kernel Parameters
|
// Returns the maximum size in bytes for Kernel Parameters
|
||||||
size_t get_max_param_size(cl_device_id device);
|
size_t get_max_param_size(cl_device_id device);
|
||||||
|
|
||||||
|
/* We need to use a portion of available alloc size,
|
||||||
|
* divide it to leave some memory for the platform. */
|
||||||
|
#define MAX_DEVICE_MEMORY_SIZE_DIVISOR (2)
|
||||||
|
|
||||||
|
/* Get max allocation size. */
|
||||||
|
cl_ulong get_device_info_max_mem_alloc_size(cl_device_id device,
|
||||||
|
unsigned int divisor = 1);
|
||||||
|
cl_ulong get_device_info_global_mem_size(cl_device_id device,
|
||||||
|
unsigned int divisor = 1);
|
||||||
|
cl_ulong get_device_info_max_constant_buffer_size(cl_device_id device,
|
||||||
|
unsigned int divisor = 1);
|
||||||
|
|
||||||
#endif // _deviceInfo_h
|
#endif // _deviceInfo_h
|
||||||
|
|||||||
@@ -188,27 +188,15 @@ int allocate_size(cl_context context, cl_command_queue *queue,
|
|||||||
// one we don't end up returning a garbage value
|
// one we don't end up returning a garbage value
|
||||||
*number_of_mems = 0;
|
*number_of_mems = 0;
|
||||||
|
|
||||||
error = clGetDeviceInfo(device_id, CL_DEVICE_MAX_MEM_ALLOC_SIZE,
|
max_individual_allocation_size =
|
||||||
sizeof(max_individual_allocation_size),
|
get_device_info_max_mem_alloc_size(device_id);
|
||||||
&max_individual_allocation_size, NULL);
|
global_mem_size = get_device_info_global_mem_size(device_id);
|
||||||
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");
|
|
||||||
|
|
||||||
if (global_mem_size > (cl_ulong)SIZE_MAX)
|
if (global_mem_size > (cl_ulong)SIZE_MAX)
|
||||||
{
|
{
|
||||||
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)
|
if (size_to_allocate > global_mem_size)
|
||||||
{
|
{
|
||||||
log_error("Can not allocate more than the global memory size.\n");
|
log_error("Can not allocate more than the global memory size.\n");
|
||||||
|
|||||||
@@ -24,8 +24,10 @@
|
|||||||
|
|
||||||
typedef long long unsigned llu;
|
typedef long long unsigned llu;
|
||||||
|
|
||||||
|
#define REDUCTION_PERCENTAGE_DEFAULT 50
|
||||||
|
|
||||||
int g_repetition_count = 1;
|
int g_repetition_count = 1;
|
||||||
int g_reduction_percentage = 100;
|
int g_reduction_percentage = REDUCTION_PERCENTAGE_DEFAULT;
|
||||||
int g_write_allocations = 1;
|
int g_write_allocations = 1;
|
||||||
int g_multiple_allocations = 0;
|
int g_multiple_allocations = 0;
|
||||||
int g_execute_kernel = 1;
|
int g_execute_kernel = 1;
|
||||||
@@ -44,24 +46,9 @@ test_status init_cl(cl_device_id device)
|
|||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = clGetDeviceInfo(device, CL_DEVICE_MAX_MEM_ALLOC_SIZE,
|
g_max_individual_allocation_size =
|
||||||
sizeof(g_max_individual_allocation_size),
|
get_device_info_max_mem_alloc_size(device);
|
||||||
&g_max_individual_allocation_size, NULL);
|
g_global_mem_size = get_device_info_global_mem_size(device);
|
||||||
if (error)
|
|
||||||
{
|
|
||||||
print_error(error,
|
|
||||||
"clGetDeviceInfo failed for CL_DEVICE_MAX_MEM_ALLOC_SIZE");
|
|
||||||
return TEST_FAIL;
|
|
||||||
}
|
|
||||||
error =
|
|
||||||
clGetDeviceInfo(device, CL_DEVICE_GLOBAL_MEM_SIZE,
|
|
||||||
sizeof(g_global_mem_size), &g_global_mem_size, NULL);
|
|
||||||
if (error)
|
|
||||||
{
|
|
||||||
print_error(error,
|
|
||||||
"clGetDeviceInfo failed for CL_DEVICE_GLOBAL_MEM_SIZE");
|
|
||||||
return TEST_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
log_info("Device reports CL_DEVICE_MAX_MEM_ALLOC_SIZE=%llu bytes (%gMB), "
|
log_info("Device reports CL_DEVICE_MAX_MEM_ALLOC_SIZE=%llu bytes (%gMB), "
|
||||||
"CL_DEVICE_GLOBAL_MEM_SIZE=%llu bytes (%gMB).\n",
|
"CL_DEVICE_GLOBAL_MEM_SIZE=%llu bytes (%gMB).\n",
|
||||||
|
|||||||
@@ -112,6 +112,8 @@ const char *sample_const_max_arg_kernel_pattern =
|
|||||||
"\n"
|
"\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
|
#define MAX_REDUCTION_FACTOR 4
|
||||||
|
|
||||||
int test_min_max_thread_dimensions(cl_device_id deviceID, cl_context context,
|
int test_min_max_thread_dimensions(cl_device_id deviceID, cl_context context,
|
||||||
cl_command_queue queue, int num_elements)
|
cl_command_queue queue, int num_elements)
|
||||||
{
|
{
|
||||||
@@ -564,7 +566,7 @@ int test_min_max_mem_alloc_size(cl_device_id deviceID, cl_context context,
|
|||||||
cl_command_queue queue, int num_elements)
|
cl_command_queue queue, int num_elements)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
cl_ulong maxAllocSize, memSize, minSizeToTry;
|
cl_ulong maxAllocSize, memSize, minSizeToTry, currentSize;
|
||||||
clMemWrapper memHdl;
|
clMemWrapper memHdl;
|
||||||
|
|
||||||
cl_ulong requiredAllocSize;
|
cl_ulong requiredAllocSize;
|
||||||
@@ -574,56 +576,12 @@ int test_min_max_mem_alloc_size(cl_device_id deviceID, cl_context context,
|
|||||||
else
|
else
|
||||||
requiredAllocSize = 128 * 1024 * 1024;
|
requiredAllocSize = 128 * 1024 * 1024;
|
||||||
|
|
||||||
/* Get the max mem alloc size */
|
/* Get the max mem alloc size, limit the alloc to half of the available
|
||||||
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_MEM_ALLOC_SIZE,
|
* memory */
|
||||||
sizeof(maxAllocSize), &maxAllocSize, NULL);
|
maxAllocSize = get_device_info_max_mem_alloc_size(
|
||||||
test_error(error, "Unable to get max mem alloc size from device");
|
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
|
memSize = get_device_info_global_mem_size(deviceID,
|
||||||
error = clGetDeviceInfo(deviceID, CL_DEVICE_GLOBAL_MEM_SIZE,
|
MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
sizeof(memSize), &memSize, NULL);
|
|
||||||
test_error(error, "Unable to get global memory size from device");
|
|
||||||
|
|
||||||
if (memSize > (cl_ulong)SIZE_MAX)
|
|
||||||
{
|
|
||||||
memSize = (cl_ulong)SIZE_MAX;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxAllocSize < requiredAllocSize)
|
|
||||||
{
|
|
||||||
log_error("ERROR: Reported max allocation size is less than required "
|
|
||||||
"%lldMB! (%llu or %lluMB, from a total mem size of %lldMB)\n",
|
|
||||||
(requiredAllocSize / 1024) / 1024, maxAllocSize,
|
|
||||||
(maxAllocSize / 1024) / 1024, (memSize / 1024) / 1024);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
requiredAllocSize = ((memSize / 4) > (1024 * 1024 * 1024))
|
|
||||||
? 1024 * 1024 * 1024
|
|
||||||
: memSize / 4;
|
|
||||||
|
|
||||||
if (gIsEmbedded)
|
|
||||||
requiredAllocSize = (requiredAllocSize < 1 * 1024 * 1024)
|
|
||||||
? 1 * 1024 * 1024
|
|
||||||
: requiredAllocSize;
|
|
||||||
else
|
|
||||||
requiredAllocSize = (requiredAllocSize < 128 * 1024 * 1024)
|
|
||||||
? 128 * 1024 * 1024
|
|
||||||
: requiredAllocSize;
|
|
||||||
|
|
||||||
if (maxAllocSize < requiredAllocSize)
|
|
||||||
{
|
|
||||||
log_error(
|
|
||||||
"ERROR: Reported max allocation size is less than required of "
|
|
||||||
"total memory! (%llu or %lluMB, from a total mem size of %lluMB)\n",
|
|
||||||
maxAllocSize, (maxAllocSize / 1024) / 1024,
|
|
||||||
(requiredAllocSize / 1024) / 1024);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
log_info("Reported max allocation size of %lld bytes (%gMB) and global mem "
|
|
||||||
"size of %lld bytes (%gMB).\n",
|
|
||||||
maxAllocSize, maxAllocSize / (1024.0 * 1024.0), requiredAllocSize,
|
|
||||||
requiredAllocSize / (1024.0 * 1024.0));
|
|
||||||
|
|
||||||
if (memSize < maxAllocSize)
|
if (memSize < maxAllocSize)
|
||||||
{
|
{
|
||||||
@@ -632,27 +590,44 @@ int test_min_max_mem_alloc_size(cl_device_id deviceID, cl_context context,
|
|||||||
maxAllocSize = memSize;
|
maxAllocSize = memSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (memSize > (cl_ulong)SIZE_MAX)
|
||||||
|
{
|
||||||
|
memSize = (cl_ulong)SIZE_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxAllocSize < requiredAllocSize)
|
||||||
|
{
|
||||||
|
log_error("ERROR: Reported max allocation size is less than required");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
log_info("Reported max allocation size of %lld bytes (%gMB) and global mem "
|
||||||
|
"size of %lld bytes (%gMB).\n",
|
||||||
|
maxAllocSize, maxAllocSize / (1024.0 * 1024.0), memSize,
|
||||||
|
memSize / (1024.0 * 1024.0));
|
||||||
|
|
||||||
minSizeToTry = maxAllocSize / 16;
|
minSizeToTry = maxAllocSize / 16;
|
||||||
while (maxAllocSize > (maxAllocSize / 4))
|
currentSize = maxAllocSize;
|
||||||
|
while (currentSize >= maxAllocSize / MAX_REDUCTION_FACTOR)
|
||||||
{
|
{
|
||||||
|
|
||||||
log_info("Trying to create a buffer of size of %lld bytes (%gMB).\n",
|
log_info("Trying to create a buffer of size of %lld bytes (%gMB).\n",
|
||||||
maxAllocSize, (double)maxAllocSize / (1024.0 * 1024.0));
|
currentSize, (double)currentSize / (1024.0 * 1024.0));
|
||||||
memHdl = clCreateBuffer(context, CL_MEM_READ_ONLY, (size_t)maxAllocSize,
|
memHdl = clCreateBuffer(context, CL_MEM_READ_ONLY, (size_t)currentSize,
|
||||||
NULL, &error);
|
NULL, &error);
|
||||||
if (error == CL_MEM_OBJECT_ALLOCATION_FAILURE
|
if (error == CL_MEM_OBJECT_ALLOCATION_FAILURE
|
||||||
|| error == CL_OUT_OF_RESOURCES || error == CL_OUT_OF_HOST_MEMORY)
|
|| error == CL_OUT_OF_RESOURCES || error == CL_OUT_OF_HOST_MEMORY)
|
||||||
{
|
{
|
||||||
log_info("\tAllocation failed at size of %lld bytes (%gMB).\n",
|
log_info("\tAllocation failed at size of %lld bytes (%gMB).\n",
|
||||||
maxAllocSize, (double)maxAllocSize / (1024.0 * 1024.0));
|
currentSize, (double)currentSize / (1024.0 * 1024.0));
|
||||||
maxAllocSize -= minSizeToTry;
|
currentSize -= minSizeToTry;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
test_error(error, "clCreateBuffer failed for maximum sized buffer.");
|
test_error(error, "clCreateBuffer failed for maximum sized buffer.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
log_error("Failed to allocate even %lld bytes (%gMB).\n", maxAllocSize,
|
log_error("Failed to allocate even %lld bytes (%gMB).\n", currentSize,
|
||||||
(double)maxAllocSize / (1024.0 * 1024.0));
|
(double)currentSize / (1024.0 * 1024.0));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -709,9 +684,8 @@ int test_min_max_image_2d_width(cl_device_id deviceID, cl_context context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Verify that we can actually allocate an image that large */
|
/* Verify that we can actually allocate an image that large */
|
||||||
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_MEM_ALLOC_SIZE,
|
maxAllocSize = get_device_info_max_mem_alloc_size(
|
||||||
sizeof(maxAllocSize), &maxAllocSize, NULL);
|
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
test_error(error, "Unable to get CL_DEVICE_MAX_MEM_ALLOC_SIZE.");
|
|
||||||
if ((cl_ulong)maxDimension * 1 * 4 > maxAllocSize)
|
if ((cl_ulong)maxDimension * 1 * 4 > maxAllocSize)
|
||||||
{
|
{
|
||||||
log_error("Can not allocate a large enough image (min size: %lld "
|
log_error("Can not allocate a large enough image (min size: %lld "
|
||||||
@@ -787,9 +761,8 @@ int test_min_max_image_2d_height(cl_device_id deviceID, cl_context context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Verify that we can actually allocate an image that large */
|
/* Verify that we can actually allocate an image that large */
|
||||||
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_MEM_ALLOC_SIZE,
|
maxAllocSize = get_device_info_max_mem_alloc_size(
|
||||||
sizeof(maxAllocSize), &maxAllocSize, NULL);
|
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
test_error(error, "Unable to get CL_DEVICE_MAX_MEM_ALLOC_SIZE.");
|
|
||||||
if ((cl_ulong)maxDimension * 1 * 4 > maxAllocSize)
|
if ((cl_ulong)maxDimension * 1 * 4 > maxAllocSize)
|
||||||
{
|
{
|
||||||
log_error("Can not allocate a large enough image (min size: %lld "
|
log_error("Can not allocate a large enough image (min size: %lld "
|
||||||
@@ -855,9 +828,8 @@ int test_min_max_image_3d_width(cl_device_id deviceID, cl_context context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Verify that we can actually allocate an image that large */
|
/* Verify that we can actually allocate an image that large */
|
||||||
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_MEM_ALLOC_SIZE,
|
maxAllocSize = get_device_info_max_mem_alloc_size(
|
||||||
sizeof(maxAllocSize), &maxAllocSize, NULL);
|
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
test_error(error, "Unable to get CL_DEVICE_MAX_MEM_ALLOC_SIZE.");
|
|
||||||
if ((cl_ulong)maxDimension * 2 * 4 > maxAllocSize)
|
if ((cl_ulong)maxDimension * 2 * 4 > maxAllocSize)
|
||||||
{
|
{
|
||||||
log_error("Can not allocate a large enough image (min size: %lld "
|
log_error("Can not allocate a large enough image (min size: %lld "
|
||||||
@@ -924,9 +896,8 @@ int test_min_max_image_3d_height(cl_device_id deviceID, cl_context context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Verify that we can actually allocate an image that large */
|
/* Verify that we can actually allocate an image that large */
|
||||||
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_MEM_ALLOC_SIZE,
|
maxAllocSize = get_device_info_max_mem_alloc_size(
|
||||||
sizeof(maxAllocSize), &maxAllocSize, NULL);
|
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
test_error(error, "Unable to get CL_DEVICE_MAX_MEM_ALLOC_SIZE.");
|
|
||||||
if ((cl_ulong)maxDimension * 2 * 4 > maxAllocSize)
|
if ((cl_ulong)maxDimension * 2 * 4 > maxAllocSize)
|
||||||
{
|
{
|
||||||
log_error("Can not allocate a large enough image (min size: %lld "
|
log_error("Can not allocate a large enough image (min size: %lld "
|
||||||
@@ -994,9 +965,8 @@ int test_min_max_image_3d_depth(cl_device_id deviceID, cl_context context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Verify that we can actually allocate an image that large */
|
/* Verify that we can actually allocate an image that large */
|
||||||
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_MEM_ALLOC_SIZE,
|
maxAllocSize = get_device_info_max_mem_alloc_size(
|
||||||
sizeof(maxAllocSize), &maxAllocSize, NULL);
|
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
test_error(error, "Unable to get CL_DEVICE_MAX_MEM_ALLOC_SIZE.");
|
|
||||||
if ((cl_ulong)maxDimension * 1 * 4 > maxAllocSize)
|
if ((cl_ulong)maxDimension * 1 * 4 > maxAllocSize)
|
||||||
{
|
{
|
||||||
log_error("Can not allocate a large enough image (min size: %lld "
|
log_error("Can not allocate a large enough image (min size: %lld "
|
||||||
@@ -1063,9 +1033,8 @@ int test_min_max_image_array_size(cl_device_id deviceID, cl_context context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Verify that we can actually allocate an image that large */
|
/* Verify that we can actually allocate an image that large */
|
||||||
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_MEM_ALLOC_SIZE,
|
maxAllocSize = get_device_info_max_mem_alloc_size(
|
||||||
sizeof(maxAllocSize), &maxAllocSize, NULL);
|
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
test_error(error, "Unable to get CL_DEVICE_MAX_MEM_ALLOC_SIZE.");
|
|
||||||
if ((cl_ulong)maxDimension * 1 * 4 > maxAllocSize)
|
if ((cl_ulong)maxDimension * 1 * 4 > maxAllocSize)
|
||||||
{
|
{
|
||||||
log_error("Can not allocate a large enough image (min size: %lld "
|
log_error("Can not allocate a large enough image (min size: %lld "
|
||||||
@@ -1105,10 +1074,9 @@ int test_min_max_image_buffer_size(cl_device_id deviceID, cl_context context,
|
|||||||
|
|
||||||
PASSIVE_REQUIRE_IMAGE_SUPPORT(deviceID);
|
PASSIVE_REQUIRE_IMAGE_SUPPORT(deviceID);
|
||||||
|
|
||||||
/* Get the max memory allocation size */
|
/* Get the max memory allocation size, divide it */
|
||||||
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_MEM_ALLOC_SIZE,
|
maxAllocSize = get_device_info_max_mem_alloc_size(
|
||||||
sizeof(maxAllocSize), &maxAllocSize, NULL);
|
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
test_error(error, "Unable to get CL_DEVICE_MAX_MEM_ALLOC_SIZE.");
|
|
||||||
|
|
||||||
/* Get the max image array width */
|
/* Get the max image array width */
|
||||||
error =
|
error =
|
||||||
@@ -1559,7 +1527,6 @@ int test_min_max_samplers(cl_device_id deviceID, cl_context context,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PASSING_FRACTION 4
|
|
||||||
int test_min_max_constant_buffer_size(cl_device_id deviceID, cl_context context,
|
int test_min_max_constant_buffer_size(cl_device_id deviceID, cl_context context,
|
||||||
cl_command_queue queue, int num_elements)
|
cl_command_queue queue, int num_elements)
|
||||||
{
|
{
|
||||||
@@ -1575,11 +1542,12 @@ int test_min_max_constant_buffer_size(cl_device_id deviceID, cl_context context,
|
|||||||
MTdata d;
|
MTdata d;
|
||||||
|
|
||||||
/* Verify our test buffer won't be bigger than allowed */
|
/* Verify our test buffer won't be bigger than allowed */
|
||||||
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE,
|
maxSize = get_device_info_max_constant_buffer_size(
|
||||||
sizeof(maxSize), &maxSize, 0);
|
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
test_error(error, "Unable to get max constant buffer size");
|
|
||||||
|
|
||||||
if ((0 == gIsEmbedded && maxSize < 64L * 1024L) || maxSize < 1L * 1024L)
|
if ((0 == gIsEmbedded
|
||||||
|
&& (maxSize * MAX_DEVICE_MEMORY_SIZE_DIVISOR) < 64L * 1024L)
|
||||||
|
|| (maxSize * MAX_DEVICE_MEMORY_SIZE_DIVISOR) < 1L * 1024L)
|
||||||
{
|
{
|
||||||
log_error("ERROR: Reported max constant buffer size less than required "
|
log_error("ERROR: Reported max constant buffer size less than required "
|
||||||
"by OpenCL 1.0 (reported %d KB)\n",
|
"by OpenCL 1.0 (reported %d KB)\n",
|
||||||
@@ -1589,16 +1557,14 @@ int test_min_max_constant_buffer_size(cl_device_id deviceID, cl_context context,
|
|||||||
|
|
||||||
log_info("Reported max constant buffer size of %lld bytes.\n", maxSize);
|
log_info("Reported max constant buffer size of %lld bytes.\n", maxSize);
|
||||||
|
|
||||||
// Limit test buffer size to 1/8 of CL_DEVICE_GLOBAL_MEM_SIZE
|
/* We have four buffers allocations */
|
||||||
error = clGetDeviceInfo(deviceID, CL_DEVICE_GLOBAL_MEM_SIZE,
|
maxGlobalSize = get_device_info_global_mem_size(
|
||||||
sizeof(maxGlobalSize), &maxGlobalSize, 0);
|
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR * 4);
|
||||||
test_error(error, "Unable to get CL_DEVICE_GLOBAL_MEM_SIZE");
|
|
||||||
|
|
||||||
if (maxSize > maxGlobalSize / 8) maxSize = maxGlobalSize / 8;
|
if (maxSize > maxGlobalSize) maxSize = maxGlobalSize;
|
||||||
|
|
||||||
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_MEM_ALLOC_SIZE,
|
maxAllocSize = get_device_info_max_mem_alloc_size(
|
||||||
sizeof(maxAllocSize), &maxAllocSize, 0);
|
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
test_error(error, "Unable to get CL_DEVICE_MAX_MEM_ALLOC_SIZE ");
|
|
||||||
|
|
||||||
if (maxSize > maxAllocSize) maxSize = maxAllocSize;
|
if (maxSize > maxAllocSize) maxSize = maxAllocSize;
|
||||||
|
|
||||||
@@ -1615,7 +1581,7 @@ int test_min_max_constant_buffer_size(cl_device_id deviceID, cl_context context,
|
|||||||
currentSize = maxSize;
|
currentSize = maxSize;
|
||||||
int allocPassed = 0;
|
int allocPassed = 0;
|
||||||
d = init_genrand(gRandomSeed);
|
d = init_genrand(gRandomSeed);
|
||||||
while (!allocPassed && currentSize >= maxSize / PASSING_FRACTION)
|
while (!allocPassed && currentSize >= maxSize / MAX_REDUCTION_FACTOR)
|
||||||
{
|
{
|
||||||
log_info("Attempting to allocate constant buffer of size %lld bytes\n",
|
log_info("Attempting to allocate constant buffer of size %lld bytes\n",
|
||||||
maxSize);
|
maxSize);
|
||||||
@@ -1741,7 +1707,7 @@ int test_min_max_constant_buffer_size(cl_device_id deviceID, cl_context context,
|
|||||||
|
|
||||||
if (allocPassed)
|
if (allocPassed)
|
||||||
{
|
{
|
||||||
if (currentSize < maxSize / PASSING_FRACTION)
|
if (currentSize < maxSize / MAX_REDUCTION_FACTOR)
|
||||||
{
|
{
|
||||||
log_error("Failed to allocate at least 1/8 of the reported "
|
log_error("Failed to allocate at least 1/8 of the reported "
|
||||||
"constant size.\n");
|
"constant size.\n");
|
||||||
@@ -1808,10 +1774,9 @@ int test_min_max_constant_args(cl_device_id deviceID, cl_context context,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE,
|
maxSize = get_device_info_max_constant_buffer_size(
|
||||||
sizeof(maxSize), &maxSize, 0);
|
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
test_error(error, "Unable to get max constant buffer size");
|
individualBufferSize = ((int)maxSize / 2) / maxArgs;
|
||||||
individualBufferSize = (maxSize / 2) / maxArgs;
|
|
||||||
|
|
||||||
log_info(
|
log_info(
|
||||||
"Reported max constant arg count of %u and max constant buffer "
|
"Reported max constant arg count of %u and max constant buffer "
|
||||||
|
|||||||
@@ -389,8 +389,8 @@ int test_set_kernel_arg_constant(cl_device_id deviceID, cl_context context, cl_c
|
|||||||
std::vector<cl_int> randomTestDataB(num_elements);
|
std::vector<cl_int> randomTestDataB(num_elements);
|
||||||
|
|
||||||
/* Verify our test buffer won't be bigger than allowed */
|
/* Verify our test buffer won't be bigger than allowed */
|
||||||
error = clGetDeviceInfo( deviceID, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, sizeof( maxSize ), &maxSize, 0 );
|
maxSize = get_device_info_max_constant_buffer_size(
|
||||||
test_error( error, "Unable to get max constant buffer size" );
|
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
if (maxSize < sizeof(cl_int) * num_elements)
|
if (maxSize < sizeof(cl_int) * num_elements)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Unable to test constant argument to kernel: max size of constant buffer is reported as %d!\n", (int)maxSize );
|
log_error( "ERROR: Unable to test constant argument to kernel: max size of constant buffer is reported as %d!\n", (int)maxSize );
|
||||||
|
|||||||
@@ -39,15 +39,20 @@ int test_get_image_info_1D( cl_device_id device, cl_context context, cl_image_fo
|
|||||||
imageInfo.format = format;
|
imageInfo.format = format;
|
||||||
pixelSize = get_pixel_size( imageInfo.format );
|
pixelSize = get_pixel_size( imageInfo.format );
|
||||||
|
|
||||||
int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
int error = clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_WIDTH,
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL );
|
sizeof(maxWidth), &maxWidth, NULL);
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof( memSize ), &memSize, NULL );
|
|
||||||
test_error( error, "Unable to get max image 1D size from device" );
|
test_error( error, "Unable to get max image 1D size from device" );
|
||||||
|
|
||||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
/* Reduce the size used by the test by half */
|
||||||
memSize = (cl_ulong)SIZE_MAX;
|
maxAllocSize = get_device_info_max_mem_alloc_size(
|
||||||
maxAllocSize = (cl_ulong)SIZE_MAX;
|
device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
}
|
memSize =
|
||||||
|
get_device_info_global_mem_size(device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
|
|
||||||
|
if (memSize > (cl_ulong)SIZE_MAX)
|
||||||
|
{
|
||||||
|
memSize = (cl_ulong)SIZE_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
if( gTestSmallImages )
|
if( gTestSmallImages )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,15 +37,20 @@ int test_get_image_info_1D_array( cl_device_id device, cl_context context, cl_im
|
|||||||
imageInfo.type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
|
imageInfo.type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
|
||||||
|
|
||||||
int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, sizeof( maxArraySize ), &maxArraySize, NULL );
|
error |= clGetDeviceInfo(device, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE,
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL );
|
sizeof(maxArraySize), &maxArraySize, NULL);
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof( memSize ), &memSize, NULL );
|
|
||||||
test_error( error, "Unable to get max image 1D array size from device" );
|
test_error( error, "Unable to get max image 1D array size from device" );
|
||||||
|
|
||||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
/* Reduce the size used by the test by half */
|
||||||
memSize = (cl_ulong)SIZE_MAX;
|
maxAllocSize = get_device_info_max_mem_alloc_size(
|
||||||
maxAllocSize = (cl_ulong)SIZE_MAX;
|
device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
}
|
memSize =
|
||||||
|
get_device_info_global_mem_size(device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
|
|
||||||
|
if (memSize > (cl_ulong)SIZE_MAX)
|
||||||
|
{
|
||||||
|
memSize = (cl_ulong)SIZE_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
if( gTestSmallImages )
|
if( gTestSmallImages )
|
||||||
{
|
{
|
||||||
@@ -162,15 +167,20 @@ int test_get_image_info_2D_array( cl_device_id device, cl_context context, cl_im
|
|||||||
|
|
||||||
int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL );
|
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL );
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, sizeof( maxArraySize ), &maxArraySize, NULL );
|
error |= clGetDeviceInfo(device, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE,
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL );
|
sizeof(maxArraySize), &maxArraySize, NULL);
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof( memSize ), &memSize, NULL );
|
|
||||||
test_error( error, "Unable to get max image 1D array size from device" );
|
test_error( error, "Unable to get max image 1D array size from device" );
|
||||||
|
|
||||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
/* Reduce the size used by the test by half */
|
||||||
memSize = (cl_ulong)SIZE_MAX;
|
maxAllocSize = get_device_info_max_mem_alloc_size(
|
||||||
maxAllocSize = (cl_ulong)SIZE_MAX;
|
device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
}
|
memSize =
|
||||||
|
get_device_info_global_mem_size(device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
|
|
||||||
|
if (memSize > (cl_ulong)SIZE_MAX)
|
||||||
|
{
|
||||||
|
memSize = (cl_ulong)SIZE_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
if( gTestSmallImages )
|
if( gTestSmallImages )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -301,15 +301,20 @@ int test_get_image_info_2D( cl_device_id device, cl_context context, cl_image_fo
|
|||||||
pixelSize = get_pixel_size( imageInfo.format );
|
pixelSize = get_pixel_size( imageInfo.format );
|
||||||
|
|
||||||
int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL );
|
error |= clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_HEIGHT,
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL );
|
sizeof(maxHeight), &maxHeight, NULL);
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof( memSize ), &memSize, NULL );
|
|
||||||
test_error( error, "Unable to get max image 2D width or max image 3D height or max memory allocation size or global memory size from device" );
|
test_error( error, "Unable to get max image 2D width or max image 3D height or max memory allocation size or global memory size from device" );
|
||||||
|
|
||||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
/* Reduce the size used by the test by half */
|
||||||
memSize = (cl_ulong)SIZE_MAX;
|
maxAllocSize = get_device_info_max_mem_alloc_size(
|
||||||
maxAllocSize = (cl_ulong)SIZE_MAX;
|
device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
}
|
memSize =
|
||||||
|
get_device_info_global_mem_size(device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
|
|
||||||
|
if (memSize > (cl_ulong)SIZE_MAX)
|
||||||
|
{
|
||||||
|
memSize = (cl_ulong)SIZE_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
if( gTestSmallImages )
|
if( gTestSmallImages )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,15 +40,20 @@ int test_get_image_info_3D( cl_device_id device, cl_context context, cl_image_fo
|
|||||||
|
|
||||||
int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL );
|
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL );
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_DEPTH, sizeof( maxDepth ), &maxDepth, NULL );
|
error |= clGetDeviceInfo(device, CL_DEVICE_IMAGE3D_MAX_DEPTH,
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL );
|
sizeof(maxDepth), &maxDepth, NULL);
|
||||||
error |= clGetDeviceInfo( device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof( memSize ), &memSize, NULL );
|
|
||||||
test_error( error, "Unable to get max image 3D size from device" );
|
test_error( error, "Unable to get max image 3D size from device" );
|
||||||
|
|
||||||
if (memSize > (cl_ulong)SIZE_MAX) {
|
/* Reduce the size used by the test by half */
|
||||||
memSize = (cl_ulong)SIZE_MAX;
|
maxAllocSize = get_device_info_max_mem_alloc_size(
|
||||||
maxAllocSize = (cl_ulong)SIZE_MAX;
|
device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
}
|
memSize =
|
||||||
|
get_device_info_global_mem_size(device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
|
||||||
|
|
||||||
|
if (memSize > (cl_ulong)SIZE_MAX)
|
||||||
|
{
|
||||||
|
memSize = (cl_ulong)SIZE_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
if( gTestSmallImages )
|
if( gTestSmallImages )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user