Skip to content

Commit

Permalink
Merge branch 'main' into work_item_fns_out_of_range
Browse files Browse the repository at this point in the history
  • Loading branch information
shajder committed Nov 5, 2024
2 parents 3946932 + c4119f0 commit dc98a7f
Show file tree
Hide file tree
Showing 156 changed files with 3,983 additions and 672 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang"
# Enable more warnings if not doing a release build.
add_cxx_flag_if_supported(-Wall)
endif()
add_cxx_flag_if_supported(-Wno-narrowing)
add_cxx_flag_if_supported(-Wno-format)
add_cxx_flag_if_supported(-Wno-error=cpp) # Allow #warning directive
add_cxx_flag_if_supported(-Wno-unknown-pragmas) # Issue #785
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ require compilation, these are:

The Khronos [Conformance Process Document](https://members.khronos.org/document/dl/911)
details the steps required for a conformance submission.
In this repository [opencl_conformance_tests_full.csv](test_conformance/submission_details_template.txt)
In this repository [opencl_conformance_tests_full.csv](test_conformance/opencl_conformance_tests_full.csv)
defines the full list of tests which must be run for conformance. The output log
of which must be included alongside a filled in
[submission details template](test_conformance/submission_details_template.txt).
Expand Down
2 changes: 2 additions & 0 deletions test_common/harness/errorHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ const char *GetChannelTypeName(cl_channel_type type)
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_UNORM_INT_2_101010_EXT: return "CL_UNORM_INT_2_101010_EXT";
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 @@ -228,6 +229,7 @@ int IsChannelTypeSupported(cl_channel_type type)
case CL_UNORM_SHORT_555:
case CL_UNORM_INT_101010:
case CL_UNORM_INT_101010_2:
case CL_UNORM_INT_2_101010_EXT:
case CL_SIGNED_INT8:
case CL_SIGNED_INT16:
case CL_SIGNED_INT32:
Expand Down
82 changes: 60 additions & 22 deletions test_common/harness/imageHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ uint32_t get_channel_data_type_size(cl_channel_type channelType)
case CL_UNORM_SHORT_555: return 2;

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

case CL_FLOAT: return sizeof(cl_float);

Expand Down Expand Up @@ -163,25 +164,27 @@ cl_channel_type get_channel_type_from_name(const char *name)
{
cl_channel_type type;
const char *name;
} typeNames[] = { { CL_SNORM_INT8, "CL_SNORM_INT8" },
{ CL_SNORM_INT16, "CL_SNORM_INT16" },
{ CL_UNORM_INT8, "CL_UNORM_INT8" },
{ CL_UNORM_INT16, "CL_UNORM_INT16" },
{ CL_UNORM_INT24, "CL_UNORM_INT24" },
{ 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" },
{ CL_UNSIGNED_INT8, "CL_UNSIGNED_INT8" },
{ CL_UNSIGNED_INT16, "CL_UNSIGNED_INT16" },
{ CL_UNSIGNED_INT32, "CL_UNSIGNED_INT32" },
{ CL_HALF_FLOAT, "CL_HALF_FLOAT" },
{ CL_FLOAT, "CL_FLOAT" },
} typeNames[] = {
{ CL_SNORM_INT8, "CL_SNORM_INT8" },
{ CL_SNORM_INT16, "CL_SNORM_INT16" },
{ CL_UNORM_INT8, "CL_UNORM_INT8" },
{ CL_UNORM_INT16, "CL_UNORM_INT16" },
{ CL_UNORM_INT24, "CL_UNORM_INT24" },
{ 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_UNORM_INT_2_101010_EXT, "CL_UNORM_INT_2_101010_EXT" },
{ CL_SIGNED_INT8, "CL_SIGNED_INT8" },
{ CL_SIGNED_INT16, "CL_SIGNED_INT16" },
{ CL_SIGNED_INT32, "CL_SIGNED_INT32" },
{ CL_UNSIGNED_INT8, "CL_UNSIGNED_INT8" },
{ CL_UNSIGNED_INT16, "CL_UNSIGNED_INT16" },
{ CL_UNSIGNED_INT32, "CL_UNSIGNED_INT32" },
{ CL_HALF_FLOAT, "CL_HALF_FLOAT" },
{ CL_FLOAT, "CL_FLOAT" },
#ifdef CL_SFIXED14_APPLE
{ CL_SFIXED14_APPLE, "CL_SFIXED14_APPLE" }
{ CL_SFIXED14_APPLE, "CL_SFIXED14_APPLE" }
#endif
};
for (size_t i = 0; i < sizeof(typeNames) / sizeof(typeNames[0]); i++)
Expand Down Expand Up @@ -288,7 +291,8 @@ uint32_t get_pixel_size(const cl_image_format *format)

case CL_FLOAT:
return get_format_channel_count(format) * sizeof(cl_float);
case CL_UNORM_INT_101010_2: return 4;
case CL_UNORM_INT_101010_2:
case CL_UNORM_INT_2_101010_EXT: return 4;

case CL_UNSIGNED_INT_RAW10_EXT:
case CL_UNSIGNED_INT_RAW12_EXT: return 2;
Expand Down Expand Up @@ -937,6 +941,7 @@ float get_max_relative_error(const cl_image_format *format,
case CL_UNORM_SHORT_555:
case CL_UNORM_INT_101010:
case CL_UNORM_INT_101010_2:
case CL_UNORM_INT_2_101010_EXT:
// 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 @@ -1021,7 +1026,8 @@ size_t get_format_max_int(const cl_image_format *format)
case CL_UNORM_SHORT_555: return 31;

case CL_UNORM_INT_101010:
case CL_UNORM_INT_101010_2: return 1023;
case CL_UNORM_INT_101010_2:
case CL_UNORM_INT_2_101010_EXT: return 1023;

case CL_HALF_FLOAT: return 1 << 10;

Expand Down Expand Up @@ -1054,7 +1060,8 @@ int get_format_min_int(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: return 0;
case CL_UNORM_INT_101010_2:
case CL_UNORM_INT_2_101010_EXT: return 0;

case CL_HALF_FLOAT: return -(1 << 10);

Expand Down Expand Up @@ -1479,6 +1486,15 @@ void read_image_pixel_float(void *imageData, image_descriptor *imageInfo, int x,
break;
}

case CL_UNORM_INT_2_101010_EXT: {
cl_uint *dPtr = (cl_uint *)ptr;
tempData[0] = (float)((dPtr[0] >> 30) & 0x3) / (float)3;
tempData[1] = (float)((dPtr[0] >> 20) & 0x3ff) / (float)1023;
tempData[2] = (float)(dPtr[0] >> 10 & 0x3ff) / (float)1023;
tempData[3] = (float)(dPtr[0] >> 0 & 0x3ff) / (float)1023;
break;
}

case CL_FLOAT: {
float *dPtr = (float *)ptr;
for (i = 0; i < channelCount; i++) tempData[i] = (float)dPtr[i];
Expand Down Expand Up @@ -2753,6 +2769,14 @@ void pack_image_pixel(float *srcVector, const cl_image_format *imageFormat,
| (((unsigned int)NORMALIZE(srcVector[3], 3.f) & 3) << 0);
break;
}
case CL_UNORM_INT_2_101010_EXT: {
cl_uint *ptr = (cl_uint *)outData;
ptr[0] = (((unsigned int)NORMALIZE(srcVector[0], 3.f) & 3) << 30)
| (((unsigned int)NORMALIZE(srcVector[1], 1023.f) & 1023) << 20)
| (((unsigned int)NORMALIZE(srcVector[2], 1023.f) & 1023) << 10)
| (((unsigned int)NORMALIZE(srcVector[3], 1023.f) & 1023) << 0);
break;
}
case CL_SIGNED_INT8: {
cl_char *ptr = (cl_char *)outData;
for (unsigned int i = 0; i < channelCount; i++)
Expand Down Expand Up @@ -2929,6 +2953,20 @@ void pack_image_pixel_error(const float *srcVector,

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

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

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

Expand Down
23 changes: 12 additions & 11 deletions test_common/harness/kernelHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,8 @@ size_t get_pixel_bytes(const cl_image_format *fmt)
case CL_UNORM_SHORT_555: return 2;

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

case CL_SNORM_INT8:
case CL_UNORM_INT8:
Expand Down Expand Up @@ -1624,7 +1625,7 @@ Version get_device_cl_c_version(cl_device_id device)
&opencl_c_version_size_in_bytes);
test_error_ret(error,
"clGetDeviceInfo failed for CL_DEVICE_OPENCL_C_VERSION\n",
(Version{ -1, 0 }));
(Version{ 0, 0 }));

std::string opencl_c_version(opencl_c_version_size_in_bytes, '\0');
error =
Expand All @@ -1633,13 +1634,13 @@ Version get_device_cl_c_version(cl_device_id device)

test_error_ret(error,
"clGetDeviceInfo failed for CL_DEVICE_OPENCL_C_VERSION\n",
(Version{ -1, 0 }));
(Version{ 0, 0 }));

// Scrape out the major, minor pair from the string.
auto major = opencl_c_version[opencl_c_version.find('.') - 1];
auto minor = opencl_c_version[opencl_c_version.find('.') + 1];

return Version{ major - '0', minor - '0' };
return Version{ (cl_uint)(major - '0'), (cl_uint)(minor - '0') };
}

Version get_device_latest_cl_c_version(cl_device_id device)
Expand All @@ -1657,22 +1658,22 @@ Version get_device_latest_cl_c_version(cl_device_id device)
&opencl_c_all_versions_size_in_bytes);
test_error_ret(
error, "clGetDeviceInfo failed for CL_DEVICE_OPENCL_C_ALL_VERSIONS",
(Version{ -1, 0 }));
(Version{ 0, 0 }));
std::vector<cl_name_version> name_versions(
opencl_c_all_versions_size_in_bytes / sizeof(cl_name_version));
error = clGetDeviceInfo(device, CL_DEVICE_OPENCL_C_ALL_VERSIONS,
opencl_c_all_versions_size_in_bytes,
name_versions.data(), nullptr);
test_error_ret(
error, "clGetDeviceInfo failed for CL_DEVICE_OPENCL_C_ALL_VERSIONS",
(Version{ -1, 0 }));
(Version{ 0, 0 }));

