Skip to content

Commit

Permalink
Merge branch 'main' into semaphore_device_handle_list_complement
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhiljnv authored Oct 1, 2024
2 parents b8d6253 + cd74e02 commit b896a35
Show file tree
Hide file tree
Showing 62 changed files with 1,647 additions and 1,142 deletions.
29 changes: 18 additions & 11 deletions test_common/gl/setup_osx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,28 @@

class OSXGLEnvironment : public GLEnvironment
{
public:
OSXGLEnvironment()
{
mCGLContext = NULL;
}
private:
bool mIsGlutInit;

public:
OSXGLEnvironment()
{
mCGLContext = NULL;
mIsGlutInit = false;
}

virtual int Init( int *argc, char **argv, int use_opengl_32 )
{
if (!use_opengl_32) {

// Create a GLUT window to render into
glutInit( argc, argv );
glutInitWindowSize( 512, 512 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
glutCreateWindow( "OpenCL <-> OpenGL Test" );
if (!mIsGlutInit)
{
// Create a GLUT window to render into
glutInit(argc, argv);
glutInitWindowSize(512, 512);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutCreateWindow("OpenCL <-> OpenGL Test");
mIsGlutInit = true;
}
}

else {
Expand Down
2 changes: 2 additions & 0 deletions test_common/harness/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ int feclearexcept(int excepts);

#if defined(__INTEL_COMPILER)
#include <mathimf.h>
#elif __cplusplus && defined(_MSC_VER)
#include <cmath>
#else
#include <math.h>
#endif
Expand Down
8 changes: 8 additions & 0 deletions test_common/harness/errorHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ const char *IGetErrorString(int clErrorCode)
case CL_INVALID_SPEC_ID: return "CL_INVALID_SPEC_ID";
case CL_MAX_SIZE_RESTRICTION_EXCEEDED:
return "CL_MAX_SIZE_RESTRICTION_EXCEEDED";
case CL_INCOMPATIBLE_COMMAND_QUEUE_KHR:
return "CL_INCOMPATIBLE_COMMAND_QUEUE_KHR";
case CL_INVALID_SYNC_POINT_WAIT_LIST_KHR:
return "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR";
case CL_INVALID_COMMAND_BUFFER_KHR:
return "CL_INVALID_COMMAND_BUFFER_KHR";
default: return "(unknown)";
}
}
Expand Down Expand Up @@ -190,6 +196,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 +227,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
43 changes: 40 additions & 3 deletions 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 @@ -1017,7 +1020,8 @@ size_t get_format_max_int(const cl_image_format *format)
case CL_UNORM_SHORT_565:
case CL_UNORM_SHORT_555: return 31;

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

case CL_HALF_FLOAT: return 1 << 10;

Expand Down Expand Up @@ -1049,7 +1053,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: return 0;
case CL_UNORM_INT_101010:
case CL_UNORM_INT_101010_2: return 0;

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

Expand Down Expand Up @@ -1465,6 +1470,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 +2744,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 +2915,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
3 changes: 2 additions & 1 deletion test_common/harness/kernelHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,8 @@ size_t get_pixel_bytes(const cl_image_format *fmt)
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_SNORM_INT8:
case CL_UNORM_INT8:
Expand Down
37 changes: 37 additions & 0 deletions test_common/harness/testHarness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,43 @@ cl_platform_id getPlatformFromDevice(cl_device_id deviceID)
return platform;
}

/**
* Helper to return a string containing platform information
* for the specified platform info parameter.
*/
std::string get_platform_info_string(cl_platform_id platform,
cl_platform_info param_name)
{
size_t size = 0;
int err;

if ((err = clGetPlatformInfo(platform, param_name, 0, NULL, &size))
!= CL_SUCCESS
|| size == 0)
{
throw std::runtime_error("clGetPlatformInfo failed\n");
}

std::vector<char> info(size);

if ((err = clGetPlatformInfo(platform, param_name, size, info.data(), NULL))
!= CL_SUCCESS)
{
throw std::runtime_error("clGetPlatformInfo failed\n");
}

/* The returned string does not include the null terminator. */
return std::string(info.data(), size - 1);
}

bool is_platform_extension_available(cl_platform_id platform,
const char *extensionName)
{
std::string extString =
get_platform_info_string(platform, CL_PLATFORM_EXTENSIONS);
return extString.find(extensionName) != std::string::npos;
}

void PrintArch(void)
{
vlog("sizeof( void*) = %zu\n", sizeof(void *));
Expand Down
4 changes: 4 additions & 0 deletions test_common/harness/testHarness.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ extern int gHasLong; // This is set to 1 if the device suppots long and ulong
extern bool gCoreILProgram;

extern cl_platform_id getPlatformFromDevice(cl_device_id deviceID);
extern std::string get_platform_info_string(cl_platform_id platform,
cl_platform_info param_name);
extern bool is_platform_extension_available(cl_platform_id platform,
const char *extensionName);

#if !defined(__APPLE__)
void memset_pattern4(void *, const void *, size_t);
Expand Down
Loading

0 comments on commit b896a35

Please sign in to comment.