Skip to content

Commit

Permalink
Merge branch 'main' into modernization_semaphores
Browse files Browse the repository at this point in the history
test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp
  • Loading branch information
shajder committed Aug 1, 2024
2 parents 2e88d72 + 284f757 commit 0e57196
Show file tree
Hide file tree
Showing 148 changed files with 16,058 additions and 3,206 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
10 changes: 4 additions & 6 deletions presubmit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ cmake .. -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} \
-DOPENCL_ICD_LOADER_HEADERS_DIR=${TOP}/OpenCL-Headers/
cmake --build . -j2
cmake --build . --parallel

#Vulkan Loader
cd ${TOP}
Expand All @@ -78,7 +78,7 @@ cmake .. -G Ninja \
-DBUILD_WSI_XCB_SUPPORT=OFF \
-DBUILD_WSI_WAYLAND_SUPPORT=OFF \
-C helper.cmake ..
cmake --build . -j2
cmake --build . --parallel

# Build CTS
cd ${TOP}
Expand All @@ -87,14 +87,12 @@ mkdir build
cd build
if [[ ${RUNNER_OS} == "Windows" ]]; then
CMAKE_OPENCL_LIBRARIES_OPTION="OpenCL"
CMAKE_CACHE_OPTIONS=""
else
CMAKE_OPENCL_LIBRARIES_OPTION="-lOpenCL -lpthread"
CMAKE_CACHE_OPTIONS="-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache"
fi
cmake .. -G Ninja \
-DCMAKE_BUILD_TYPE="${BUILD_CONFIG}" \
${CMAKE_CACHE_OPTIONS} \
-DCMAKE_CACHE_OPTIONS="-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache" \
-DCL_INCLUDE_DIR=${TOP}/OpenCL-Headers \
-DCL_LIB_DIR=${TOP}/OpenCL-ICD-Loader/build \
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} \
Expand All @@ -105,4 +103,4 @@ cmake .. -G Ninja \
-DVULKAN_IS_SUPPORTED=${BUILD_VULKAN_TEST} \
-DVULKAN_INCLUDE_DIR=${TOP}/Vulkan-Headers/include/ \
-DVULKAN_LIB_DIR=${TOP}/Vulkan-Loader/build/loader/
cmake --build . -j3
cmake --build . --parallel
41 changes: 0 additions & 41 deletions readme-spir-v-binaries.txt

This file was deleted.

41 changes: 0 additions & 41 deletions test_common/config.hpp

This file was deleted.

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
3 changes: 0 additions & 3 deletions test_common/harness/deviceInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
#ifndef _deviceInfo_h
#define _deviceInfo_h

// Configuration
#include "../config.hpp"

#include <string>

#include <CL/opencl.h>
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
3 changes: 0 additions & 3 deletions test_common/harness/kernelHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
#ifndef _kernelHelpers_h
#define _kernelHelpers_h

// Configuration
#include "../config.hpp"

#include "compat.h"
#include "testHarness.h"

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
Loading

0 comments on commit 0e57196

Please sign in to comment.