Fixes for Image_from_buffer_alignment_negative when alignments are 1 (#1971)

The Image_from_buffer_alignment_negative test creates images with
incorrect pitches by adding 1 and tests whether the image creation
fails.

Devices that return 1 for either of
CL_IMAGE_REQUIREMENTS_ROW_PITCH_ALIGNMENT_EXT,
CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT or
CL_IMAGE_REQUIREMENTS_BASE_ADDRESS_ALIGNMENT_EXT will successfully
create the image and therefore fail the test.

This change allows to skip the image creation in this case as the error
condition (pitch % pitch_alignment != 0) will not be triggered for these
devices.
This commit is contained in:
Ahmed
2024-06-18 17:40:14 +01:00
committed by GitHub
parent c8f91c5ead
commit b3c89ebde0

View File

@@ -494,10 +494,11 @@ int image_from_buffer_alignment_negative(cl_device_id device,
test_error(err, "Unable to create buffer"); test_error(err, "Unable to create buffer");
/* Test Row pitch images */ /* Test Row pitch images */
if (imageType == CL_MEM_OBJECT_IMAGE2D if ((imageType == CL_MEM_OBJECT_IMAGE2D
|| imageType == CL_MEM_OBJECT_IMAGE3D || imageType == CL_MEM_OBJECT_IMAGE3D
|| imageType == CL_MEM_OBJECT_IMAGE1D_ARRAY || imageType == CL_MEM_OBJECT_IMAGE1D_ARRAY
|| imageType == CL_MEM_OBJECT_IMAGE2D_ARRAY) || imageType == CL_MEM_OBJECT_IMAGE2D_ARRAY)
&& row_pitch_alignment != 1)
{ {
image_desc.buffer = buffer; image_desc.buffer = buffer;
image_desc.image_row_pitch = image_desc.image_row_pitch =
@@ -510,8 +511,9 @@ int image_from_buffer_alignment_negative(cl_device_id device,
} }
/* Test Slice pitch images */ /* Test Slice pitch images */
if (imageType == CL_MEM_OBJECT_IMAGE3D if ((imageType == CL_MEM_OBJECT_IMAGE3D
|| imageType == CL_MEM_OBJECT_IMAGE2D_ARRAY) || imageType == CL_MEM_OBJECT_IMAGE2D_ARRAY)
&& slice_pitch_alignment != 1)
{ {
image_desc.buffer = buffer; image_desc.buffer = buffer;
image_desc.image_row_pitch = row_pitch; image_desc.image_row_pitch = row_pitch;
@@ -524,11 +526,14 @@ int image_from_buffer_alignment_negative(cl_device_id device,
"Unexpected clCreateImage return"); "Unexpected clCreateImage return");
} }
/* Test buffer from host ptr to test base address alignment */ if (base_address_alignment != 1)
{
/* Test buffer from host ptr to test base address alignment
*/
const size_t aligned_buffer_size = const size_t aligned_buffer_size =
aligned_size(buffer_size, base_address_alignment); aligned_size(buffer_size, base_address_alignment);
/* Create buffer with host ptr and additional size for the wrong /* Create buffer with host ptr and additional size for the
* alignment */ * wrong alignment */
void* const host_ptr = void* const host_ptr =
malloc(aligned_buffer_size + base_address_alignment); malloc(aligned_buffer_size + base_address_alignment);
void* non_aligned_host_ptr = void* non_aligned_host_ptr =
@@ -549,12 +554,12 @@ int image_from_buffer_alignment_negative(cl_device_id device,
"Unexpected clCreateImage return"); "Unexpected clCreateImage return");
free(host_ptr); free(host_ptr);
err = clReleaseMemObject(buffer_host);
test_error(err, "Unable to release buffer");
}
err = clReleaseMemObject(buffer); err = clReleaseMemObject(buffer);
test_error(err, "Unable to release buffer"); test_error(err, "Unable to release buffer");
err = clReleaseMemObject(buffer_host);
test_error(err, "Unable to release buffer");
} }
} }
} }