Skip to content

Commit

Permalink
Test IMAGE1D_BUFFER in more scenario (#1806)
Browse files Browse the repository at this point in the history
* cl_copy_images

* cl_get_info

* cl_fill_image

* cl_read_write_image

* kernel_image_methods

* IMAGE1D_BUFFER cannot be created with (USE_|ALLOC_|COPY_)_HOST_PTR

* do not allow mipmap with 1D buffer

* adjust M to be within maximum_sizes and max_pixels

* remove unused variables

* make sure M will never be 0

* fix region[0] after refactoring removing mipmap

* fix formatting

* format with clang-format-11

* fix image1d_buffer creation with gEnablePitch

* add missing case in switch

* use align_malloc when CL version is at least 2.0

* use CL_DEVICE_NUMERIC_VERSION and align_free

* fix free of pitch buffer

* fix formatting

* fix formatting

* fix data->is_aligned
  • Loading branch information
rjodinchr committed Apr 16, 2024
1 parent 7fa567c commit be8b56d
Show file tree
Hide file tree
Showing 25 changed files with 1,838 additions and 87 deletions.
15 changes: 14 additions & 1 deletion test_common/harness/imageHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,10 +769,14 @@ void get_max_sizes(

(*numberOfSizes) = 0;

if (image_type == CL_MEM_OBJECT_IMAGE1D)
if (image_type == CL_MEM_OBJECT_IMAGE1D
|| image_type == CL_MEM_OBJECT_IMAGE1D_BUFFER)
{

size_t M = maximum_sizes[0];
size_t A = max_pixels;

M = static_cast<size_t>(fmax(1, fmin(A / M, M)));

// Store the size
sizes[(*numberOfSizes)][0] = M;
Expand Down Expand Up @@ -860,6 +864,7 @@ void get_max_sizes(
{
switch (image_type)
{
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
case CL_MEM_OBJECT_IMAGE1D:
log_info(" size[%d] = [%zu] (%g MB image)\n", j, sizes[j][0],
raw_pixel_size * sizes[j][0] * sizes[j][1]
Expand Down Expand Up @@ -1080,6 +1085,7 @@ cl_ulong get_image_size(image_descriptor const *imageInfo)
{
switch (imageInfo->type)
{
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
case CL_MEM_OBJECT_IMAGE1D: imageSize = imageInfo->rowPitch; break;
case CL_MEM_OBJECT_IMAGE2D:
imageSize = imageInfo->height * imageInfo->rowPitch;
Expand Down Expand Up @@ -2317,6 +2323,7 @@ int debug_find_vector_in_image(void *imagePtr, image_descriptor *imageInfo,

switch (imageInfo->type)
{
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
case CL_MEM_OBJECT_IMAGE1D:
width = (imageInfo->width >> lod) ? (imageInfo->width >> lod) : 1;
height = 1;
Expand Down Expand Up @@ -3513,6 +3520,7 @@ void copy_image_data(image_descriptor *srcImageInfo,

switch (srcImageInfo->type)
{
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
case CL_MEM_OBJECT_IMAGE1D:
src_lod = sourcePos[1];
sourcePos_lod[1] = sourcePos_lod[2] = 0;
Expand Down Expand Up @@ -3558,6 +3566,7 @@ void copy_image_data(image_descriptor *srcImageInfo,
size_t dst_height_lod = 1 /*dstImageInfo->height*/;
switch (dstImageInfo->type)
{
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
case CL_MEM_OBJECT_IMAGE1D:
dst_lod = destPos[1];
destPos_lod[1] = destPos_lod[2] = 0;
Expand Down Expand Up @@ -4022,6 +4031,7 @@ cl_ulong compute_mipmapped_image_size(image_descriptor imageInfo)
retSize += (cl_ulong)curr_width * curr_height
* get_pixel_size(imageInfo.format);
break;
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
case CL_MEM_OBJECT_IMAGE1D:
retSize +=
(cl_ulong)curr_width * get_pixel_size(imageInfo.format);
Expand All @@ -4043,6 +4053,7 @@ cl_ulong compute_mipmapped_image_size(image_descriptor imageInfo)
case CL_MEM_OBJECT_IMAGE2D:
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
curr_height = curr_height >> 1 ? curr_height >> 1 : 1;
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
case CL_MEM_OBJECT_IMAGE1D:
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
curr_width = curr_width >> 1 ? curr_width >> 1 : 1;
Expand Down Expand Up @@ -4080,6 +4091,7 @@ size_t compute_mip_level_offset(image_descriptor *imageInfo, size_t lod)
retOffset +=
(size_t)width * height * get_pixel_size(imageInfo->format);
break;
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
case CL_MEM_OBJECT_IMAGE1D:
retOffset += (size_t)width * get_pixel_size(imageInfo->format);
break;
Expand All @@ -4092,6 +4104,7 @@ size_t compute_mip_level_offset(image_descriptor *imageInfo, size_t lod)
case CL_MEM_OBJECT_IMAGE2D:
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
height = (height >> 1) ? (height >> 1) : 1;
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
case CL_MEM_OBJECT_IMAGE1D: width = (width >> 1) ? (width >> 1) : 1;
}
Expand Down
1 change: 1 addition & 0 deletions test_conformance/images/clCopyImage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set(${MODULE_NAME}_SOURCES
test_copy_2D_array.cpp
test_copy_3D.cpp
test_copy_3D_2D_array.cpp
test_copy_1D_buffer.cpp
test_copy_generic.cpp
test_loops.cpp
../common.cpp
Expand Down
31 changes: 20 additions & 11 deletions test_conformance/images/clCopyImage/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ int test_3D(cl_device_id device, cl_context context, cl_command_queue queue, int
{
return test_image_set( device, context, queue, k3D );
}
int test_1Dbuffer(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements)
{
return test_image_set(device, context, queue, k1DBuffer);
}
int test_1DTo1Dbuffer(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements)
{
return test_image_set(device, context, queue, k1DTo1DBuffer);
}
int test_1DbufferTo1D(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements)
{
return test_image_set(device, context, queue, k1DBufferTo1D);
}
int test_1Darray(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
{
return test_image_set( device, context, queue, k1DArray );
Expand Down Expand Up @@ -79,17 +94,11 @@ int test_3Dto2Darray(cl_device_id device, cl_context context, cl_command_queue q
}

test_definition test_list[] = {
ADD_TEST( 1D ),
ADD_TEST( 2D ),
ADD_TEST( 3D ),
ADD_TEST( 1Darray ),
ADD_TEST( 2Darray ),
ADD_TEST( 2Dto3D ),
ADD_TEST( 3Dto2D ),
ADD_TEST( 2Darrayto2D ),
ADD_TEST( 2Dto2Darray ),
ADD_TEST( 2Darrayto3D ),
ADD_TEST( 3Dto2Darray ),
ADD_TEST(1D), ADD_TEST(2D), ADD_TEST(3D),
ADD_TEST(1Darray), ADD_TEST(2Darray), ADD_TEST(2Dto3D),
ADD_TEST(3Dto2D), ADD_TEST(2Darrayto2D), ADD_TEST(2Dto2Darray),
ADD_TEST(2Darrayto3D), ADD_TEST(3Dto2Darray), ADD_TEST(1Dbuffer),
ADD_TEST(1DTo1Dbuffer), ADD_TEST(1DbufferTo1D),
};

const int test_num = ARRAY_SIZE( test_list );
Expand Down
Loading

0 comments on commit be8b56d

Please sign in to comment.