Skip to content

Commit a7ccaa3

Browse files
committed
Added support for querying the maximum image width and height when the device does not support images
additional housekeeping: -unified naming convention -corrected consistency of returned values More housekeeping corrections
1 parent 5673883 commit a7ccaa3

1 file changed

Lines changed: 63 additions & 38 deletions

File tree

test_conformance/api/test_api_min_max.cpp

Lines changed: 63 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -633,12 +633,25 @@ REGISTER_TEST(min_max_image_2d_width)
633633
{
634634
int error;
635635
size_t maxDimension;
636-
clMemWrapper streams[1];
637-
cl_image_format image_format_desc;
636+
clMemWrapper streams;
637+
cl_image_format imageFormatDesc;
638638
cl_ulong maxAllocSize;
639639
cl_uint minRequiredDimension;
640640

641-
PASSIVE_REQUIRE_IMAGE_SUPPORT(device)
641+
if (checkForImageSupport(device))
642+
{
643+
/* Get the max 2d image width */
644+
error = clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_WIDTH,
645+
sizeof(maxDimension), &maxDimension, NULL);
646+
test_error(error, "Unable to get max image 2d width from device");
647+
648+
test_failure_error_ret(
649+
maxDimension, 0,
650+
"Missing image support but CL_DEVICE_IMAGE2D_MAX_WIDTH query did "
651+
"not return 0",
652+
TEST_FAIL);
653+
return TEST_SKIPPED_ITSELF;
654+
}
642655

643656
auto version = get_device_cl_version(device);
644657
if (version == Version(1, 0))
@@ -650,10 +663,9 @@ REGISTER_TEST(min_max_image_2d_width)
650663
minRequiredDimension = gIsEmbedded ? 2048 : 8192;
651664
}
652665

653-
654666
/* Just get any ol format to test with */
655667
error = get_8_bit_image_format(context, CL_MEM_OBJECT_IMAGE2D,
656-
CL_MEM_READ_WRITE, 0, &image_format_desc);
668+
CL_MEM_READ_WRITE, 0, &imageFormatDesc);
657669
test_error(error, "Unable to obtain suitable image format to test with!");
658670

659671
/* Get the max 2d image width */
@@ -663,21 +675,21 @@ REGISTER_TEST(min_max_image_2d_width)
663675

664676
if (maxDimension < minRequiredDimension)
665677
{
666-
log_error(
667-
"ERROR: Reported max image 2d width is less than required! (%d)\n",
668-
(int)maxDimension);
669-
return -1;
678+
log_error("ERROR: Reported max image 2d width is less than "
679+
"required! (%d)\n",
680+
(int)maxDimension);
681+
return TEST_FAIL;
670682
}
671683
log_info("Max reported width is %zu.\n", maxDimension);
672684

673685
/* Verify we can use the format */
674-
image_format_desc.image_channel_data_type = CL_UNORM_INT8;
675-
image_format_desc.image_channel_order = CL_RGBA;
686+
imageFormatDesc.image_channel_data_type = CL_UNORM_INT8;
687+
imageFormatDesc.image_channel_order = CL_RGBA;
676688
if (!is_image_format_supported(context, CL_MEM_READ_ONLY,
677-
CL_MEM_OBJECT_IMAGE2D, &image_format_desc))
689+
CL_MEM_OBJECT_IMAGE2D, &imageFormatDesc))
678690
{
679691
log_error("CL_UNORM_INT8 CL_RGBA not supported. Can not test.");
680-
return -1;
692+
return TEST_FAIL;
681693
}
682694

683695
/* Verify that we can actually allocate an image that large */
@@ -688,34 +700,47 @@ REGISTER_TEST(min_max_image_2d_width)
688700
log_error("Can not allocate a large enough image (min size: %" PRIu64
689701
" bytes, max allowed: %" PRIu64 " bytes) to test.\n",
690702
(cl_ulong)maxDimension * 1 * 4, maxAllocSize);
691-
return -1;
703+
return TEST_FAIL;
692704
}
693705

694706
log_info("Attempting to create an image of size %d x 1 = %gMB.\n",
695707
(int)maxDimension, ((float)maxDimension * 4 / 1024.0 / 1024.0));
696708

697709
/* Try to allocate a very big image */
698-
streams[0] = create_image_2d(context, CL_MEM_READ_ONLY, &image_format_desc,
699-
maxDimension, 1, 0, NULL, &error);
700-
if ((streams[0] == NULL) || (error != CL_SUCCESS))
710+
streams = create_image_2d(context, CL_MEM_READ_ONLY, &imageFormatDesc,
711+
maxDimension, 1, 0, NULL, &error);
712+
if ((streams == nullptr) || (error != CL_SUCCESS))
701713
{
702714
print_error(error, "Image 2D creation failed for maximum width");
703-
return -1;
715+
return TEST_FAIL;
704716
}
705717

