Skip to content

Commit

Permalink
Merge branch 'main' into semaphore_negative_clCreateSemaphoreWithProp…
Browse files Browse the repository at this point in the history
…ertiesKHR
  • Loading branch information
shajder committed Jul 4, 2024
2 parents 83b129c + 6b4d57d commit e8c34d6
Show file tree
Hide file tree
Showing 133 changed files with 15,091 additions and 2,247 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Install packages
run: sudo apt install -y clang-format clang-format-11
run: sudo apt install -y clang-format clang-format-14
- uses: actions/checkout@v4
with:
fetch-depth: 0
Expand Down
2 changes: 1 addition & 1 deletion check-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Arg used to specify non-'origin/main' comparison branch
ORIGIN_BRANCH=${1:-"origin/main"}
CLANG_BINARY=${2:-"`which clang-format-11`"}
CLANG_BINARY=${2:-"`which clang-format-14`"}

# Run git-clang-format to check for violations
CLANG_FORMAT_OUTPUT=$(git-clang-format --diff $ORIGIN_BRANCH --extensions c,cpp,h,hpp --binary $CLANG_BINARY)
Expand Down
16 changes: 11 additions & 5 deletions test_common/gl/setup_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,26 @@ class X11GLEnvironment : public GLEnvironment
private:
cl_device_id m_devices[64];
cl_uint m_device_count;
bool m_glut_init;

public:
X11GLEnvironment()
{
m_device_count = 0;
m_glut_init = false;
}
virtual int Init( int *argc, char **argv, int use_opencl_32 )
{
// Create a GLUT window to render into
glutInit( argc, argv );
glutInitWindowSize( 512, 512 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
glutCreateWindow( "OpenCL <-> OpenGL Test" );
glewInit();
if (!m_glut_init)
{
glutInit(argc, argv);
glutInitWindowSize(512, 512);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutCreateWindow("OpenCL <-> OpenGL Test");
glewInit();
m_glut_init = true;
}
return 0;
}

Expand Down
4 changes: 3 additions & 1 deletion test_common/harness/errorHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ const char *GetChannelTypeName(cl_channel_type type)
case CL_SFIXED14_APPLE: return "CL_SFIXED14_APPLE";
#endif
case CL_UNORM_INT24: return "CL_UNORM_INT24";
case CL_UNSIGNED_INT_RAW10_EXT: return "CL_UNSIGNED_INT_RAW10_EXT";
case CL_UNSIGNED_INT_RAW12_EXT: return "CL_UNSIGNED_INT_RAW12_EXT";
default: return NULL;
}
}
Expand Down Expand Up @@ -369,7 +371,7 @@ static float Ulp_Error_Half_Float(float test, double reference)
return (float)scalbn(testVal - reference, ulp_exp);
}

float Ulp_Error_Half(cl_half test, float reference)
float Ulp_Error_Half(cl_half test, double reference)
{
return Ulp_Error_Half_Float(cl_half_to_float(test), reference);
}
Expand Down
2 changes: 1 addition & 1 deletion test_common/harness/errorHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static int vlog_win32(const char *format, ...);

extern const char *IGetErrorString(int clErrorCode);

extern float Ulp_Error_Half(cl_half test, float reference);
extern float Ulp_Error_Half(cl_half test, double reference);
extern float Ulp_Error(float test, double reference);
extern float Ulp_Error_Double(double test, long double reference);

Expand Down
13 changes: 10 additions & 3 deletions test_common/harness/imageHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ uint32_t get_pixel_size(const cl_image_format *format)
return get_format_channel_count(format) * sizeof(cl_float);
case CL_UNORM_INT_101010_2: return 4;

case CL_UNSIGNED_INT_RAW10_EXT:
case CL_UNSIGNED_INT_RAW12_EXT: return 2;

default: return 0;
}
}
Expand Down Expand Up @@ -1125,13 +1128,15 @@ cl_ulong get_image_size_mb(image_descriptor const *imageInfo)
uint64_t gRoundingStartValue = 0;


void escape_inf_nan_values(char *data, size_t allocSize)
void escape_inf_nan_subnormal_values(char *data, size_t allocSize)
{
// filter values with 8 not-quite-highest bits
unsigned int *intPtr = (unsigned int *)data;
for (size_t i = 0; i<allocSize>> 2; i++)
{
if ((intPtr[i] & 0x7F800000) == 0x7F800000) intPtr[i] ^= 0x40000000;
else if ((intPtr[i] & 0x7F800000) == 0)
intPtr[i] ^= 0x40000000;
}

// Ditto with half floats (16-bit numbers with the 5 not-quite-highest bits
Expand All @@ -1140,6 +1145,8 @@ void escape_inf_nan_values(char *data, size_t allocSize)
for (size_t i = 0; i<allocSize>> 1; i++)
{
if ((shortPtr[i] & 0x7C00) == 0x7C00) shortPtr[i] ^= 0x4000;
else if ((shortPtr[i] & 0x7C00) == 0)
shortPtr[i] ^= 0x4000;
}
}

