Skip to content

Commit

Permalink
Merge branch 'KhronosGroup:main' into bugfix_basic_fpmath
Browse files Browse the repository at this point in the history
  • Loading branch information
zzk0 authored Feb 10, 2025
2 parents 5c1e40a + a8b32b2 commit bc9c1cb
Show file tree
Hide file tree
Showing 84 changed files with 715 additions and 865 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang"
add_cxx_flag_if_supported(-Wno-error=cpp) # Allow #warning directive
add_cxx_flag_if_supported(-Wno-unknown-pragmas) # Issue #785
add_cxx_flag_if_supported(-Wno-error=asm-operand-widths) # Issue #784
add_cxx_flag_if_supported(-Wno-strict-aliasing) # Issue 2234

# -msse -mfpmath=sse to force gcc to use sse for float math,
# avoiding excess precision problems that cause tests like int2float
Expand Down
1 change: 1 addition & 0 deletions test_common/harness/errorHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const char *IGetErrorString(int clErrorCode)
return "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR";
case CL_INVALID_COMMAND_BUFFER_KHR:
return "CL_INVALID_COMMAND_BUFFER_KHR";
case CL_INVALID_SEMAPHORE_KHR: return "CL_INVALID_SEMAPHORE_KHR";
default: return "(unknown)";
}
}
Expand Down
16 changes: 16 additions & 0 deletions test_common/harness/imageHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2415,6 +2415,12 @@ int debug_find_vector_in_image(void *imagePtr, image_descriptor *imageInfo,
(imageInfo->height >> lod) ? (imageInfo->height >> lod) : 1;
depth = (imageInfo->depth >> lod) ? (imageInfo->depth >> lod) : 1;
break;
default:
log_error("ERROR: Invalid imageInfo->type = %d\n", imageInfo->type);
width = 0;
depth = 0;
height = 0;
break;
}

