Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend testing of CL_UNORM_INT_101010_2 #2031

Merged
merged 2 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test_common/harness/errorHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ const char *GetChannelTypeName(cl_channel_type type)
case CL_UNORM_SHORT_565: return "CL_UNORM_SHORT_565";
case CL_UNORM_SHORT_555: return "CL_UNORM_SHORT_555";
case CL_UNORM_INT_101010: return "CL_UNORM_INT_101010";
case CL_UNORM_INT_101010_2: return "CL_UNORM_INT_101010_2";
case CL_SIGNED_INT8: return "CL_SIGNED_INT8";
case CL_SIGNED_INT16: return "CL_SIGNED_INT16";
case CL_SIGNED_INT32: return "CL_SIGNED_INT32";
Expand Down Expand Up @@ -220,6 +221,7 @@ int IsChannelTypeSupported(cl_channel_type type)
case CL_UNORM_SHORT_565:
case CL_UNORM_SHORT_555:
case CL_UNORM_INT_101010:
case CL_UNORM_INT_101010_2:
case CL_SIGNED_INT8:
case CL_SIGNED_INT16:
case CL_SIGNED_INT32:
Expand Down
37 changes: 36 additions & 1 deletion test_common/harness/imageHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ uint32_t get_channel_data_type_size(cl_channel_type channelType)
case CL_UNORM_SHORT_565:
case CL_UNORM_SHORT_555: return 2;

case CL_UNORM_INT_101010: return 4;
case CL_UNORM_INT_101010:
case CL_UNORM_INT_101010_2: return 4;

case CL_FLOAT: return sizeof(cl_float);

Expand Down Expand Up @@ -170,6 +171,7 @@ cl_channel_type get_channel_type_from_name(const char *name)
{ CL_UNORM_SHORT_565, "CL_UNORM_SHORT_565" },
{ CL_UNORM_SHORT_555, "CL_UNORM_SHORT_555" },
{ CL_UNORM_INT_101010, "CL_UNORM_INT_101010" },
{ CL_UNORM_INT_101010_2, "CL_UNORM_INT_101010_2" },
{ CL_SIGNED_INT8, "CL_SIGNED_INT8" },
{ CL_SIGNED_INT16, "CL_SIGNED_INT16" },
{ CL_SIGNED_INT32, "CL_SIGNED_INT32" },
Expand Down Expand Up @@ -934,6 +936,7 @@ float get_max_relative_error(const cl_image_format *format,
case CL_UNORM_SHORT_565:
case CL_UNORM_SHORT_555:
case CL_UNORM_INT_101010:
case CL_UNORM_INT_101010_2:
// Maximum sampling error for round to zero normalization based on
// multiplication by reciprocal (using reciprocal generated in
// round to +inf mode, so that 1.0 matches spec)
Expand Down Expand Up @@ -1465,6 +1468,15 @@ void read_image_pixel_float(void *imageData, image_descriptor *imageInfo, int x,
break;
}

case CL_UNORM_INT_101010_2: {
cl_uint *dPtr = (cl_uint *)ptr;
tempData[0] = (float)((dPtr[0] >> 22) & 0x3ff) / (float)1023;
tempData[1] = (float)((dPtr[0] >> 12) & 0x3ff) / (float)1023;
tempData[2] = (float)(dPtr[0] >> 2 & 0x3ff) / (float)1023;
tempData[3] = (float)(dPtr[0] >> 0 & 3) / (float)3;
break;
}

case CL_FLOAT: {
float *dPtr = (float *)ptr;
for (i = 0; i < channelCount; i++) tempData[i] = (float)dPtr[i];
Expand Down Expand Up @@ -2730,6 +2742,15 @@ void pack_image_pixel(float *srcVector, const cl_image_format *imageFormat,
| (((unsigned int)NORMALIZE(srcVector[2], 1023.f) & 1023) << 0);
break;
}
case CL_UNORM_INT_101010_2: {
cl_uint *ptr = (cl_uint *)outData;
ptr[0] =
(((unsigned int)NORMALIZE(srcVector[0], 1023.f) & 1023) << 22)
| (((unsigned int)NORMALIZE(srcVector[1], 1023.f) & 1023) << 12)
| (((unsigned int)NORMALIZE(srcVector[2], 1023.f) & 1023) << 2)
| (((unsigned int)NORMALIZE(srcVector[3], 3.f) & 3) << 0);
break;
}
case CL_SIGNED_INT8: {
cl_char *ptr = (cl_char *)outData;
for (unsigned int i = 0; i < channelCount; i++)
Expand Down Expand Up @@ -2892,6 +2913,20 @@ void pack_image_pixel_error(const float *srcVector,

break;
}
case CL_UNORM_INT_101010_2: {
const cl_uint *ptr = (const cl_uint *)results;

errors[0] = ((ptr[0] >> 22) & 1023)
- NORMALIZE_UNROUNDED(srcVector[0], 1023.f);
errors[1] = ((ptr[0] >> 12) & 1023)
- NORMALIZE_UNROUNDED(srcVector[1], 1023.f);
errors[2] = ((ptr[0] >> 2) & 1023)
- NORMALIZE_UNROUNDED(srcVector[2], 1023.f);
errors[3] =
((ptr[0] >> 0) & 3) - NORMALIZE_UNROUNDED(srcVector[3], 3.f);

break;
}
case CL_SIGNED_INT8: {
const cl_char *ptr = (const cl_char *)results;

Expand Down
8 changes: 5 additions & 3 deletions test_conformance/images/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
#include "common.h"

cl_channel_type floatFormats[] = {
CL_UNORM_SHORT_565, CL_UNORM_SHORT_555, CL_UNORM_INT_101010,
CL_UNORM_SHORT_565, CL_UNORM_SHORT_555, CL_UNORM_INT_101010,
CL_UNORM_INT_101010_2,
#ifdef CL_SFIXED14_APPLE
CL_SFIXED14_APPLE,
#endif
CL_UNORM_INT8, CL_SNORM_INT8, CL_UNORM_INT16, CL_SNORM_INT16,
CL_FLOAT, CL_HALF_FLOAT, (cl_channel_type)-1,
CL_UNORM_INT8, CL_SNORM_INT8, CL_UNORM_INT16,
CL_SNORM_INT16, CL_FLOAT, CL_HALF_FLOAT,
(cl_channel_type)-1,
};

cl_channel_type intFormats[] = {
Expand Down
2 changes: 2 additions & 0 deletions test_conformance/images/kernel_read_write/test_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1663,6 +1663,8 @@ int filter_rounding_errors(int forceCorrectlyRoundedWrites,
if (0 == forceCorrectlyRoundedWrites
&& (imageInfo->format->image_channel_data_type == CL_UNORM_INT8
|| imageInfo->format->image_channel_data_type == CL_UNORM_INT_101010
|| imageInfo->format->image_channel_data_type
== CL_UNORM_INT_101010_2
|| imageInfo->format->image_channel_data_type == CL_UNORM_INT16
|| imageInfo->format->image_channel_data_type == CL_SNORM_INT8
|| imageInfo->format->image_channel_data_type == CL_SNORM_INT16
Expand Down
Loading