mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
External sharing new updates (#1482)
* Fix enqueue_flags test to use correct barrier type. Currently, enqueue_flags test uses CLK_LOCAL_MEM_FENCE. Use CLK_GLOBAL_MEM_FENCE instead as all threads across work-groups need to wait here. * Add check for support for Read-Wrie images Read-Write images have required OpenCL 2.x. Read-Write image tests are already being skipped for 1.x devices. With OpenCL 3.0, read-write images being optional, the tests should be run or skipped depending on the implementation support. Add a check to decide if Read-Write images are supported or required to be supported depending on OpenCL version and decide if the tests should be run on skipped. Fixes issue #894 * Fix formatting in case of Read-Write image checks. Fix formatting in case of Read-write image checks. Also, combine two ifs into one in case of kerne_read_write tests * Fix some more formatting for RW-image checks Remove unnecessary spaces at various places. Also, fix lengthy lines. * Fix malloc-size calculation in test imagedim unsigned char size is silently assumed to be 1 in imagedim test of test_basic. Pass sizeof(type) in malloc size calculation. Also, change loop variable from signed to unsigned. Add checks for null pointer for malloced memory. * Initial CTS for external sharing extensions Initial set of tests for below extensions with Vulkan as producer 1. cl_khr_external_memory 2. cl_khr_external_memory_win32 3. cl_khr_external_memory_opaque_fd 4. cl_khr_external_semaphore 5. cl_khr_external_semaphore_win32 6. cl_khr_external_semaphore_opaque_fd * Updates to external sharing CTS Updates to external sharing CTS 1. Fix some build issues to remove unnecessary, non-existent files 2. Add new tests for platform and device queries. 3. Some added checks for VK Support. * Update CTS build script for Vulkan Headers Update CTS build to clone Vulkan Headers repo and pass it to CTS build in preparation for external memory and semaphore tests * Fix Vulkan header path Fix Vulkan header include path. * Add Vulkan loader dependency Vulkan loader is required to build test_vulkan of OpenCL-CTS. Clone and build Vulkan loader as prerequisite to OpenCL-CTS. * Fix Vulkan loader path in test_vulkan Remove arch/os suffix in Vulkan loader path to match vulkan loader repo build. * Fix warnings around getHandle API. Return type of getHandle is defined differently based on win or linux builds. Use appropriate guards when using API at other places. While at it remove duplicate definition of ARRAY_SIZE. * Use ARRAY_SIZE in harness. Use already defined ARRAY_SIZE macro from test_harness. * Fix build issues for test_vulkan Fix build issues for test_vulkan 1. Add cl_ext.h in common files 2. Replace cl_mem_properties_khr with cl_mem_properties 3. Replace cl_external_mem_handle_type_khr with cl_external_memory_handle_type_khr 4. Type-cast malloc as required. * Fix code formatting. Fix code formatting to get CTS CI builds clean. * Fix formatting fixes part-2 Another set of formatting fixes. * Fix code formatting part-3 Some more code formatting fixes. * Fix code formatting issues part-4 More code formatting fixes. * Formatting fixes part-5 Some more formatting fixes * Fix formatting part-6 More formatting fixes continued. * Code formatting fixes part-7 Code formatting fixes for image * Code formatting fixes part-8 Fixes for platform and device query tests. * Code formatting fixes part-9 More formatting fixes for vulkan_wrapper * Code formatting fixes part-10 More fixes to wrapper header * Code formatting fixes part-11 Formatting fixes for api_list * Code formatting fixes part-12 Formatting fixes for api_list_map. * Code formatting changes part-13 Code formatting changes for utility. * Code formatting fixes part-15 Formatting fixes for wrapper. * Misc Code formatting fixes Some more misc code formatting fixes. * Fix build breaks due to code formatting Fix build issues arised with recent code formatting issues. * Fix presubmit script after merge Fix presubmit script after merge conflicts. * Fix Vulkan loader build in presubmit script. Use cmake ninja and appropriate toolchain for Vulkan loader dependency to fix linking issue on arm/aarch64. * Use static array sizes Use static array sizes to fix windows builds. * Some left-out formatting fixes. Fix remaining formatting issues. * Fix harness header path Fix harness header path While at it, remove Misc and test pragma. * Add/Fix license information Add Khronos License info for test_vulkan. Replace Apple license with Khronos as applicable. * Fix headers for Mac OSX builds. Use appropriate headers for Mac OSX builds * Fix Mac OSX builds. Use appropriate headers for Mac OSX builds. Also, fix some build issues due to type-casting. * Fix new code formatting issues Fix new code formatting issues with recent MacOS fixes. * Add back missing case statement Add back missing case statement that was accidentally removed. * Disable USE_GAS for Vulkan Loader build. Disable USE_GAS for Vulkan Loader build to fix aarch64 build. * Fixes to OpenCL external sharing tests Fix clReleaseSemaphore() API. Fix copyright year. Some other minor fixes. * Improvements to OpenCL external sharing CTS Use SPIR-V shaders instead of NV extension path from GLSL to Vulkan shaders. Fixes for lower end GPUs to use limited memory. Update copy-right year at some more places. * Fix new code formatting issues. Fix code formatting issues with recent changes for external sharing tests. * More formatting fixes. More formatting fixes for recent updates to external sharing tests. * Final code formatting fixes. Minor formatting fixes to get format checks clean.
This commit is contained in:
@@ -25,8 +25,6 @@
|
||||
#define MAX_2D_IMAGE_ELEMENT_SIZE 16
|
||||
#define MAX_2D_IMAGE_MIP_LEVELS 11
|
||||
#define MAX_2D_IMAGE_DESCRIPTORS MAX_2D_IMAGES *MAX_2D_IMAGE_MIP_LEVELS
|
||||
#define GLSL_FORMAT_STRING "<GLSL_FORMAT>"
|
||||
#define GLSL_TYPE_PREFIX_STRING "<GLSL_TYPE_PREFIX>"
|
||||
#define NUM_THREADS_PER_GROUP_X 32
|
||||
#define NUM_THREADS_PER_GROUP_Y 32
|
||||
#define NUM_BLOCKS(size, blockSize) \
|
||||
@@ -54,61 +52,8 @@ struct Params
|
||||
}
|
||||
static cl_uchar uuid[CL_UUID_SIZE_KHR];
|
||||
static cl_device_id deviceId = NULL;
|
||||
|
||||
static const char *vkImage2DShader =
|
||||
"#version 450\n"
|
||||
"#extension GL_ARB_separate_shader_objects : enable\n"
|
||||
"#extension GL_NV_gpu_shader5 : enable\n"
|
||||
"layout(binding = 0) buffer Params\n"
|
||||
"{\n"
|
||||
" uint32_t numImage2DDescriptors;\n"
|
||||
"};\n"
|
||||
"layout(binding = 1, " GLSL_FORMAT_STRING
|
||||
") uniform " GLSL_TYPE_PREFIX_STRING "image2D image2DList[" STRING(
|
||||
MAX_2D_IMAGE_DESCRIPTORS) "];\n"
|
||||
"layout(local_size_x = 32, local_size_y = "
|
||||
"32) in;\n"
|
||||
"void main() {\n"
|
||||
" uvec3 numThreads = gl_NumWorkGroups * "
|
||||
"gl_WorkGroupSize;\n"
|
||||
" for (uint32_t image2DIdx = 0; "
|
||||
"image2DIdx < numImage2DDescriptors; "
|
||||
"image2DIdx++)"
|
||||
" {\n"
|
||||
" ivec2 imageDim = "
|
||||
"imageSize(image2DList[image2DIdx]);\n"
|
||||
" uint32_t heightBy2 = imageDim.y / "
|
||||
"2;\n"
|
||||
" for (uint32_t row = "
|
||||
"gl_GlobalInvocationID.y; row < heightBy2; "
|
||||
"row += numThreads.y)"
|
||||
" {\n"
|
||||
" for (uint32_t col = "
|
||||
"gl_GlobalInvocationID.x; col < imageDim.x; "
|
||||
"col += numThreads.x)"
|
||||
" {\n"
|
||||
" ivec2 coordsA = ivec2(col, "
|
||||
"row);\n"
|
||||
" ivec2 coordsB = ivec2(col, "
|
||||
"imageDim.y - row - 1);\n"
|
||||
" " GLSL_TYPE_PREFIX_STRING
|
||||
"vec4 dataA = "
|
||||
"imageLoad(image2DList[image2DIdx], "
|
||||
"coordsA);\n"
|
||||
" " GLSL_TYPE_PREFIX_STRING
|
||||
"vec4 dataB = "
|
||||
"imageLoad(image2DList[image2DIdx], "
|
||||
"coordsB);\n"
|
||||
" "
|
||||
"imageStore(image2DList[image2DIdx], "
|
||||
"coordsA, dataB);\n"
|
||||
" "
|
||||
"imageStore(image2DList[image2DIdx], "
|
||||
"coordsB, dataA);\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}\n";
|
||||
size_t max_width = MAX_2D_IMAGE_WIDTH;
|
||||
size_t max_height = MAX_2D_IMAGE_HEIGHT;
|
||||
|
||||
const char *kernel_text_numImage_1 = " \
|
||||
__constant sampler_t smpImg = CLK_NORMALIZED_COORDS_FALSE|CLK_ADDRESS_NONE|CLK_FILTER_NEAREST;\n\
|
||||
@@ -268,8 +213,8 @@ int run_test_with_two_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
VULKAN_MEMORY_TYPE_PROPERTY_HOST_VISIBLE_COHERENT));
|
||||
vkParamsDeviceMemory.bindBuffer(vkParamsBuffer);
|
||||
|
||||
uint64_t maxImage2DSize = MAX_2D_IMAGE_WIDTH * MAX_2D_IMAGE_HEIGHT
|
||||
* MAX_2D_IMAGE_ELEMENT_SIZE * 2;
|
||||
uint64_t maxImage2DSize =
|
||||
max_width * max_height * MAX_2D_IMAGE_ELEMENT_SIZE * 2;
|
||||
VulkanBuffer vkSrcBuffer(vkDevice, maxImage2DSize);
|
||||
VulkanDeviceMemory vkSrcBufferDeviceMemory(
|
||||
vkDevice, vkSrcBuffer.getSize(),
|
||||
@@ -310,6 +255,12 @@ int run_test_with_two_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
clCl2VkExternalSemaphore = new clExternalSemaphore(
|
||||
vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
|
||||
|
||||
std::vector<VulkanDeviceMemory *> vkNonDedicatedImage2DListDeviceMemory1;
|
||||
std::vector<VulkanDeviceMemory *> vkNonDedicatedImage2DListDeviceMemory2;
|
||||
std::vector<clExternalMemoryImage *> nonDedicatedExternalMemory1;
|
||||
std::vector<clExternalMemoryImage *> nonDedicatedExternalMemory2;
|
||||
std::vector<char> vkImage2DShader;
|
||||
|
||||
for (size_t fIdx = 0; fIdx < vkFormatList.size(); fIdx++)
|
||||
{
|
||||
VulkanFormat vkFormat = vkFormatList[fIdx];
|
||||
@@ -317,15 +268,13 @@ int run_test_with_two_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
uint32_t elementSize = getVulkanFormatElementSize(vkFormat);
|
||||
ASSERT_LEQ(elementSize, (uint32_t)MAX_2D_IMAGE_ELEMENT_SIZE);
|
||||
log_info("elementSize= %d\n", elementSize);
|
||||
std::map<std::string, std::string> patternToSubstituteMap;
|
||||
patternToSubstituteMap[GLSL_FORMAT_STRING] =
|
||||
getVulkanFormatGLSLFormat(vkFormat);
|
||||
patternToSubstituteMap[GLSL_TYPE_PREFIX_STRING] =
|
||||
getVulkanFormatGLSLTypePrefix(vkFormat);
|
||||
|
||||
VulkanShaderModule vkImage2DShaderModule(
|
||||
vkDevice,
|
||||
prepareVulkanShader(vkImage2DShader, patternToSubstituteMap));
|
||||
std::string fileName = "image2D_"
|
||||
+ std::string(getVulkanFormatGLSLFormat(vkFormat)) + ".spv";
|
||||
log_info("Load %s file", fileName.c_str());
|
||||
vkImage2DShader = readFile(fileName);
|
||||
VulkanShaderModule vkImage2DShaderModule(vkDevice, vkImage2DShader);
|
||||
|
||||
VulkanComputePipeline vkComputePipeline(vkDevice, vkPipelineLayout,
|
||||
vkImage2DShaderModule);
|
||||
|
||||
@@ -333,13 +282,13 @@ int run_test_with_two_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
{
|
||||
uint32_t width = widthList[wIdx];
|
||||
log_info("Width: %d\n", width);
|
||||
ASSERT_LEQ(width, (uint32_t)MAX_2D_IMAGE_WIDTH);
|
||||
if (width > max_width) continue;
|
||||
region[0] = width;
|
||||
for (size_t hIdx = 0; hIdx < ARRAY_SIZE(heightList); hIdx++)
|
||||
{
|
||||
uint32_t height = heightList[hIdx];
|
||||
log_info("Height: %d", height);
|
||||
ASSERT_LEQ(height, (uint32_t)MAX_2D_IMAGE_HEIGHT);
|
||||
if (height > max_height) continue;
|
||||
region[1] = height;
|
||||
|
||||
uint32_t numMipLevels = 1;
|
||||
@@ -418,14 +367,6 @@ int run_test_with_two_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
const VulkanMemoryTypeList &memoryTypeList =
|
||||
vkDummyImage2D.getMemoryTypeList();
|
||||
|
||||
std::vector<VulkanDeviceMemory *>
|
||||
vkNonDedicatedImage2DListDeviceMemory1;
|
||||
std::vector<VulkanDeviceMemory *>
|
||||
vkNonDedicatedImage2DListDeviceMemory2;
|
||||
std::vector<clExternalMemoryImage *>
|
||||
nonDedicatedExternalMemory1;
|
||||
std::vector<clExternalMemoryImage *>
|
||||
nonDedicatedExternalMemory2;
|
||||
for (size_t mtIdx = 0; mtIdx < memoryTypeList.size();
|
||||
mtIdx++)
|
||||
{
|
||||
@@ -834,6 +775,8 @@ int run_test_with_two_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vkImage2DShader.clear();
|
||||
}
|
||||
CLEANUP:
|
||||
if (clVk2CLExternalSemaphore) delete clVk2CLExternalSemaphore;
|
||||
@@ -866,8 +809,8 @@ int run_test_with_one_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
VULKAN_MEMORY_TYPE_PROPERTY_HOST_VISIBLE_COHERENT));
|
||||
vkParamsDeviceMemory.bindBuffer(vkParamsBuffer);
|
||||
|
||||
uint64_t maxImage2DSize = MAX_2D_IMAGE_WIDTH * MAX_2D_IMAGE_HEIGHT
|
||||
* MAX_2D_IMAGE_ELEMENT_SIZE * 2;
|
||||
uint64_t maxImage2DSize =
|
||||
max_width * max_height * MAX_2D_IMAGE_ELEMENT_SIZE * 2;
|
||||
VulkanBuffer vkSrcBuffer(vkDevice, maxImage2DSize);
|
||||
VulkanDeviceMemory vkSrcBufferDeviceMemory(
|
||||
vkDevice, vkSrcBuffer.getSize(),
|
||||
@@ -908,6 +851,12 @@ int run_test_with_one_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
clCl2VkExternalSemaphore = new clExternalSemaphore(
|
||||
vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
|
||||
|
||||
std::vector<VulkanDeviceMemory *> vkNonDedicatedImage2DListDeviceMemory1;
|
||||
std::vector<VulkanDeviceMemory *> vkNonDedicatedImage2DListDeviceMemory2;
|
||||
std::vector<clExternalMemoryImage *> nonDedicatedExternalMemory1;
|
||||
std::vector<clExternalMemoryImage *> nonDedicatedExternalMemory2;
|
||||
std::vector<char> vkImage2DShader;
|
||||
|
||||
for (size_t fIdx = 0; fIdx < vkFormatList.size(); fIdx++)
|
||||
{
|
||||
VulkanFormat vkFormat = vkFormatList[fIdx];
|
||||
@@ -915,15 +864,13 @@ int run_test_with_one_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
uint32_t elementSize = getVulkanFormatElementSize(vkFormat);
|
||||
ASSERT_LEQ(elementSize, (uint32_t)MAX_2D_IMAGE_ELEMENT_SIZE);
|
||||
log_info("elementSize= %d\n", elementSize);
|
||||
std::map<std::string, std::string> patternToSubstituteMap;
|
||||
patternToSubstituteMap[GLSL_FORMAT_STRING] =
|
||||
getVulkanFormatGLSLFormat(vkFormat);
|
||||
patternToSubstituteMap[GLSL_TYPE_PREFIX_STRING] =
|
||||
getVulkanFormatGLSLTypePrefix(vkFormat);
|
||||
|
||||
VulkanShaderModule vkImage2DShaderModule(
|
||||
vkDevice,
|
||||
prepareVulkanShader(vkImage2DShader, patternToSubstituteMap));
|
||||
std::string fileName = "image2D_"
|
||||
+ std::string(getVulkanFormatGLSLFormat(vkFormat)) + ".spv";
|
||||
log_info("Load %s file", fileName.c_str());
|
||||
vkImage2DShader = readFile(fileName);
|
||||
VulkanShaderModule vkImage2DShaderModule(vkDevice, vkImage2DShader);
|
||||
|
||||
VulkanComputePipeline vkComputePipeline(vkDevice, vkPipelineLayout,
|
||||
vkImage2DShaderModule);
|
||||
|
||||
@@ -931,13 +878,13 @@ int run_test_with_one_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
{
|
||||
uint32_t width = widthList[wIdx];
|
||||
log_info("Width: %d\n", width);
|
||||
ASSERT_LEQ(width, (uint32_t)MAX_2D_IMAGE_WIDTH);
|
||||
if (width > max_width) continue;
|
||||
region[0] = width;
|
||||
for (size_t hIdx = 0; hIdx < ARRAY_SIZE(heightList); hIdx++)
|
||||
{
|
||||
uint32_t height = heightList[hIdx];
|
||||
log_info("Height: %d\n", height);
|
||||
ASSERT_LEQ(height, (uint32_t)MAX_2D_IMAGE_HEIGHT);
|
||||
if (height > max_height) continue;
|
||||
region[1] = height;
|
||||
|
||||
uint32_t numMipLevels = 1;
|
||||
@@ -1016,14 +963,6 @@ int run_test_with_one_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
const VulkanMemoryTypeList &memoryTypeList =
|
||||
vkDummyImage2D.getMemoryTypeList();
|
||||
|
||||
std::vector<VulkanDeviceMemory *>
|
||||
vkNonDedicatedImage2DListDeviceMemory1;
|
||||
std::vector<VulkanDeviceMemory *>
|
||||
vkNonDedicatedImage2DListDeviceMemory2;
|
||||
std::vector<clExternalMemoryImage *>
|
||||
nonDedicatedExternalMemory1;
|
||||
std::vector<clExternalMemoryImage *>
|
||||
nonDedicatedExternalMemory2;
|
||||
for (size_t mtIdx = 0; mtIdx < memoryTypeList.size();
|
||||
mtIdx++)
|
||||
{
|
||||
@@ -1368,6 +1307,7 @@ int run_test_with_one_queue(cl_context &context, cl_command_queue &cmd_queue1,
|
||||
}
|
||||
}
|
||||
}
|
||||
vkImage2DShader.clear();
|
||||
}
|
||||
CLEANUP:
|
||||
if (clVk2CLExternalSemaphore) delete clVk2CLExternalSemaphore;
|
||||
@@ -1494,6 +1434,14 @@ int test_image_common(cl_device_id device_, cl_context context_,
|
||||
goto CLEANUP;
|
||||
}
|
||||
deviceId = devices[device_no];
|
||||
err = setMaxImageDimensions(deviceId, max_width, max_height);
|
||||
if (CL_SUCCESS != err)
|
||||
{
|
||||
print_error(err, "error setting max image dimensions");
|
||||
goto CLEANUP;
|
||||
}
|
||||
log_info("Set max_width to %lu and max_height to %lu\n", max_width,
|
||||
max_height);
|
||||
context = clCreateContextFromType(contextProperties, CL_DEVICE_TYPE_GPU,
|
||||
NULL, NULL, &err);
|
||||
if (CL_SUCCESS != err)
|
||||
|
||||
Reference in New Issue
Block a user