row_pitch = width * get_pixel_size(imageInfo->format);
Expand Down Expand Up @@ -3661,6 +3667,11 @@ void copy_image_data(image_descriptor *srcImageInfo,
? (srcImageInfo->height >> src_lod)
: 1;
break;
default:
log_error("ERROR: Invalid srcImageInfo->type = %d\n",
srcImageInfo->type);
src_lod = 0;
break;
}
src_mip_level_offset = compute_mip_level_offset(srcImageInfo, src_lod);
src_row_pitch_lod =
Expand Down Expand Up @@ -3707,6 +3718,11 @@ void copy_image_data(image_descriptor *srcImageInfo,
? (dstImageInfo->height >> dst_lod)
: 1;
break;
default:
log_error("ERROR: Invalid dstImageInfo->num_mip_levels = %d\n",
dstImageInfo->num_mip_levels);
dst_lod = 0;
break;
}
dst_mip_level_offset = compute_mip_level_offset(dstImageInfo, dst_lod);
dst_row_pitch_lod =
Expand Down
2 changes: 1 addition & 1 deletion test_common/harness/typeWrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ cl_int clProtectedImage::Create(cl_context context,
const cl_image_format *fmt, size_t width,
size_t height, size_t depth, size_t arraySize)
{
cl_int error;
cl_int error = 0;
#if defined(__APPLE__)
int protect_pages = 1;
cl_device_id devices[16];
Expand Down
4 changes: 2 additions & 2 deletions test_conformance/SVM/test_enqueue_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ REGISTER_TEST(svm_enqueue_api)
error = clSetUserEventStatus(userEvent, CL_COMPLETE);
test_error(error, "clSetUserEventStatus failed");

cl_uchar *src_ptr;
cl_uchar *dst_ptr;
cl_uchar *src_ptr = nullptr;
cl_uchar *dst_ptr = nullptr;
if (test_case.srcAlloc == host)
{
src_ptr = srcHostData.data();
Expand Down
60 changes: 59 additions & 1 deletion test_conformance/api/test_queue.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2020 The Khronos Group Inc.
// Copyright (c) 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 @@ -58,3 +58,61 @@ REGISTER_TEST(queue_flush_on_release)

return success ? TEST_PASS : TEST_FAIL;
}

REGISTER_TEST(multi_queue_flush_on_release)
{
cl_int err;

// Create A command queue
cl_command_queue queue_A = clCreateCommandQueue(context, device, 0, &err);
test_error(err, "Could not create command queue A");

// Create B command queue
cl_command_queue queue_B = clCreateCommandQueue(context, device, 0, &err);
test_error(err, "Could not create command queue B");

// Create a kernel
clProgramWrapper program;
clKernelWrapper kernel;
const char *source = "void kernel test(){}";
err = create_single_kernel_helper(context, &program, &kernel, 1, &source,
"test");
test_error(err, "Could not create kernel");

// Enqueue the kernel on queue_A and obtain event to synchronize with
// queue_B
size_t gws = num_elements;
clEventWrapper event_A;
err = clEnqueueNDRangeKernel(queue_A, kernel, 1, nullptr, &gws, nullptr, 0,
nullptr, &event_A);
test_error(err, "Could not enqueue kernel");

// Enqueue the kernel on queue_B using event_A for synchronization and
// create event_B to track completion
clEventWrapper event_B;
err = clEnqueueNDRangeKernel(queue_B, kernel, 1, nullptr, &gws, nullptr, 1,
&event_A, &event_B);
test_error(err, "Could not enqueue kernel");

// Release queue_A, which performs an implicit flush to issue any previously
// queued OpenCL commands
err = clReleaseCommandQueue(queue_A);
test_error(err, "clReleaseCommandQueue failed");

err = clFlush(queue_B);
test_error(err, "clFlush failed");

// Wait for kernel to execute since the queue must flush on release
bool success = poll_until(2000, 50, [&event_B]() {
cl_int status;
cl_int err = clGetEventInfo(event_B, CL_EVENT_COMMAND_EXECUTION_STATUS,
sizeof(cl_int), &status, nullptr);
if ((err != CL_SUCCESS) || (status != CL_COMPLETE))
{
return false;
}
return true;
});

return success ? TEST_PASS : TEST_FAIL;
}
2 changes: 1 addition & 1 deletion test_conformance/api/test_wg_suggested_local_work_size.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ int do_test_work_group_suggested_local_size(
bool (*skip_cond)(size_t), size_t start, size_t end, size_t incr,
cl_ulong max_local_mem_size, size_t global_work_offset[], num_dims dim)
{
int err;
int err = 0;
size_t test_values[] = { 1, 1, 1 };
std::string kernel_names[6] = {
"test_wg_scan_local_work_group_size",
Expand Down
6 changes: 6 additions & 0 deletions test_conformance/basic/test_imagereadwrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ test_imagereadwrite(cl_device_id device, cl_context context, cl_command_queue qu
}
outp = (void *)rgbafp_outptr;
break;
default:
log_error("ERROR Invalid j = %d\n", j);
elem_size = 0;
p = nullptr;
outp = nullptr;
break;
}

const char* update_packed_pitch_name = "";
Expand Down
6 changes: 6 additions & 0 deletions test_conformance/basic/test_imagereadwrite3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ test_imagereadwrite3d(cl_device_id device, cl_context context, cl_command_queue
}
outp = (void *)rgbafp_outptr;
break;
default:
log_error("ERROR Invalid j = %d\n", j);
elem_size = 0;
p = nullptr;
outp = nullptr;
break;
}

const char* update_packed_pitch_name = "";
Expand Down
4 changes: 2 additions & 2 deletions test_conformance/buffers/test_buffer_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,8 +852,8 @@ int test_buffer_write_struct( cl_device_id deviceID, cl_context context, cl_comm
buffers[0] =
clCreateBuffer(context, flag_set[src_flag_id],
ptrSizes[i] * num_elements, NULL, &err);
if ( err ){
align_free( outptr[i] );
if (err)
{
print_error(err, " clCreateBuffer failed\n" );
free_mtdata(d);
return -1;
Expand Down
5 changes: 4 additions & 1 deletion test_conformance/common/vulkan_wrapper/vulkan_api_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@
VK_FUNC_DECL(vkGetPhysicalDeviceSurfaceSupportKHR) \
VK_FUNC_DECL(vkImportSemaphoreFdKHR) \
VK_FUNC_DECL(vkGetPhysicalDeviceExternalSemaphorePropertiesKHR) \
VK_FUNC_DECL(vkGetImageSubresourceLayout)
VK_FUNC_DECL(vkGetImageSubresourceLayout) \
VK_FUNC_DECL(vkGetPhysicalDeviceExternalBufferProperties)
#define VK_WINDOWS_FUNC_LIST \
VK_FUNC_DECL(vkGetMemoryWin32HandleKHR) \
VK_FUNC_DECL(vkGetSemaphoreWin32HandleKHR) \
Expand Down Expand Up @@ -202,5 +203,7 @@
#define vkGetSemaphoreWin32HandleKHR _vkGetSemaphoreWin32HandleKHR
#define vkImportSemaphoreWin32HandleKHR _vkImportSemaphoreWin32HandleKHR
#define vkGetImageSubresourceLayout _vkGetImageSubresourceLayout
#define vkGetPhysicalDeviceExternalBufferProperties \
_vkGetPhysicalDeviceExternalBufferProperties

#endif //_vulkan_api_list_hpp_
22 changes: 19 additions & 3 deletions test_conformance/common/vulkan_wrapper/vulkan_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ getDefaultVulkanQueueFamilyToQueueCountMap()
}

const std::vector<VulkanExternalMemoryHandleType>
getSupportedVulkanExternalMemoryHandleTypeList()
getSupportedVulkanExternalMemoryHandleTypeList(
const VulkanPhysicalDevice &physical_device)
{
std::vector<VulkanExternalMemoryHandleType> externalMemoryHandleTypeList;

Expand All @@ -238,8 +239,23 @@ getSupportedVulkanExternalMemoryHandleTypeList()
externalMemoryHandleTypeList.push_back(
VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT);
#else
externalMemoryHandleTypeList.push_back(
VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD);
VkPhysicalDeviceExternalBufferInfo buffer_info = {};
buffer_info.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO;
buffer_info.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;

VkExternalBufferProperties buffer_properties = {};
buffer_properties.sType = VK_STRUCTURE_TYPE_EXTERNAL_BUFFER_PROPERTIES;

vkGetPhysicalDeviceExternalBufferProperties(physical_device, &buffer_info,
&buffer_properties);

if (buffer_properties.externalMemoryProperties.externalMemoryFeatures
& VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT)
{

externalMemoryHandleTypeList.push_back(
VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD);
}
#endif

return externalMemoryHandleTypeList;
Expand Down
3 changes: 2 additions & 1 deletion test_conformance/common/vulkan_wrapper/vulkan_utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ const VulkanDescriptorSetLayoutList& getEmptyVulkanDescriptorSetLayoutList();
const VulkanQueueFamilyToQueueCountMap&
getDefaultVulkanQueueFamilyToQueueCountMap();
const std::vector<VulkanExternalMemoryHandleType>
getSupportedVulkanExternalMemoryHandleTypeList();
getSupportedVulkanExternalMemoryHandleTypeList(
const VulkanPhysicalDevice& physical_device);
const std::vector<VulkanExternalSemaphoreHandleType>
getSupportedVulkanExternalSemaphoreHandleTypeList(const VulkanDevice& vkDevice);
std::vector<VulkanExternalSemaphoreHandleType>
Expand Down
10 changes: 6 additions & 4 deletions test_conformance/contractions/contractions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,16 +365,18 @@ static int ParseArgs( int argc, const char **argv )
int length_of_seed = 0;

{ // Extract the app name
strncpy( appName, argv[0], MAXPATHLEN );
strncpy(appName, argv[0], MAXPATHLEN - 1);
appName[MAXPATHLEN - 1] = '\0';

#if (defined( __APPLE__ ) || defined(__linux__) || defined(__MINGW32__))
char baseName[MAXPATHLEN];
char *base = NULL;
strncpy( baseName, argv[0], MAXPATHLEN );
strncpy(baseName, argv[0], MAXPATHLEN - 1);
baseName[MAXPATHLEN - 1] = '\0';
base = basename( baseName );
if( NULL != base )
{
strncpy( appName, base, sizeof( appName ) );
strncpy(appName, base, sizeof(appName) - 1);
appName[ sizeof( appName ) -1 ] = '\0';
}
#elif defined (_WIN32)
Expand All @@ -385,7 +387,7 @@ static int ParseArgs( int argc, const char **argv )
fname, _MAX_FNAME, ext, _MAX_EXT );
if (err == 0) { // no error
strcat (fname, ext); //just cat them, size of frame can keep both
strncpy (appName, fname, sizeof(appName));
strncpy(appName, fname, sizeof(appName) - 1);
appName[ sizeof( appName ) -1 ] = '\0';
}
#endif
Expand Down
14 changes: 10 additions & 4 deletions test_conformance/conversions/basic_test_conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,9 @@ cl_program MakeProgram(Type outType, Type inType, SaturationMode sat,
char inName[32];
char outName[32];
strncpy(inName, gTypeNames[inType], sizeof(inName));
inName[sizeof(inName) - 1] = '\0';
strncpy(outName, gTypeNames[outType], sizeof(outName));
outName[sizeof(outName) - 1] = '\0';
sprintf(testName, "test_implicit_%s_%s", outName, inName);

source << "__kernel void " << testName << "( __global " << inName
Expand All @@ -1473,17 +1475,21 @@ cl_program MakeProgram(Type outType, Type inType, SaturationMode sat,
switch (vectorSizetmp)
{
case 1:
strncpy(inName, gTypeNames[inType], sizeof(inName));
strncpy(outName, gTypeNames[outType], sizeof(outName));
strncpy(inName, gTypeNames[inType], sizeof(inName) - 1);
inName[sizeof(inName) - 1] = '\0';
strncpy(outName, gTypeNames[outType], sizeof(outName) - 1);
outName[sizeof(outName) - 1] = '\0';
snprintf(convertString, sizeof(convertString), "convert_%s%s%s",
outName, gSaturationNames[sat],
gRoundingModeNames[round]);
snprintf(testName, 256, "test_%s_%s", convertString, inName);
vlog("Building %s( %s ) test\n", convertString, inName);
break;
case 3:
strncpy(inName, gTypeNames[inType], sizeof(inName));
strncpy(outName, gTypeNames[outType], sizeof(outName));
strncpy(inName, gTypeNames[inType], sizeof(inName) - 1);
inName[sizeof(inName) - 1] = '\0';
strncpy(outName, gTypeNames[outType], sizeof(outName) - 1);
outName[sizeof(outName) - 1] = '\0';
snprintf(convertString, sizeof(convertString),
"convert_%s3%s%s", outName, gSaturationNames[sat],
gRoundingModeNames[round]);
Expand Down
7 changes: 4 additions & 3 deletions test_conformance/conversions/test_conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,12 @@ static int ParseArgs(int argc, const char **argv)
#if (defined(__APPLE__) || defined(__linux__) || defined(__MINGW32__))
{ // Extract the app name
char baseName[MAXPATHLEN];
strncpy(baseName, argv[0], MAXPATHLEN);
strncpy(baseName, argv[0], MAXPATHLEN - 1);
baseName[sizeof(baseName) - 1] = '\0';
char *base = basename(baseName);
if (NULL != base)
{
strncpy(appName, base, sizeof(appName));
strncpy(appName, base, sizeof(appName) - 1);
appName[sizeof(appName) - 1] = '\0';
}
}
Expand All @@ -200,7 +201,7 @@ static int ParseArgs(int argc, const char **argv)
if (err == 0)
{ // no error
strcat(fname, ext); // just cat them, size of frame can keep both
strncpy(appName, fname, sizeof(appName));
strncpy(appName, fname, sizeof(appName) - 1);
appName[sizeof(appName) - 1] = '\0';
}
}
Expand Down
2 changes: 1 addition & 1 deletion test_conformance/events/test_event_dependencies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int test_event_enqueue_wait_for_events_run_test(

// If we are to use two devices, then get them and create a context with
// both.
cl_device_id *two_device_ids;
cl_device_id *two_device_ids = nullptr;
if (two_devices)
{
two_device_ids = (cl_device_id *)malloc(sizeof(cl_device_id) * 2);
Expand Down
8 changes: 4 additions & 4 deletions test_conformance/half/Test_vStoreHalf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ int Test_vStoreHalf_private(cl_device_id device, f2h referenceFunc,
int vectorSize, error;
cl_program programs[kVectorSizeCount + kStrangeVectorSizeCount][3];
cl_kernel kernels[kVectorSizeCount + kStrangeVectorSizeCount][3];
cl_program resetProgram;
cl_kernel resetKernel;
cl_program resetProgram = nullptr;
cl_kernel resetKernel = nullptr;

uint64_t time[kVectorSizeCount + kStrangeVectorSizeCount] = { 0 };
uint64_t min_time[kVectorSizeCount + kStrangeVectorSizeCount] = { 0 };
Expand Down Expand Up @@ -1225,8 +1225,8 @@ int Test_vStoreaHalf_private(cl_device_id device, f2h referenceFunc,
int vectorSize, error;
cl_program programs[kVectorSizeCount + kStrangeVectorSizeCount][3];
cl_kernel kernels[kVectorSizeCount + kStrangeVectorSizeCount][3];
cl_program resetProgram;
cl_kernel resetKernel;
cl_program resetProgram = nullptr;
cl_kernel resetKernel = nullptr;

uint64_t time[kVectorSizeCount + kStrangeVectorSizeCount] = { 0 };
uint64_t min_time[kVectorSizeCount + kStrangeVectorSizeCount] = { 0 };
Expand Down
5 changes: 3 additions & 2 deletions test_conformance/half/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,12 @@ static int ParseArgs( int argc, const char **argv )
#if (defined( __APPLE__ ) || defined(__linux__) || defined(__MINGW32__))
{ // Extract the app name
char baseName[ MAXPATHLEN ];
strncpy( baseName, argv[0], MAXPATHLEN );
strncpy(baseName, argv[0], MAXPATHLEN - 1);
baseName[MAXPATHLEN - 1] = '\0';
char *base = basename( baseName );
if( NULL != base )
{
strncpy( appName, base, sizeof( appName ) );
strncpy(appName, base, sizeof(appName) - 1);
appName[ sizeof( appName ) -1 ] = '\0';
}
}
Expand Down
2 changes: 1 addition & 1 deletion test_conformance/images/clCopyImage/test_copy_1D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ int test_copy_image_size_1D( cl_context context, cl_command_queue queue, image_d
size_t src_lod = 0, src_width_lod = imageInfo->width, src_row_pitch_lod;
size_t dst_lod = 0, dst_width_lod = imageInfo->width, dst_row_pitch_lod;
size_t width_lod = imageInfo->width;
size_t max_mip_level;
size_t max_mip_level = 0;

if( gTestMipmaps )
{
Expand Down
Loading

0 comments on commit bc9c1cb

Please sign in to comment.