From e25bbf1ce2291d9488a0175c0ca630ec41db822d Mon Sep 17 00:00:00 2001 From: Grzegorz Wawiorko <35483345+gwawiork@users.noreply.github.com> Date: Mon, 18 Mar 2019 11:00:02 +0100 Subject: [PATCH] Khronos Bug 15347 fix for the same issue in the compatibility tests (#80) --- .../test_conformance/api/test_api_min_max.c | 28 +++++++++++++------ .../test_conformance/basic/test_constant.c | 10 ++++++- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/test_conformance/compatibility/test_conformance/api/test_api_min_max.c b/test_conformance/compatibility/test_conformance/api/test_api_min_max.c index 4dbdc9f6..bfbb2e87 100644 --- a/test_conformance/compatibility/test_conformance/api/test_api_min_max.c +++ b/test_conformance/compatibility/test_conformance/api/test_api_min_max.c @@ -493,29 +493,33 @@ int test_min_max_mem_alloc_size(cl_device_id deviceID, cl_context context, cl_co error = clGetDeviceInfo( deviceID, CL_DEVICE_GLOBAL_MEM_SIZE, 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; } - if( maxAllocSize < memSize / 4 ) + 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 1/4 of total memory! (%llu or %lluMB, from a total mem size of %lluMB)\n", maxAllocSize, (maxAllocSize / 1024)/1024, (memSize / 1024)/1024 ); + 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), memSize, memSize/(1024.0*1024.0)); + maxAllocSize, maxAllocSize/(1024.0*1024.0), requiredAllocSize, requiredAllocSize/(1024.0*1024.0)); if ( memSize < maxAllocSize ) { log_info("Global memory size is less than max allocation size, using that.\n"); maxAllocSize = memSize; - } - if ( maxAllocSize > (cl_ulong)4 * 1024 * 1024 * 1024) { - log_info("Limiting max allocation size to 4GB for test.\n"); - maxAllocSize = (cl_ulong)4 * 1024 * 1024 * 1024; } minSizeToTry = maxAllocSize/16; @@ -1298,7 +1302,7 @@ int test_min_max_constant_buffer_size(cl_device_id deviceID, cl_context context, clMemWrapper streams[3]; size_t threads[1], localThreads[1]; cl_int *constantData, *resultData; - cl_ulong maxSize, stepSize, currentSize; + cl_ulong maxSize, stepSize, currentSize, maxGlobalSize, maxAllocSize; int i; cl_event event; cl_int event_status; @@ -1316,6 +1320,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); + error = clGetDeviceInfo(deviceID, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(maxGlobalSize), &maxGlobalSize, 0); + test_error(error, "Unable to get CL_DEVICE_GLOBAL_MEM_SIZE"); + if (maxSize > maxGlobalSize / 8) + maxSize = maxGlobalSize / 8; + error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_MEM_ALLOC_SIZE , sizeof(maxAllocSize), &maxAllocSize, 0); + test_error(error, "Unable to get CL_DEVICE_MAX_MEM_ALLOC_SIZE "); + if (maxSize > maxAllocSize) + maxSize = maxAllocSize; /* Create a kernel to test with */ if( create_single_kernel_helper( context, &program, &kernel, 1, sample_const_arg_kernel, "sample_test" ) != 0 ) { diff --git a/test_conformance/compatibility/test_conformance/basic/test_constant.c b/test_conformance/compatibility/test_conformance/basic/test_constant.c index 236c6430..27bff01f 100644 --- a/test_conformance/compatibility/test_conformance/basic/test_constant.c +++ b/test_conformance/compatibility/test_conformance/basic/test_constant.c @@ -99,7 +99,7 @@ test_constant(cl_device_id device, cl_context context, cl_command_queue queue, i size_t global_threads[3]; int err; unsigned int i; - cl_ulong maxSize; + cl_ulong maxSize, maxGlobalSize, maxAllocSize; size_t num_floats, num_ints, constant_values; MTdata d; RoundingMode oldRoundMode; @@ -110,6 +110,14 @@ test_constant(cl_device_id device, cl_context context, cl_command_queue queue, i test_error( err, "Unable to get max constant buffer size" ); log_info("Device reports CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE %llu bytes.\n", maxSize); + err = clGetDeviceInfo(device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(maxGlobalSize), &maxGlobalSize, 0); + test_error(err, "Unable to get CL_DEVICE_GLOBAL_MEM_SIZE"); + if (maxSize > maxGlobalSize / 4) + maxSize = maxGlobalSize / 4; + err = clGetDeviceInfo(device, CL_DEVICE_MAX_MEM_ALLOC_SIZE , sizeof(maxAllocSize), &maxAllocSize, 0); + test_error(err, "Unable to get CL_DEVICE_MAX_MEM_ALLOC_SIZE "); + if (maxSize > maxAllocSize) + maxSize = maxAllocSize; maxSize/=4; num_ints = (size_t)maxSize/sizeof(cl_int); num_floats = (size_t)maxSize/sizeof(cl_float);