Cap CL_DEVICE_MAX_MEM_ALLOC_SIZE to SIZE_MAX (#1501)

* Fix enqueue_flags test to use correct barrier type.

Currently, enqueue_flags test uses CLK_LOCAL_MEM_FENCE.
Use CLK_GLOBAL_MEM_FENCE instead as all threads across work-groups
need to wait here.

* Add check for support for Read-Wrie images

Read-Write images have required OpenCL 2.x.
Read-Write image tests are already being skipped
for 1.x devices.
With OpenCL 3.0, read-write images being optional,
the tests should be run or skipped
depending on the implementation support.

Add a check to decide if Read-Write images are
supported or required to be supported depending
on OpenCL version and decide if the tests should
be run on skipped.

Fixes issue #894

* Fix formatting in case of Read-Write image checks.

Fix formatting in case of Read-write image checks.
Also, combine two ifs into one in case of
kerne_read_write tests

* Fix some more formatting for RW-image checks

Remove unnecessary spaces at various places.
Also, fix lengthy lines.

* Fix malloc-size calculation in test imagedim

unsigned char size is silently assumed to be 1
in imagedim test of test_basic.
Pass sizeof(type) in malloc size calculation.
Also, change loop variable from signed to unsigned.
Add checks for null pointer for malloced memory.

* Cap CL_DEVICE_MAX_MEM_ALLOC_SIZE to SIZE_MAX

Cap CL_DEVICE_MAX_MEM_ALLOC_SIZE to SIZE_MAX
when CL_DEVICE_GLOBAL_MEM_SIZE is capped with SIZE_MAX.
test_allocation caps the value of GLOBAL_MEM_SIZE to SIZE_MAX
if it exceeds the value of SIZE_MAX(value depends on platform bitness),
but doesn’t modify MAX_ALLOC_SIZE the same way.
Due to this MAX_ALLOC_SIZE becomes greater than GLOBAL_MEM_SIZE
and the test fails.

Modify MAX_MEM_ALLOC_SIZE as GLOBAL_MEM_SIZE when it exceeds SIZE_MAX

OpenCL-CTS #1022
This commit is contained in:
Nikhil Joshi
2022-10-04 21:43:18 +05:30
committed by GitHub
parent 6659a1b6b8
commit 07b055cd68
31 changed files with 32 additions and 0 deletions

View File

@@ -113,6 +113,7 @@ int test_copy_image_set_1D( cl_device_id device, cl_context context, cl_command_
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )

View File

@@ -118,6 +118,7 @@ int test_copy_image_set_1D_array( cl_device_id device, cl_context context, cl_co
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )

View File

@@ -125,6 +125,7 @@ int test_copy_image_set_2D( cl_device_id device, cl_context context, cl_command_
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )

View File

@@ -224,6 +224,7 @@ int test_copy_image_set_2D_2D_array( cl_device_id device, cl_context context, cl
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )

View File

@@ -230,6 +230,7 @@ int test_copy_image_set_2D_3D( cl_device_id device, cl_context context, cl_comma
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )

View File

@@ -71,6 +71,7 @@ int test_copy_image_set_2D_array( cl_device_id device, cl_context context, cl_co
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )

View File

@@ -57,6 +57,7 @@ int test_copy_image_set_3D( cl_device_id device, cl_context context, cl_command_
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )

View File

@@ -251,6 +251,7 @@ int test_copy_image_set_3D_2D_array(cl_device_id device, cl_context context, cl_
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )

View File

@@ -80,6 +80,7 @@ int test_fill_image_set_1D( cl_device_id device, cl_context context, cl_command_
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if ( gTestSmallImages ) if ( gTestSmallImages )

View File

@@ -83,6 +83,7 @@ int test_fill_image_set_1D_array( cl_device_id device, cl_context context, cl_co
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if ( gTestSmallImages ) if ( gTestSmallImages )

View File

@@ -83,6 +83,7 @@ int test_fill_image_set_2D( cl_device_id device, cl_context context, cl_command_
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if ( gTestSmallImages ) if ( gTestSmallImages )

View File

@@ -87,6 +87,7 @@ int test_fill_image_set_2D_array( cl_device_id device, cl_context context, cl_co
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if ( gTestSmallImages ) if ( gTestSmallImages )

View File

@@ -87,6 +87,7 @@ int test_fill_image_set_3D( cl_device_id device, cl_context context, cl_command_
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if ( gTestSmallImages ) if ( gTestSmallImages )

View File

@@ -46,6 +46,7 @@ int test_get_image_info_1D( cl_device_id device, cl_context context, cl_image_fo
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )

View File

@@ -44,6 +44,7 @@ int test_get_image_info_1D_array( cl_device_id device, cl_context context, cl_im
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )
@@ -168,6 +169,7 @@ int test_get_image_info_2D_array( cl_device_id device, cl_context context, cl_im
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )

View File

@@ -285,6 +285,7 @@ int test_get_image_info_2D( cl_device_id device, cl_context context, cl_image_fo
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )

View File

@@ -47,6 +47,7 @@ int test_get_image_info_3D( cl_device_id device, cl_context context, cl_image_fo
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )

View File

@@ -187,6 +187,7 @@ int test_read_image_set_1D(cl_device_id device, cl_context context,
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )

View File

@@ -191,6 +191,7 @@ int test_read_image_set_1D_array(cl_device_id device, cl_context context,
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )

View File

@@ -194,6 +194,7 @@ int test_read_image_set_2D(cl_device_id device, cl_context context,
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )

View File

@@ -169,6 +169,7 @@ int test_read_image_set_2D_array(cl_device_id device, cl_context context,
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )

View File

@@ -174,6 +174,7 @@ int test_read_image_set_3D(cl_device_id device, cl_context context,
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )

View File

@@ -171,6 +171,7 @@ int test_get_image_info_1D(cl_device_id device, cl_context context,
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )

View File

@@ -181,6 +181,7 @@ int test_get_image_info_1D_array(cl_device_id device, cl_context context,
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )

View File

@@ -232,6 +232,7 @@ int test_get_image_info_2D(cl_device_id device, cl_context context,
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
if( gTestSmallImages ) if( gTestSmallImages )

View File

@@ -215,6 +215,7 @@ int test_read_image_set_2D(cl_device_id device, cl_context context,
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
// Determine types // Determine types

View File

@@ -215,6 +215,7 @@ int test_read_image_set_1D(cl_device_id device, cl_context context,
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
// Determine types // Determine types

View File

@@ -214,6 +214,7 @@ int test_read_image_set_1D_array(cl_device_id device, cl_context context,
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
// Determine types // Determine types

View File

@@ -219,6 +219,7 @@ int test_read_image_set_1D_buffer(cl_device_id device, cl_context context,
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
// note: image_buffer test uses image1D for results validation. // note: image_buffer test uses image1D for results validation.

View File

@@ -202,6 +202,7 @@ int test_read_image_set_2D_array(cl_device_id device, cl_context context,
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
// Determine types // Determine types

View File

@@ -206,6 +206,7 @@ int test_read_image_set_3D(cl_device_id device, cl_context context,
if (memSize > (cl_ulong)SIZE_MAX) { if (memSize > (cl_ulong)SIZE_MAX) {
memSize = (cl_ulong)SIZE_MAX; memSize = (cl_ulong)SIZE_MAX;
maxAllocSize = (cl_ulong)SIZE_MAX;
} }
// Determine types // Determine types