Version max_supported_cl_c_version{};
for (const auto &name_version : name_versions)
{
Version current_version{
static_cast<int>(CL_VERSION_MAJOR(name_version.version)),
static_cast<int>(CL_VERSION_MINOR(name_version.version))
static_cast<cl_uint>(CL_VERSION_MAJOR(name_version.version)),
static_cast<cl_uint>(CL_VERSION_MINOR(name_version.version))
};
max_supported_cl_c_version =
(current_version > max_supported_cl_c_version)
Expand All @@ -1693,7 +1694,7 @@ Version get_max_OpenCL_C_for_context(cl_context context)
auto error = clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, nullptr,
&devices_size_in_bytes);
test_error_ret(error, "clGetDeviceInfo failed for CL_CONTEXT_DEVICES",
(Version{ -1, 0 }));
(Version{ 0, 0 }));
std::vector<cl_device_id> devices(devices_size_in_bytes
/ sizeof(cl_device_id));
error = clGetContextInfo(context, CL_CONTEXT_DEVICES, devices_size_in_bytes,
Expand Down Expand Up @@ -1757,8 +1758,8 @@ bool device_supports_cl_c_version(cl_device_id device, Version version)
for (const auto &name_version : name_versions)
{
Version current_version{
static_cast<int>(CL_VERSION_MAJOR(name_version.version)),
static_cast<int>(CL_VERSION_MINOR(name_version.version))
static_cast<cl_uint>(CL_VERSION_MAJOR(name_version.version)),
static_cast<cl_uint>(CL_VERSION_MINOR(name_version.version))
};
if (current_version == version)
{
Expand Down
2 changes: 0 additions & 2 deletions test_common/harness/parseParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#include <sys/stat.h>
#include <string.h>

using namespace std;

#define DEFAULT_COMPILATION_PROGRAM "cl_offline_compiler"
#define DEFAULT_SPIRV_VALIDATOR "spirv-val"

Expand Down
2 changes: 1 addition & 1 deletion test_common/harness/rounding_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void UnFlushToZero(void *p)
#if defined(__i386__) || defined(__x86_64__) || defined(_MSC_VER)
union {
void *p;
int i;
unsigned int i;
} u = { p };
_mm_setcsr(u.i);
#elif defined(__arm__) || defined(__aarch64__)
Expand Down
24 changes: 15 additions & 9 deletions test_common/harness/testHarness.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,28 @@
class Version {
public:
Version(): m_major(0), m_minor(0) {}
Version(int major, int minor): m_major(major), m_minor(minor) {}
bool operator>(const Version &rhs) const { return to_int() > rhs.to_int(); }
bool operator<(const Version &rhs) const { return to_int() < rhs.to_int(); }
Version(cl_uint major, cl_uint minor): m_major(major), m_minor(minor) {}
bool operator>(const Version &rhs) const
{
return to_uint() > rhs.to_uint();
}
bool operator<(const Version &rhs) const
{
return to_uint() < rhs.to_uint();
}
bool operator<=(const Version &rhs) const
{
return to_int() <= rhs.to_int();
return to_uint() <= rhs.to_uint();
}
bool operator>=(const Version &rhs) const
{
return to_int() >= rhs.to_int();
return to_uint() >= rhs.to_uint();
}
bool operator==(const Version &rhs) const
{
return to_int() == rhs.to_int();
return to_uint() == rhs.to_uint();
}
int to_int() const { return m_major * 10 + m_minor; }
cl_uint to_uint() const { return m_major * 10 + m_minor; }
std::string to_string() const
{
std::stringstream ss;
Expand All @@ -49,8 +55,8 @@ class Version {
}

private:
int m_major;
int m_minor;
cl_uint m_major;
cl_uint m_minor;
};

Version get_device_cl_version(cl_device_id device);
Expand Down
1 change: 1 addition & 0 deletions test_conformance/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set(${MODULE_NAME}_SOURCES
test_queries.cpp
test_create_kernels.cpp
test_kernels.cpp
test_kernel_local_memory_size.cpp
test_kernel_private_memory_size.cpp
test_api_min_max.cpp
test_kernel_arg_changes.cpp
Expand Down
3 changes: 3 additions & 0 deletions test_conformance/api/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ test_definition test_list[] = {
ADD_TEST_VERSION(consistency_subgroups, Version(3, 0)),
ADD_TEST_VERSION(consistency_prog_ctor_dtor, Version(3, 0)),
ADD_TEST_VERSION(consistency_3d_image_writes, Version(3, 0)),
ADD_TEST(consistency_requirements_fp64),
ADD_TEST(consistency_requirements_fp16),

ADD_TEST(min_image_formats),
ADD_TEST(set_command_queue_property),
Expand All @@ -161,6 +163,7 @@ test_definition test_list[] = {
ADD_TEST_VERSION(negative_create_command_queue_with_properties,
Version(2, 0)),
ADD_TEST(negative_create_command_queue_with_properties_khr),
ADD_TEST(kernel_local_memory_size),
};

const int test_num = ARRAY_SIZE(test_list);
Expand Down
12 changes: 12 additions & 0 deletions test_conformance/api/procs.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,21 @@ extern int test_consistency_3d_image_writes(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_requirements_fp64(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_requirements_fp16(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);

extern int test_min_image_formats(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_kernel_local_memory_size(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_negative_get_platform_info(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
Expand Down
Loading

0 comments on commit dc98a7f

Please sign in to comment.