706-
return 0;
718+
return TEST_PASS;
707719
}
708720

709721
REGISTER_TEST(min_max_image_2d_height)
710722
{
711723
int error;
712724
size_t maxDimension;
713-
clMemWrapper streams[1];
714-
cl_image_format image_format_desc;
725+
clMemWrapper streams;
726+
cl_image_format imageFormatDesc;
715727
cl_ulong maxAllocSize;
716728
cl_uint minRequiredDimension;
717729

718-
PASSIVE_REQUIRE_IMAGE_SUPPORT(device)
730+
if (checkForImageSupport(device))
731+
{
732+
/* Get the max 2d image height */
733+
error = clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_HEIGHT,
734+
sizeof(maxDimension), &maxDimension, NULL);
735+
test_error(error, "Unable to get max image 2d height from device");
736+
737+
test_failure_error_ret(
738+
maxDimension, 0,
739+
"Missing image support but CL_DEVICE_IMAGE2D_MAX_HEIGHT query did "
740+
"not return 0",
741+
TEST_FAIL);
742+
return TEST_SKIPPED_ITSELF;
743+
}
719744

720745
auto version = get_device_cl_version(device);
721746
if (version == Version(1, 0))
@@ -729,31 +754,31 @@ REGISTER_TEST(min_max_image_2d_height)
729754

730755
/* Just get any ol format to test with */
731756
error = get_8_bit_image_format(context, CL_MEM_OBJECT_IMAGE2D,
732-
CL_MEM_READ_WRITE, 0, &image_format_desc);
757+
CL_MEM_READ_WRITE, 0, &imageFormatDesc);
733758
test_error(error, "Unable to obtain suitable image format to test with!");
734759

735-
/* Get the max 2d image width */
760+
/* Get the max 2d image height */
736761
error = clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_HEIGHT,
737762
sizeof(maxDimension), &maxDimension, NULL);
738763
test_error(error, "Unable to get max image 2d height from device");
739764

740765
if (maxDimension < minRequiredDimension)
741766
{
742-
log_error(
743-
"ERROR: Reported max image 2d height is less than required! (%d)\n",
744-
(int)maxDimension);
745-
return -1;
767+
log_error("ERROR: Reported max image 2d height is less than "
768+
"required! (%d)\n",
769+
(int)maxDimension);
770+
return TEST_FAIL;
746771
}
747772
log_info("Max reported height is %zu.\n", maxDimension);
748773

749774
/* Verify we can use the format */
750-
image_format_desc.image_channel_data_type = CL_UNORM_INT8;
751-
image_format_desc.image_channel_order = CL_RGBA;
775+
imageFormatDesc.image_channel_data_type = CL_UNORM_INT8;
776+
imageFormatDesc.image_channel_order = CL_RGBA;
752777
if (!is_image_format_supported(context, CL_MEM_READ_ONLY,
753-
CL_MEM_OBJECT_IMAGE2D, &image_format_desc))
778+
CL_MEM_OBJECT_IMAGE2D, &imageFormatDesc))
754779
{
755780
log_error("CL_UNORM_INT8 CL_RGBA not supported. Can not test.");
756-
return -1;
781+
return TEST_FAIL;
757782
}
758783

759784
/* Verify that we can actually allocate an image that large */
@@ -764,22 +789,22 @@ REGISTER_TEST(min_max_image_2d_height)
764789
log_error("Can not allocate a large enough image (min size: %" PRIu64
765790
" bytes, max allowed: %" PRIu64 " bytes) to test.\n",
766791
(cl_ulong)maxDimension * 1 * 4, maxAllocSize);
767-
return -1;
792+
return TEST_FAIL;
768793
}
769794

770795
log_info("Attempting to create an image of size 1 x %d = %gMB.\n",
771796
(int)maxDimension, ((float)maxDimension * 4 / 1024.0 / 1024.0));
772797

773798
/* Try to allocate a very big image */
774-
streams[0] = create_image_2d(context, CL_MEM_READ_ONLY, &image_format_desc,
775-
1, maxDimension, 0, NULL, &error);
776-
if ((streams[0] == NULL) || (error != CL_SUCCESS))
799+
streams = create_image_2d(context, CL_MEM_READ_ONLY, &imageFormatDesc, 1,
800+
maxDimension, 0, NULL, &error);
801+
if ((streams == nullptr) || (error != CL_SUCCESS))
777802
{
778803
print_error(error, "Image 2D creation failed for maximum height");
779-
return -1;
804+
return TEST_FAIL;
780805
}
781806

782-
return 0;
807+
return TEST_PASS;
783808
}
784809

785810
REGISTER_TEST(min_max_image_3d_width)

0 commit comments

Comments
 (0)