cl20: Khronos Bug 16080 Fix local work size limit.

Problem: Some tests assume that all local work-items can be used in a
single dimension of an NDRange.

Spec References: OpenCL C 2.0 r19, table 4.3,
CL_DEVICE_MAX_WORK_ITEM_SIZES.

Solution: The overall maximum local work size is trimmed to that of an
NDRange's first dimension or all dimensions, as appropriate.

Test Suite Affected: atomics, non_uniform_work_group, and workgroups.

Side Effects: None

Change-Id: I2e8179ca15c2c090f47ea84d1d3c109dd69ec185
This commit is contained in:
Samuel Pauls
2016-10-05 18:49:15 -04:00
committed by Kévin Petit
parent e0d7ab2187
commit 627c180a31
12 changed files with 129 additions and 72 deletions

View File

@@ -968,6 +968,46 @@ int get_max_allowed_work_group_size( cl_context context, cl_kernel kernel, size_
}
extern int get_max_allowed_1d_work_group_size_on_device( cl_device_id device, cl_kernel kernel, size_t *outSize )
{
cl_uint maxDim;
size_t maxWgSize;
size_t *maxWgSizePerDim;
int error;
error = clGetKernelWorkGroupInfo( kernel, device, CL_KERNEL_WORK_GROUP_SIZE, sizeof( size_t ), &maxWgSize, NULL );
test_error( error, "clGetKernelWorkGroupInfo CL_KERNEL_WORK_GROUP_SIZE failed" );
error = clGetDeviceInfo( device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof( cl_uint ), &maxDim, NULL );
test_error( error, "clGetDeviceInfo CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS failed" );
maxWgSizePerDim = (size_t*)malloc( maxDim * sizeof( size_t ) );
if( !maxWgSizePerDim )
{
log_error( "Unable to allocate maxWgSizePerDim\n" );
return -1;
}
error = clGetDeviceInfo( device, CL_DEVICE_MAX_WORK_ITEM_SIZES, maxDim * sizeof( size_t ), maxWgSizePerDim, NULL );
if( error != CL_SUCCESS)
{
log_error( "clGetDeviceInfo CL_DEVICE_MAX_WORK_ITEM_SIZES failed\n" );
free( maxWgSizePerDim );
return error;
}
// "maxWgSize" is limited to that of the first dimension.
if( maxWgSize > maxWgSizePerDim[0] )
{
maxWgSize = maxWgSizePerDim[0];
}
free( maxWgSizePerDim );
*outSize = maxWgSize;
return 0;
}
int get_max_common_work_group_size( cl_context context, cl_kernel kernel,
size_t globalThreadSize, size_t *outMaxSize )
{

View File

@@ -120,6 +120,9 @@ extern int get_device_version( cl_device_id id, size_t* major, size_t* minor);
/* Helper to obtain the biggest allowed work group size for all the devices in a given group */
extern int get_max_allowed_work_group_size( cl_context context, cl_kernel kernel, size_t *outSize, size_t *outLimits );
/* Helper to obtain the biggest allowed 1D work group size on a given device */
extern int get_max_allowed_1d_work_group_size_on_device( cl_device_id device, cl_kernel kernel, size_t *outSize );
/* Helper to determine if an extension is supported by a device */
extern int is_extension_available( cl_device_id device, const char *extensionName );