Expand Down Expand Up @@ -1218,7 +1225,7 @@ char *generate_random_image_data(image_descriptor *imageInfo,

// Note: inf or nan float values would cause problems, although we don't
// know this will actually be a float, so we just know what to look for
escape_inf_nan_values(data, allocSize);
escape_inf_nan_subnormal_values(data, allocSize);
return data;
}

Expand All @@ -1230,7 +1237,7 @@ char *generate_random_image_data(image_descriptor *imageInfo,

// Note: inf or nan float values would cause problems, although we don't
// know this will actually be a float, so we just know what to look for
escape_inf_nan_values(data, allocSize);
escape_inf_nan_subnormal_values(data, allocSize);

if (/*!gTestMipmaps*/ imageInfo->num_mip_levels < 2)
{
Expand Down
78 changes: 74 additions & 4 deletions test_common/harness/imageHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,42 @@ cl_uint compute_max_mip_levels(size_t width, size_t height, size_t depth);
cl_ulong compute_mipmapped_image_size(image_descriptor imageInfo);
size_t compute_mip_level_offset(image_descriptor *imageInfo, size_t lod);

constexpr size_t RAW10_EXT_CLUMP_SIZE = 5;
constexpr size_t RAW10_EXT_CLUMP_NUM_PIXELS = 4;
constexpr size_t RAW12_EXT_CLUMP_SIZE = 3;
constexpr size_t RAW12_EXT_CLUMP_NUM_PIXELS = 2;

inline bool is_width_compatible(image_descriptor imageInfo)
{
if (imageInfo.format->image_channel_data_type == CL_UNSIGNED_INT_RAW10_EXT
&& (imageInfo.width % RAW10_EXT_CLUMP_NUM_PIXELS) != 0)
{
return false;
}
if (imageInfo.format->image_channel_data_type == CL_UNSIGNED_INT_RAW12_EXT
&& (imageInfo.width % RAW12_EXT_CLUMP_NUM_PIXELS) != 0)
{
return false;
}
return true;
}

inline size_t calculate_row_pitch(image_descriptor imageInfo, size_t pixelSize)
{
if (imageInfo.format->image_channel_data_type == CL_UNSIGNED_INT_RAW10_EXT)
{
return (imageInfo.width * RAW10_EXT_CLUMP_SIZE)
/ RAW10_EXT_CLUMP_NUM_PIXELS;
}
if (imageInfo.format->image_channel_data_type == CL_UNSIGNED_INT_RAW12_EXT)
{
return (imageInfo.width * RAW12_EXT_CLUMP_SIZE)
/ RAW12_EXT_CLUMP_NUM_PIXELS;
}

return imageInfo.width * pixelSize;
}

template <class T>
void read_image_pixel(void *imageData, image_descriptor *imageInfo, int x,
int y, int z, T *outData, int lod)
Expand Down Expand Up @@ -255,10 +291,24 @@ void read_image_pixel(void *imageData, image_descriptor *imageInfo, int x,

// Advance to the right spot
char *ptr = (char *)imageData;
size_t pixelSize = get_pixel_size(format);

ptr += z * slice_pitch_lod + y * row_pitch_lod + x * pixelSize;

switch (format->image_channel_data_type)
{
case CL_UNSIGNED_INT_RAW10_EXT: {
ptr += z * slice_pitch_lod + y * row_pitch_lod
+ (x / RAW10_EXT_CLUMP_NUM_PIXELS) * RAW10_EXT_CLUMP_SIZE;
break;
}
case CL_UNSIGNED_INT_RAW12_EXT: {
ptr += z * slice_pitch_lod + y * row_pitch_lod
+ (x / RAW12_EXT_CLUMP_NUM_PIXELS) * RAW12_EXT_CLUMP_SIZE;
break;
}
default: {
size_t pixelSize = get_pixel_size(format);
ptr += z * slice_pitch_lod + y * row_pitch_lod + x * pixelSize;
break;
}
}
// OpenCL only supports reading floats from certain formats
switch (format->image_channel_data_type)
{
Expand Down Expand Up @@ -377,6 +427,26 @@ void read_image_pixel(void *imageData, image_descriptor *imageInfo, int x,
break;
}
#endif
case CL_UNSIGNED_INT_RAW10_EXT: {
cl_uchar *dPtr = (cl_uchar *)ptr;
i = x % RAW10_EXT_CLUMP_NUM_PIXELS;
uint8_t bit_index = i << 1;
uint16_t hi_val = dPtr[i] << 2;
uint16_t lo_val = (dPtr[4] & (0x3 << bit_index)) >> bit_index;

tempData[0] = (T)(hi_val | lo_val);
break;
}
case CL_UNSIGNED_INT_RAW12_EXT: {
cl_uchar *dPtr = (cl_uchar *)ptr;
i = x % RAW12_EXT_CLUMP_NUM_PIXELS;
uint8_t bit_index = i << 2;
uint16_t hi_val = dPtr[i] << 4;
uint16_t lo_val = (dPtr[2] & (0xF << bit_index)) >> bit_index;

tempData[0] = (T)(hi_val | lo_val);
break;
}
}


Expand Down
2 changes: 2 additions & 0 deletions test_common/harness/integer_ops_test_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "conversions.h"
#include "testHarness.h"

#include <vector>

// TODO: expand usage to other tests.

template <typename T> struct TestInfo
Expand Down
2 changes: 1 addition & 1 deletion test_common/harness/os_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ static std::string _err_msg(int err, int level)

#if (defined(__ANDROID__) && __ANDROID_API__ < 23) \
|| ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE) \
|| (defined(_GNU_SOURCE) && !defined(__GLIBC__))
|| (defined(_GNU_SOURCE) && !defined(__GLIBC__) && !defined(__USE_GNU))

// XSI version of strerror_r.
#warning Not tested!
Expand Down
11 changes: 6 additions & 5 deletions test_common/harness/rounding_mode.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
// Copyright (c) 2017-2024 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -42,10 +42,11 @@ typedef enum
kshort = 3,
kuint = 4,
kint = 5,
kfloat = 6,
kdouble = 7,
kulong = 8,
klong = 9,
khalf = 6,
kfloat = 7,
kdouble = 8,
kulong = 9,
klong = 10,

// This goes last
kTypeCount
Expand Down
1 change: 1 addition & 0 deletions test_conformance/SVM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set(MODULE_NAME SVM)
set(${MODULE_NAME}_SOURCES
main.cpp
test_allocate_shared_buffer.cpp
test_allocate_shared_buffer_negative.cpp
test_byte_granularity.cpp
test_cross_buffer_pointers.cpp
test_enqueue_api.cpp
Expand Down
4 changes: 4 additions & 0 deletions test_conformance/SVM/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ extern int test_svm_shared_address_space_fine_grain(cl_device_id deviceID, cl
extern int test_svm_cross_buffer_pointers_coarse_grain(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_svm_pointer_passing(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_svm_allocate_shared_buffer(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_svm_allocate_shared_buffer_negative(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_svm_shared_sub_buffers(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_svm_enqueue_api(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_svm_migrate(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
Expand Down
29 changes: 15 additions & 14 deletions test_conformance/SVM/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,20 +261,21 @@ cl_int create_cl_objects(cl_device_id device_from_harness, const char** ppCodeSt
}

test_definition test_list[] = {
ADD_TEST( svm_byte_granularity),
ADD_TEST( svm_set_kernel_exec_info_svm_ptrs ),
ADD_TEST( svm_fine_grain_memory_consistency ),
ADD_TEST( svm_fine_grain_sync_buffers ),
ADD_TEST( svm_shared_address_space_fine_grain ),
ADD_TEST( svm_shared_sub_buffers ),
ADD_TEST( svm_shared_address_space_fine_grain_buffers ),
ADD_TEST( svm_allocate_shared_buffer ),
ADD_TEST( svm_shared_address_space_coarse_grain_old_api ),
ADD_TEST( svm_shared_address_space_coarse_grain_new_api ),
ADD_TEST( svm_cross_buffer_pointers_coarse_grain ),
ADD_TEST( svm_pointer_passing ),
ADD_TEST( svm_enqueue_api ),
ADD_TEST_VERSION( svm_migrate, Version(2, 1)),
ADD_TEST(svm_byte_granularity),
ADD_TEST(svm_set_kernel_exec_info_svm_ptrs),
ADD_TEST(svm_fine_grain_memory_consistency),
ADD_TEST(svm_fine_grain_sync_buffers),
ADD_TEST(svm_shared_address_space_fine_grain),
ADD_TEST(svm_shared_sub_buffers),
ADD_TEST(svm_shared_address_space_fine_grain_buffers),
ADD_TEST(svm_allocate_shared_buffer),
ADD_TEST(svm_allocate_shared_buffer_negative),
ADD_TEST(svm_shared_address_space_coarse_grain_old_api),
ADD_TEST(svm_shared_address_space_coarse_grain_new_api),
ADD_TEST(svm_cross_buffer_pointers_coarse_grain),
ADD_TEST(svm_pointer_passing),
ADD_TEST(svm_enqueue_api),
ADD_TEST_VERSION(svm_migrate, Version(2, 1)),
};

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

0 comments on commit e8c34d6

Please sign in to comment.