mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Fix vulkan subtest for diffCtx and platform/device info (#2046)
Fixes: 1. Multi import diff ctx subtest which acquires/releases external memory via queue not associated with the context in which memory was imported. 2. Platform/Device info subtests to handle different platforms and availability of the query.
This commit is contained in:
@@ -517,9 +517,10 @@ int test_consistency_external_semaphore(cl_device_id deviceID,
|
||||
|
||||
// Pass invalid object to release call
|
||||
errNum = clReleaseSemaphoreKHRptr(NULL);
|
||||
test_failure_error(errNum, CL_INVALID_VALUE,
|
||||
"clReleaseSemaphoreKHRptr fails with "
|
||||
"CL_INVALID_VALUE when NULL semaphore object is passed");
|
||||
test_failure_error(
|
||||
errNum, CL_INVALID_SEMAPHORE_KHR,
|
||||
"clReleaseSemaphoreKHRptr fails with "
|
||||
"CL_INVALID_SEMAPHORE_KHR when NULL semaphore object is passed");
|
||||
|
||||
// Release both semaphore objects
|
||||
errNum = clReleaseSemaphoreKHRptr(clVk2Clsemaphore);
|
||||
|
||||
@@ -1382,7 +1382,7 @@ int run_test_with_multi_import_diff_ctx(
|
||||
"Failed to set kernel arg");
|
||||
|
||||
err = clEnqueueAcquireExternalMemObjectsKHRptr(
|
||||
cmd_queue1, 1, &buffers2[i][launchIter], 0,
|
||||
cmd_queue2, 1, &buffers2[i][launchIter], 0,
|
||||
nullptr, nullptr);
|
||||
test_error_and_cleanup(err, CLEANUP,
|
||||
"Failed to acquire buffers");
|
||||
@@ -1402,7 +1402,7 @@ int run_test_with_multi_import_diff_ctx(
|
||||
for (int i = 0; i < numBuffers; i++)
|
||||
{
|
||||
err = clEnqueueReleaseExternalMemObjectsKHRptr(
|
||||
cmd_queue1, 1, &buffers2[i][launchIter], 0,
|
||||
cmd_queue2, 1, &buffers2[i][launchIter], 0,
|
||||
nullptr, nullptr);
|
||||
test_error_and_cleanup(err, CLEANUP,
|
||||
"Failed to release buffers");
|
||||
|
||||
@@ -16,9 +16,11 @@
|
||||
|
||||
#include <CL/cl.h>
|
||||
#include <CL/cl_ext.h>
|
||||
#include "harness/deviceInfo.h"
|
||||
#include "harness/testHarness.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -51,62 +53,81 @@ _info device_info_table[] = {
|
||||
int test_platform_info(cl_device_id deviceID, cl_context _context,
|
||||
cl_command_queue _queue, int num_elements)
|
||||
{
|
||||
cl_uint num_platforms;
|
||||
cl_uint i, j;
|
||||
cl_platform_id *platforms;
|
||||
cl_uint i;
|
||||
cl_platform_id platform = getPlatformFromDevice(deviceID);
|
||||
cl_int errNum;
|
||||
cl_uint *handle_type;
|
||||
size_t handle_type_size = 0;
|
||||
cl_uint num_handles = 0;
|
||||
cl_bool external_mem_extn_available =
|
||||
is_platform_extension_available(platform, "cl_khr_external_semaphore");
|
||||
cl_bool external_sema_extn_available =
|
||||
is_platform_extension_available(platform, "cl_khr_external_memory");
|
||||
cl_bool supports_atleast_one_sema_query = false;
|
||||
|
||||
// get total # of platforms
|
||||
errNum = clGetPlatformIDs(0, NULL, &num_platforms);
|
||||
test_error(errNum, "clGetPlatformIDs (getting count) failed");
|
||||
|
||||
platforms =
|
||||
(cl_platform_id *)malloc(num_platforms * sizeof(cl_platform_id));
|
||||
if (!platforms)
|
||||
if (!external_mem_extn_available && !external_sema_extn_available)
|
||||
{
|
||||
printf("error allocating memory\n");
|
||||
exit(1);
|
||||
log_info("Platform does not support 'cl_khr_external_semaphore' "
|
||||
"and 'cl_khr_external_memory'. Skipping the test.\n");
|
||||
return TEST_SKIPPED_ITSELF;
|
||||
}
|
||||
log_info("%d platforms available\n", num_platforms);
|
||||
errNum = clGetPlatformIDs(num_platforms, platforms, NULL);
|
||||
test_error(errNum, "clGetPlatformIDs (getting IDs) failed");
|
||||
|
||||
for (i = 0; i < num_platforms; i++)
|
||||
log_info("Platform (id %lu) info:\n", (unsigned long)platform);
|
||||
|
||||
for (i = 0;
|
||||
i < sizeof(platform_info_table) / sizeof(platform_info_table[0]); i++)
|
||||
{
|
||||
log_info("Platform%d (id %lu) info:\n", i, (unsigned long)platforms[i]);
|
||||
for (j = 0;
|
||||
j < sizeof(platform_info_table) / sizeof(platform_info_table[0]);
|
||||
j++)
|
||||
{
|
||||
errNum =
|
||||
clGetPlatformInfo(platforms[i], platform_info_table[j].info, 0,
|
||||
NULL, &handle_type_size);
|
||||
test_error(errNum, "clGetPlatformInfo failed");
|
||||
num_handles = handle_type_size / sizeof(cl_uint);
|
||||
handle_type = (cl_uint *)malloc(handle_type_size);
|
||||
errNum =
|
||||
clGetPlatformInfo(platforms[i], platform_info_table[j].info,
|
||||
handle_type_size, handle_type, NULL);
|
||||
test_error(errNum, "clGetPlatformInfo failed");
|
||||
errNum = clGetPlatformInfo(platform, platform_info_table[i].info, 0,
|
||||
NULL, &handle_type_size);
|
||||
test_error(errNum, "clGetPlatformInfo failed");
|
||||
|
||||
log_info("%s: \n", platform_info_table[j].name);
|
||||
while (num_handles--)
|
||||
if (handle_type_size == 0)
|
||||
{
|
||||
if (platform_info_table[i].info
|
||||
== CL_PLATFORM_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR
|
||||
&& external_mem_extn_available)
|
||||
{
|
||||
log_info("%x \n", handle_type[num_handles]);
|
||||
}
|
||||
if (handle_type)
|
||||
{
|
||||
free(handle_type);
|
||||
test_fail(
|
||||
"External memory import handle types should be reported if "
|
||||
"cl_khr_external_memory is available.\n");
|
||||
}
|
||||
log_info("%s not supported. Skipping the query.\n",
|
||||
platform_info_table[i].name);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((platform_info_table[i].info
|
||||
== CL_PLATFORM_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR)
|
||||
|| (platform_info_table[i].info
|
||||
== CL_PLATFORM_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR))
|
||||
{
|
||||
supports_atleast_one_sema_query = true;
|
||||
}
|
||||
|
||||
num_handles = handle_type_size / sizeof(cl_uint);
|
||||
handle_type = (cl_uint *)malloc(handle_type_size);
|
||||
errNum = clGetPlatformInfo(platform, platform_info_table[i].info,
|
||||
handle_type_size, handle_type, NULL);
|
||||
test_error(errNum, "clGetPlatformInfo failed");
|
||||
|
||||
log_info("%s: \n", platform_info_table[i].name);
|
||||
while (num_handles--)
|
||||
{
|
||||
log_info("%x \n", handle_type[num_handles]);
|
||||
}
|
||||
if (handle_type)
|
||||
{
|
||||
free(handle_type);
|
||||
}
|
||||
}
|
||||
if (platforms)
|
||||
|
||||
if (external_sema_extn_available && !supports_atleast_one_sema_query)
|
||||
{
|
||||
free(platforms);
|
||||
log_info("External semaphore import/export or both should be supported "
|
||||
"if cl_khr_external_semaphore is available.\n");
|
||||
return TEST_FAIL;
|
||||
}
|
||||
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
@@ -118,6 +139,19 @@ int test_device_info(cl_device_id deviceID, cl_context _context,
|
||||
size_t handle_type_size = 0;
|
||||
cl_uint num_handles = 0;
|
||||
cl_int errNum = CL_SUCCESS;
|
||||
cl_bool external_mem_extn_available =
|
||||
is_extension_available(deviceID, "cl_khr_external_memory");
|
||||
cl_bool external_sema_extn_available =
|
||||
is_extension_available(deviceID, "cl_khr_external_semaphore");
|
||||
cl_bool supports_atleast_one_sema_query = false;
|
||||
|
||||
if (!external_mem_extn_available && !external_sema_extn_available)
|
||||
{
|
||||
log_info("Device does not support 'cl_khr_external_semaphore' "
|
||||
"and 'cl_khr_external_memory'. Skipping the test.\n");
|
||||
return TEST_SKIPPED_ITSELF;
|
||||
}
|
||||
|
||||
for (j = 0; j < sizeof(device_info_table) / sizeof(device_info_table[0]);
|
||||
j++)
|
||||
{
|
||||
@@ -125,6 +159,29 @@ int test_device_info(cl_device_id deviceID, cl_context _context,
|
||||
&handle_type_size);
|
||||
test_error(errNum, "clGetDeviceInfo failed");
|
||||
|
||||
if (handle_type_size == 0)
|
||||
{
|
||||
if (device_info_table[j].info
|
||||
== CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR
|
||||
&& external_mem_extn_available)
|
||||
{
|
||||
test_fail(
|
||||
"External memory import handle types should be reported if "
|
||||
"cl_khr_external_memory is available.\n");
|
||||
}
|
||||
log_info("%s not supported. Skipping the query.\n",
|
||||
device_info_table[j].name);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((device_info_table[j].info
|
||||
== CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR)
|
||||
|| (device_info_table[j].info
|
||||
== CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR))
|
||||
{
|
||||
supports_atleast_one_sema_query = true;
|
||||
}
|
||||
|
||||
num_handles = handle_type_size / sizeof(cl_uint);
|
||||
handle_type = (cl_uint *)malloc(handle_type_size);
|
||||
|
||||
@@ -142,5 +199,13 @@ int test_device_info(cl_device_id deviceID, cl_context _context,
|
||||
free(handle_type);
|
||||
}
|
||||
}
|
||||
|
||||
if (external_sema_extn_available && !supports_atleast_one_sema_query)
|
||||
{
|
||||
log_info("External semaphore import/export or both should be supported "
|
||||
"if cl_khr_external_semaphore is available.\n");
|
||||
return TEST_FAIL;
|
||||
}
|
||||
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user