Updated semaphore tests to use clSemaphoreReImportSyncFdKHR. (#1854)

* Updated semaphore tests to use clSemaphoreReImportSyncFdKHR.

Additionally updated common semaphore code to handle spec updates
that restrict simultaneous importing/exporting of handles.

* Fix build issues on CI

* gcc build issues

* Make clReImportSemaphoreSyncFdKHR a required API
call if cl_khr_external_semaphore_sync_fd is present.

* Implement signal and wait for all semaphore types.
This commit is contained in:
joshqti
2024-01-23 10:09:14 -08:00
committed by GitHub
parent 0bdd0fd2fa
commit b5f030faa1
6 changed files with 232 additions and 147 deletions

View File

@@ -34,8 +34,10 @@ pfnclEnqueueReleaseExternalMemObjectsKHR
clEnqueueReleaseExternalMemObjectsKHRptr; clEnqueueReleaseExternalMemObjectsKHRptr;
pfnclReleaseSemaphoreKHR clReleaseSemaphoreKHRptr; pfnclReleaseSemaphoreKHR clReleaseSemaphoreKHRptr;
pfnclGetSemaphoreHandleForTypeKHR clGetSemaphoreHandleForTypeKHRptr; pfnclGetSemaphoreHandleForTypeKHR clGetSemaphoreHandleForTypeKHRptr;
pfnclReImportSemaphoreSyncFdKHR clReImportSemaphoreSyncFdKHRptr;
void init_cl_vk_ext(cl_platform_id opencl_platform) void init_cl_vk_ext(cl_platform_id opencl_platform, cl_uint num_devices,
cl_device_id *deviceIds)
{ {
clEnqueueWaitSemaphoresKHRptr = clEnqueueWaitSemaphoresKHRptr =
(pfnclEnqueueWaitSemaphoresKHR)clGetExtensionFunctionAddressForPlatform( (pfnclEnqueueWaitSemaphoresKHR)clGetExtensionFunctionAddressForPlatform(
@@ -79,6 +81,21 @@ void init_cl_vk_ext(cl_platform_id opencl_platform)
throw std::runtime_error("Failed to get the function pointer of " throw std::runtime_error("Failed to get the function pointer of "
"clGetSemaphoreHandleForTypeKHRptr!"); "clGetSemaphoreHandleForTypeKHRptr!");
} }
// Required only if cl_khr_external_semaphore_sync_fd is reported
clReImportSemaphoreSyncFdKHRptr = (pfnclReImportSemaphoreSyncFdKHR)
clGetExtensionFunctionAddressForPlatform(
opencl_platform, "clReImportSemaphoreSyncFdKHR");
for (cl_uint i = 0; i < num_devices; i++)
{
if (is_extension_available(deviceIds[i],
"cl_khr_external_semaphore_sync_fd")
&& (NULL == clReImportSemaphoreSyncFdKHRptr))
{
throw std::runtime_error("Failed to get the function pointer of "
"clReImportSemaphoreSyncFdKHR!");
}
}
} }
cl_int setMaxImageDimensions(cl_device_id deviceID, size_t &max_width, cl_int setMaxImageDimensions(cl_device_id deviceID, size_t &max_width,
@@ -669,7 +686,6 @@ clExternalMemoryImage::clExternalMemoryImage(
break; break;
#elif !defined(__APPLE__) #elif !defined(__APPLE__)
case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD: case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD:
log_info(" Opaque file descriptors are not supported on Windows\n");
fd = (int)deviceMemory.getHandle(externalMemoryHandleType); fd = (int)deviceMemory.getHandle(externalMemoryHandleType);
errcode_ret = check_external_memory_handle_type( errcode_ret = check_external_memory_handle_type(
devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR); devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR);
@@ -738,7 +754,9 @@ clExternalMemoryImage::clExternalMemoryImage() {}
// clExternalSemaphore implementation // // clExternalSemaphore implementation //
////////////////////////////////////////// //////////////////////////////////////////
clExternalSemaphore::clExternalSemaphore( clExternalSemaphore::~clExternalSemaphore() = default;
clExternalImportableSemaphore::clExternalImportableSemaphore(
const VulkanSemaphore &semaphore, cl_context context, const VulkanSemaphore &semaphore, cl_context context,
VulkanExternalSemaphoreHandleType externalSemaphoreHandleType, VulkanExternalSemaphoreHandleType externalSemaphoreHandleType,
cl_device_id deviceId) cl_device_id deviceId)
@@ -759,17 +777,12 @@ clExternalSemaphore::clExternalSemaphore(
switch (externalSemaphoreHandleType) switch (externalSemaphoreHandleType)
{ {
case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD: case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD:
#ifdef _WIN32
ASSERT(0);
#else
log_info(" Opaque file descriptors are not supported on Windows\n");
fd = (int)semaphore.getHandle(externalSemaphoreHandleType); fd = (int)semaphore.getHandle(externalSemaphoreHandleType);
err = check_external_semaphore_handle_type( err = check_external_semaphore_handle_type(
devList[0], CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR); devList[0], CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR);
sema_props.push_back( sema_props.push_back(
(cl_semaphore_properties_khr)CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR); (cl_semaphore_properties_khr)CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR);
sema_props.push_back((cl_semaphore_properties_khr)fd); sema_props.push_back((cl_semaphore_properties_khr)fd);
#endif
break; break;
case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_NT: case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_NT:
#ifndef _WIN32 #ifndef _WIN32
@@ -802,12 +815,10 @@ clExternalSemaphore::clExternalSemaphore(
case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD: case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD:
err = check_external_semaphore_handle_type( err = check_external_semaphore_handle_type(
devList[0], CL_SEMAPHORE_HANDLE_SYNC_FD_KHR); devList[0], CL_SEMAPHORE_HANDLE_SYNC_FD_KHR);
sema_props.push_back(static_cast<cl_semaphore_properties_khr>(
CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR));
sema_props.push_back(static_cast<cl_semaphore_properties_khr>( sema_props.push_back(static_cast<cl_semaphore_properties_khr>(
CL_SEMAPHORE_HANDLE_SYNC_FD_KHR)); CL_SEMAPHORE_HANDLE_SYNC_FD_KHR));
sema_props.push_back(static_cast<cl_semaphore_properties_khr>( sema_props.push_back(static_cast<cl_semaphore_properties_khr>(-1));
CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR));
break; break;
default: default:
ASSERT(0); ASSERT(0);
@@ -837,7 +848,7 @@ clExternalSemaphore::clExternalSemaphore(
} }
} }
clExternalSemaphore::~clExternalSemaphore() noexcept(false) clExternalImportableSemaphore::~clExternalImportableSemaphore()
{ {
cl_int err = clReleaseSemaphoreKHRptr(m_externalSemaphore); cl_int err = clReleaseSemaphoreKHRptr(m_externalSemaphore);
if (err != CL_SUCCESS) if (err != CL_SUCCESS)
@@ -846,7 +857,89 @@ clExternalSemaphore::~clExternalSemaphore() noexcept(false)
} }
} }
int clExternalSemaphore::signal(cl_command_queue cmd_queue) int clExternalImportableSemaphore::wait(cl_command_queue cmd_queue)
{
int err = CL_SUCCESS;
if (m_externalHandleType == VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD)
{
cl_int err = 0;
fd = (int)m_deviceSemaphore.getHandle(m_externalHandleType);
err = clReImportSemaphoreSyncFdKHRptr(m_externalSemaphore, nullptr, fd);
if (err != CL_SUCCESS)
{
return err;
}
}
err = clEnqueueWaitSemaphoresKHRptr(cmd_queue, 1, &m_externalSemaphore,
NULL, 0, NULL, NULL);
return err;
}
int clExternalImportableSemaphore::signal(cl_command_queue cmd_queue)
{
return clEnqueueSignalSemaphoresKHRptr(cmd_queue, 1, &m_externalSemaphore,
NULL, 0, NULL, NULL);
}
cl_semaphore_khr &clExternalImportableSemaphore::getCLSemaphore()
{
return m_externalSemaphore;
}
clExternalExportableSemaphore::clExternalExportableSemaphore(
const VulkanSemaphore &semaphore, cl_context context,
VulkanExternalSemaphoreHandleType externalSemaphoreHandleType,
cl_device_id deviceId)
: m_deviceSemaphore(semaphore)
{
cl_int err = 0;
cl_device_id devList[] = { deviceId, NULL };
m_externalHandleType = externalSemaphoreHandleType;
m_externalSemaphore = nullptr;
m_device = deviceId;
m_context = context;
std::vector<cl_semaphore_properties_khr> sema_props{
(cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR,
(cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR,
};
sema_props.push_back(
(cl_semaphore_properties_khr)CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR);
sema_props.push_back(
(cl_semaphore_properties_khr)getCLSemaphoreTypeFromVulkanType(
externalSemaphoreHandleType));
sema_props.push_back((cl_semaphore_properties_khr)
CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR);
sema_props.push_back(
(cl_semaphore_properties_khr)CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR);
sema_props.push_back((cl_semaphore_properties_khr)devList[0]);
sema_props.push_back(
(cl_semaphore_properties_khr)CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR);
sema_props.push_back(0);
m_externalSemaphore =
clCreateSemaphoreWithPropertiesKHRptr(context, sema_props.data(), &err);
if (CL_SUCCESS != err)
{
log_error("clCreateSemaphoreWithPropertiesKHRptr failed with %d\n",
err);
throw std::runtime_error(
"clCreateSemaphoreWithPropertiesKHRptr failed! ");
}
}
clExternalExportableSemaphore::~clExternalExportableSemaphore()
{
cl_int err = clReleaseSemaphoreKHRptr(m_externalSemaphore);
if (err != CL_SUCCESS)
{
throw std::runtime_error("clReleaseSemaphoreKHR failed!");
}
}
int clExternalExportableSemaphore::signal(cl_command_queue cmd_queue)
{ {
int err = clEnqueueSignalSemaphoresKHRptr( int err = clEnqueueSignalSemaphoresKHRptr(
cmd_queue, 1, &m_externalSemaphore, NULL, 0, NULL, nullptr); cmd_queue, 1, &m_externalSemaphore, NULL, 0, NULL, nullptr);
@@ -886,60 +979,13 @@ int clExternalSemaphore::signal(cl_command_queue cmd_queue)
return err; return err;
} }
int clExternalSemaphore::wait(cl_command_queue cmd_queue) int clExternalExportableSemaphore::wait(cl_command_queue command_queue)
{ {
int err = CL_SUCCESS; return clEnqueueWaitSemaphoresKHRptr(command_queue, 1, &m_externalSemaphore,
if (m_externalHandleType == VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD) NULL, 0, NULL, nullptr);
{
cl_int err = 0;
cl_device_id devList[] = { m_device, NULL };
std::vector<cl_semaphore_properties_khr> sema_props{
(cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR,
(cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR,
};
fd = (int)m_deviceSemaphore.getHandle(m_externalHandleType);
err = check_external_semaphore_handle_type(
devList[0], CL_SEMAPHORE_HANDLE_SYNC_FD_KHR);
if (CL_SUCCESS != err)
{
log_error("CL_SEMAPHORE_HANDLE_SYNC_FD_KHR not supported\n");
return err;
}
sema_props.push_back(
(cl_semaphore_properties_khr)CL_SEMAPHORE_HANDLE_SYNC_FD_KHR);
sema_props.push_back((cl_semaphore_properties_khr)fd);
sema_props.push_back(0);
if (m_externalSemaphore)
{
err = clReleaseSemaphoreKHRptr(m_externalSemaphore);
if (err != CL_SUCCESS)
{
log_error("Failed to release CL external semaphore\n");
return err;
}
m_externalSemaphore = nullptr;
}
m_externalSemaphore = clCreateSemaphoreWithPropertiesKHRptr(
m_context, sema_props.data(), &err);
if (CL_SUCCESS != err)
{
log_error("clCreateSemaphoreWithPropertiesKHRptr failed with %d\n",
err);
return err;
}
}
err = clEnqueueWaitSemaphoresKHRptr(cmd_queue, 1, &m_externalSemaphore,
NULL, 0, NULL, NULL);
return err;
} }
cl_semaphore_khr &clExternalSemaphore::getCLSemaphore() cl_semaphore_khr &clExternalExportableSemaphore::getCLSemaphore()
{ {
return m_externalSemaphore; return m_externalSemaphore;
} }
@@ -1006,4 +1052,4 @@ VulkanImageTiling vkClExternalMemoryHandleTilingAssumption(
} }
return mode; return mode;
} }

View File

@@ -54,6 +54,9 @@ typedef cl_int (*pfnclGetSemaphoreHandleForTypeKHR)(
cl_semaphore_khr sema_object, cl_device_id device, cl_semaphore_khr sema_object, cl_device_id device,
cl_external_semaphore_handle_type_khr handleType, size_t handle_size, cl_external_semaphore_handle_type_khr handleType, size_t handle_size,
void *handle, size_t *handleSize); void *handle, size_t *handleSize);
typedef cl_int (*pfnclReImportSemaphoreSyncFdKHR)(
cl_semaphore_khr sema_object,
cl_semaphore_reimport_properties_khr *reimport_props, int fd);
extern pfnclCreateSemaphoreWithPropertiesKHR extern pfnclCreateSemaphoreWithPropertiesKHR
clCreateSemaphoreWithPropertiesKHRptr; clCreateSemaphoreWithPropertiesKHRptr;
@@ -64,6 +67,7 @@ extern pfnclEnqueueAcquireExternalMemObjectsKHR
extern pfnclEnqueueReleaseExternalMemObjectsKHR extern pfnclEnqueueReleaseExternalMemObjectsKHR
clEnqueueReleaseExternalMemObjectsKHRptr; clEnqueueReleaseExternalMemObjectsKHRptr;
extern pfnclReleaseSemaphoreKHR clReleaseSemaphoreKHRptr; extern pfnclReleaseSemaphoreKHR clReleaseSemaphoreKHRptr;
extern pfnclReImportSemaphoreSyncFdKHR pfnclReImportSemaphoreSyncFdKHRptr;
cl_int getCLImageInfoFromVkImageInfo(const VkImageCreateInfo *, size_t, cl_int getCLImageInfoFromVkImageInfo(const VkImageCreateInfo *, size_t,
cl_image_format *, cl_image_desc *); cl_image_format *, cl_image_desc *);
@@ -97,7 +101,6 @@ protected:
cl_mem m_externalMemory; cl_mem m_externalMemory;
int fd; int fd;
void *handle; void *handle;
cl_command_queue cmd_queue;
clExternalMemoryImage(); clExternalMemoryImage();
public: public:
@@ -112,6 +115,15 @@ public:
}; };
class clExternalSemaphore { class clExternalSemaphore {
public:
virtual int signal(cl_command_queue command_queue) = 0;
virtual int wait(cl_command_queue command_queue) = 0;
virtual cl_semaphore_khr &getCLSemaphore() = 0;
virtual ~clExternalSemaphore() = 0;
};
class clExternalImportableSemaphore : public virtual clExternalSemaphore {
protected: protected:
cl_semaphore_khr m_externalSemaphore; cl_semaphore_khr m_externalSemaphore;
VulkanExternalSemaphoreHandleType m_externalHandleType; VulkanExternalSemaphoreHandleType m_externalHandleType;
@@ -122,21 +134,42 @@ protected:
void *handle; void *handle;
public: public:
clExternalSemaphore( clExternalImportableSemaphore(
const VulkanSemaphore &deviceSemaphore, cl_context context, const VulkanSemaphore &deviceSemaphore, cl_context context,
VulkanExternalSemaphoreHandleType externalSemaphoreHandleType, VulkanExternalSemaphoreHandleType externalSemaphoreHandleType,
cl_device_id deviceId); cl_device_id deviceId);
virtual ~clExternalSemaphore() noexcept(false); ~clExternalImportableSemaphore() override;
int signal(cl_command_queue command_queue); int wait(cl_command_queue command_queue) override;
int wait(cl_command_queue command_queue); int signal(cl_command_queue command_queue) override;
cl_semaphore_khr &getCLSemaphore(); cl_semaphore_khr &getCLSemaphore() override;
// operator openclExternalSemaphore_t() const;
}; };
extern void init_cl_vk_ext(cl_platform_id); class clExternalExportableSemaphore : public virtual clExternalSemaphore {
protected:
cl_semaphore_khr m_externalSemaphore;
VulkanExternalSemaphoreHandleType m_externalHandleType;
cl_device_id m_device;
cl_context m_context;
const VulkanSemaphore &m_deviceSemaphore;
int fd;
void *handle;
public:
clExternalExportableSemaphore(
const VulkanSemaphore &deviceSemaphore, cl_context context,
VulkanExternalSemaphoreHandleType externalSemaphoreHandleType,
cl_device_id deviceId);
~clExternalExportableSemaphore() override;
int signal(cl_command_queue command_queue) override;
int wait(cl_command_queue command_queue) override;
cl_semaphore_khr &getCLSemaphore() override;
};
extern void init_cl_vk_ext(cl_platform_id, cl_uint num_devices,
cl_device_id *deviceIds);
VulkanImageTiling vkClExternalMemoryHandleTilingAssumption( VulkanImageTiling vkClExternalMemoryHandleTilingAssumption(
cl_device_id deviceId, cl_device_id deviceId,
VulkanExternalMemoryHandleType vkExternalMemoryHandleType, int *error_ret); VulkanExternalMemoryHandleType vkExternalMemoryHandleType, int *error_ret);
#endif // _opencl_vulkan_wrapper_hpp_ #endif // _opencl_vulkan_wrapper_hpp_

View File

@@ -64,7 +64,7 @@ static void log_info_semaphore_type(
log_info("%s", semaphore_type_description.str().c_str()); log_info("%s", semaphore_type_description.str().c_str());
} }
static int init_vuikan_device() static int init_vuikan_device(cl_uint num_devices, cl_device_id* deviceIds)
{ {
cl_platform_id platform = nullptr; cl_platform_id platform = nullptr;
@@ -77,7 +77,7 @@ static int init_vuikan_device()
return err; return err;
} }
init_cl_vk_ext(platform); init_cl_vk_ext(platform, num_devices, deviceIds);
return CL_SUCCESS; return CL_SUCCESS;
} }
@@ -101,7 +101,7 @@ int test_external_semaphores_queries(cl_device_id deviceID, cl_context context,
return TEST_SKIPPED_ITSELF; return TEST_SKIPPED_ITSELF;
} }
if (init_vuikan_device()) if (init_vuikan_device(1, &deviceID))
{ {
log_info("Cannot initialise Vulkan. " log_info("Cannot initialise Vulkan. "
"Skipping test.\n"); "Skipping test.\n");
@@ -130,8 +130,8 @@ int test_external_semaphores_queries(cl_device_id deviceID, cl_context context,
VulkanSemaphore vkVk2CLSemaphore(vkDevice, VulkanSemaphore vkVk2CLSemaphore(vkDevice,
vkExternalSemaphoreHandleType); vkExternalSemaphoreHandleType);
clExternalSemaphore sema_ext(vkVk2CLSemaphore, context, clExternalImportableSemaphore sema_ext(
vkExternalSemaphoreHandleType, deviceID); vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceID);
// Needed by the macro // Needed by the macro
cl_semaphore_khr sema = sema_ext.getCLSemaphore(); cl_semaphore_khr sema = sema_ext.getCLSemaphore();
@@ -181,7 +181,7 @@ int test_external_semaphores_multi_context(cl_device_id deviceID,
return TEST_SKIPPED_ITSELF; return TEST_SKIPPED_ITSELF;
} }
if (init_vuikan_device()) if (init_vuikan_device(1, &deviceID))
{ {
log_info("Cannot initialise Vulkan. " log_info("Cannot initialise Vulkan. "
"Skipping test.\n"); "Skipping test.\n");
@@ -219,10 +219,11 @@ int test_external_semaphores_multi_context(cl_device_id deviceID,
return TEST_FAIL; return TEST_FAIL;
} }
clExternalSemaphore sema_ext_1(vkVk2CLSemaphore, context, clExternalExportableSemaphore sema_ext_1(
vkExternalSemaphoreHandleType, deviceID); vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceID);
clExternalSemaphore sema_ext_2(vkVk2CLSemaphore, context2, clExternalExportableSemaphore sema_ext_2(vkVk2CLSemaphore, context2,
vkExternalSemaphoreHandleType, deviceID); vkExternalSemaphoreHandleType,
deviceID);
clCommandQueueWrapper queue1 = clCommandQueueWrapper queue1 =
clCreateCommandQueue(context, deviceID, 0, &err); clCreateCommandQueue(context, deviceID, 0, &err);
@@ -288,7 +289,7 @@ static int semaphore_external_cross_queue_helper(cl_device_id deviceID,
return TEST_SKIPPED_ITSELF; return TEST_SKIPPED_ITSELF;
} }
if (init_vuikan_device()) if (init_vuikan_device(1, &deviceID))
{ {
log_info("Cannot initialise Vulkan. " log_info("Cannot initialise Vulkan. "
"Skipping test.\n"); "Skipping test.\n");
@@ -313,8 +314,8 @@ static int semaphore_external_cross_queue_helper(cl_device_id deviceID,
VulkanSemaphore vkVk2CLSemaphore(vkDevice, VulkanSemaphore vkVk2CLSemaphore(vkDevice,
vkExternalSemaphoreHandleType); vkExternalSemaphoreHandleType);
clExternalSemaphore sema_ext(vkVk2CLSemaphore, context, clExternalExportableSemaphore sema_ext(
vkExternalSemaphoreHandleType, deviceID); vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceID);
// Obtain pointers to semaphore's API // Obtain pointers to semaphore's API
GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR); GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR);
@@ -362,7 +363,7 @@ int test_external_semaphores_simple_1(cl_device_id deviceID, cl_context context,
return TEST_SKIPPED_ITSELF; return TEST_SKIPPED_ITSELF;
} }
if (init_vuikan_device()) if (init_vuikan_device(1, &deviceID))
{ {
log_info("Cannot initialise Vulkan. " log_info("Cannot initialise Vulkan. "
"Skipping test.\n"); "Skipping test.\n");
@@ -392,8 +393,8 @@ int test_external_semaphores_simple_1(cl_device_id deviceID, cl_context context,
VulkanSemaphore vkVk2CLSemaphore(vkDevice, VulkanSemaphore vkVk2CLSemaphore(vkDevice,
vkExternalSemaphoreHandleType); vkExternalSemaphoreHandleType);
clExternalSemaphore sema_ext(vkVk2CLSemaphore, context, clExternalExportableSemaphore sema_ext(
vkExternalSemaphoreHandleType, deviceID); vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceID);
cl_int err = CL_SUCCESS; cl_int err = CL_SUCCESS;
@@ -439,7 +440,7 @@ int test_external_semaphores_simple_2(cl_device_id deviceID, cl_context context,
return TEST_SKIPPED_ITSELF; return TEST_SKIPPED_ITSELF;
} }
if (init_vuikan_device()) if (init_vuikan_device(1, &deviceID))
{ {
log_info("Cannot initialise Vulkan. " log_info("Cannot initialise Vulkan. "
"Skipping test.\n"); "Skipping test.\n");
@@ -468,8 +469,8 @@ int test_external_semaphores_simple_2(cl_device_id deviceID, cl_context context,
VulkanSemaphore vkVk2CLSemaphore(vkDevice, VulkanSemaphore vkVk2CLSemaphore(vkDevice,
vkExternalSemaphoreHandleType); vkExternalSemaphoreHandleType);
clExternalSemaphore sema_ext(vkVk2CLSemaphore, context, clExternalExportableSemaphore sema_ext(
vkExternalSemaphoreHandleType, deviceID); vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceID);
cl_int err = CL_SUCCESS; cl_int err = CL_SUCCESS;
@@ -545,7 +546,7 @@ int test_external_semaphores_reuse(cl_device_id deviceID, cl_context context,
return TEST_SKIPPED_ITSELF; return TEST_SKIPPED_ITSELF;
} }
if (init_vuikan_device()) if (init_vuikan_device(1, &deviceID))
{ {
log_info("Cannot initialise Vulkan. " log_info("Cannot initialise Vulkan. "
"Skipping test.\n"); "Skipping test.\n");
@@ -574,8 +575,8 @@ int test_external_semaphores_reuse(cl_device_id deviceID, cl_context context,
VulkanSemaphore vkVk2CLSemaphore(vkDevice, VulkanSemaphore vkVk2CLSemaphore(vkDevice,
vkExternalSemaphoreHandleType); vkExternalSemaphoreHandleType);
clExternalSemaphore sema_ext(vkVk2CLSemaphore, context, clExternalExportableSemaphore sema_ext(
vkExternalSemaphoreHandleType, deviceID); vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceID);
cl_int err = CL_SUCCESS; cl_int err = CL_SUCCESS;
@@ -668,7 +669,7 @@ static int external_semaphore_cross_queue_helper(cl_device_id deviceID,
return TEST_SKIPPED_ITSELF; return TEST_SKIPPED_ITSELF;
} }
if (init_vuikan_device()) if (init_vuikan_device(1, &deviceID))
{ {
log_info("Cannot initialise Vulkan. " log_info("Cannot initialise Vulkan. "
"Skipping test.\n"); "Skipping test.\n");
@@ -697,8 +698,8 @@ static int external_semaphore_cross_queue_helper(cl_device_id deviceID,
VulkanSemaphore vkVk2CLSemaphore(vkDevice, VulkanSemaphore vkVk2CLSemaphore(vkDevice,
vkExternalSemaphoreHandleType); vkExternalSemaphoreHandleType);
clExternalSemaphore sema_ext(vkVk2CLSemaphore, context, clExternalExportableSemaphore sema_ext(
vkExternalSemaphoreHandleType, deviceID); vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceID);
cl_int err = CL_SUCCESS; cl_int err = CL_SUCCESS;
@@ -785,7 +786,7 @@ int test_external_semaphores_cross_queues_io2(cl_device_id deviceID,
return TEST_SKIPPED_ITSELF; return TEST_SKIPPED_ITSELF;
} }
if (init_vuikan_device()) if (init_vuikan_device(1, &deviceID))
{ {
log_info("Cannot initialise Vulkan. " log_info("Cannot initialise Vulkan. "
"Skipping test.\n"); "Skipping test.\n");
@@ -823,10 +824,11 @@ int test_external_semaphores_cross_queues_io2(cl_device_id deviceID,
VulkanSemaphore vkVk2CLSemaphore(vkDevice, VulkanSemaphore vkVk2CLSemaphore(vkDevice,
vkExternalSemaphoreHandleType); vkExternalSemaphoreHandleType);
clExternalSemaphore sema_ext_1(vkVk2CLSemaphore, context, clExternalExportableSemaphore sema_ext_1(
vkExternalSemaphoreHandleType, deviceID); vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceID);
clExternalSemaphore sema_ext_2(vkVk2CLSemaphore, context2, clExternalExportableSemaphore sema_ext_2(vkVk2CLSemaphore, context2,
vkExternalSemaphoreHandleType, deviceID); vkExternalSemaphoreHandleType,
deviceID);
clCommandQueueWrapper queue1 = clCommandQueueWrapper queue1 =
clCreateCommandQueue(context, deviceID, 0, &err); clCreateCommandQueue(context, deviceID, 0, &err);
@@ -891,7 +893,7 @@ int test_external_semaphores_multi_signal(cl_device_id deviceID,
return TEST_SKIPPED_ITSELF; return TEST_SKIPPED_ITSELF;
} }
if (init_vuikan_device()) if (init_vuikan_device(1, &deviceID))
{ {
log_info("Cannot initialise Vulkan. " log_info("Cannot initialise Vulkan. "
"Skipping test.\n"); "Skipping test.\n");
@@ -922,10 +924,12 @@ int test_external_semaphores_multi_signal(cl_device_id deviceID,
VulkanSemaphore vkVk2CLSemaphore2(vkDevice, VulkanSemaphore vkVk2CLSemaphore2(vkDevice,
vkExternalSemaphoreHandleType); vkExternalSemaphoreHandleType);
clExternalSemaphore sema_ext_1(vkVk2CLSemaphore1, context, clExternalExportableSemaphore sema_ext_1(vkVk2CLSemaphore1, context,
vkExternalSemaphoreHandleType, deviceID); vkExternalSemaphoreHandleType,
clExternalSemaphore sema_ext_2(vkVk2CLSemaphore2, context, deviceID);
vkExternalSemaphoreHandleType, deviceID); clExternalExportableSemaphore sema_ext_2(vkVk2CLSemaphore2, context,
vkExternalSemaphoreHandleType,
deviceID);
cl_int err = CL_SUCCESS; cl_int err = CL_SUCCESS;
@@ -980,7 +984,7 @@ int test_external_semaphores_multi_wait(cl_device_id deviceID,
return TEST_SKIPPED_ITSELF; return TEST_SKIPPED_ITSELF;
} }
if (init_vuikan_device()) if (init_vuikan_device(1, &deviceID))
{ {
log_info("Cannot initialise Vulkan. " log_info("Cannot initialise Vulkan. "
"Skipping test.\n"); "Skipping test.\n");
@@ -1011,10 +1015,12 @@ int test_external_semaphores_multi_wait(cl_device_id deviceID,
VulkanSemaphore vkVk2CLSemaphore2(vkDevice, VulkanSemaphore vkVk2CLSemaphore2(vkDevice,
vkExternalSemaphoreHandleType); vkExternalSemaphoreHandleType);
clExternalSemaphore sema_ext_1(vkVk2CLSemaphore1, context, clExternalExportableSemaphore sema_ext_1(vkVk2CLSemaphore1, context,
vkExternalSemaphoreHandleType, deviceID); vkExternalSemaphoreHandleType,
clExternalSemaphore sema_ext_2(vkVk2CLSemaphore2, context, deviceID);
vkExternalSemaphoreHandleType, deviceID); clExternalExportableSemaphore sema_ext_2(vkVk2CLSemaphore2, context,
vkExternalSemaphoreHandleType,
deviceID);
cl_int err = CL_SUCCESS; cl_int err = CL_SUCCESS;
@@ -1056,4 +1062,4 @@ int test_external_semaphores_multi_wait(cl_device_id deviceID,
} }
return TEST_PASS; return TEST_PASS;
} }

View File

@@ -369,7 +369,7 @@ int main(int argc, const char *argv[])
log_info(" TEST SKIPPED\n"); log_info(" TEST SKIPPED\n");
return CL_SUCCESS; return CL_SUCCESS;
} }
init_cl_vk_ext(platform); init_cl_vk_ext(platform, num_devices, devices);
// Execute tests. // Execute tests.
// Note: don't use the entire harness, because we have a different way of // Note: don't use the entire harness, because we have a different way of
@@ -381,4 +381,4 @@ int main(int argc, const char *argv[])
errNum = parseAndCallCommandLineTests(argCount, argList, devices[device_no], errNum = parseAndCallCommandLineTests(argCount, argList, devices[device_no],
test_num, test_list, config); test_num, test_list, config);
return errNum; return errNum;
} }

View File

@@ -89,10 +89,10 @@ int run_test_with_two_queue(
{ {
int err = CL_SUCCESS; int err = CL_SUCCESS;
size_t global_work_size[1]; size_t global_work_size[1];
uint8_t *error_2; uint8_t *error_2 = nullptr;
cl_mem error_1; cl_mem error_1 = nullptr;
cl_kernel update_buffer_kernel; cl_kernel update_buffer_kernel = nullptr;
cl_kernel kernel_cq; cl_kernel kernel_cq = nullptr;
clExternalSemaphore *clVk2CLExternalSemaphore = NULL; clExternalSemaphore *clVk2CLExternalSemaphore = NULL;
clExternalSemaphore *clCl2VkExternalSemaphore = NULL; clExternalSemaphore *clCl2VkExternalSemaphore = NULL;
const char *program_source_const = kernel_text_numbuffer_2; const char *program_source_const = kernel_text_numbuffer_2;
@@ -140,9 +140,9 @@ int run_test_with_two_queue(
} }
else else
{ {
clVk2CLExternalSemaphore = new clExternalSemaphore( clVk2CLExternalSemaphore = new clExternalImportableSemaphore(
vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId); vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
clCl2VkExternalSemaphore = new clExternalSemaphore( clCl2VkExternalSemaphore = new clExternalExportableSemaphore(
vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId); vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
} }
@@ -413,8 +413,8 @@ int run_test_with_one_queue(
{ {
log_info("RUNNING TEST WITH ONE QUEUE...... \n\n"); log_info("RUNNING TEST WITH ONE QUEUE...... \n\n");
size_t global_work_size[1]; size_t global_work_size[1];
uint8_t *error_2; uint8_t *error_2 = nullptr;
cl_mem error_1; cl_mem error_1 = nullptr;
cl_kernel update_buffer_kernel; cl_kernel update_buffer_kernel;
clExternalSemaphore *clVk2CLExternalSemaphore = NULL; clExternalSemaphore *clVk2CLExternalSemaphore = NULL;
clExternalSemaphore *clCl2VkExternalSemaphore = NULL; clExternalSemaphore *clCl2VkExternalSemaphore = NULL;
@@ -453,9 +453,9 @@ int run_test_with_one_queue(
} }
else else
{ {
clVk2CLExternalSemaphore = new clExternalSemaphore( clVk2CLExternalSemaphore = new clExternalImportableSemaphore(
vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId); vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
clCl2VkExternalSemaphore = new clExternalSemaphore( clCl2VkExternalSemaphore = new clExternalExportableSemaphore(
vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId); vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
} }
@@ -699,8 +699,8 @@ int run_test_with_multi_import_same_ctx(
VulkanExternalSemaphoreHandleType vkExternalSemaphoreHandleType) VulkanExternalSemaphoreHandleType vkExternalSemaphoreHandleType)
{ {
size_t global_work_size[1]; size_t global_work_size[1];
uint8_t *error_2; uint8_t *error_2 = nullptr;
cl_mem error_1; cl_mem error_1 = nullptr;
int numImports = numBuffers; int numImports = numBuffers;
cl_kernel update_buffer_kernel; cl_kernel update_buffer_kernel;
clExternalSemaphore *clVk2CLExternalSemaphore = NULL; clExternalSemaphore *clVk2CLExternalSemaphore = NULL;
@@ -742,9 +742,9 @@ int run_test_with_multi_import_same_ctx(
} }
else else
{ {
clVk2CLExternalSemaphore = new clExternalSemaphore( clVk2CLExternalSemaphore = new clExternalImportableSemaphore(
vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId); vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
clCl2VkExternalSemaphore = new clExternalSemaphore( clCl2VkExternalSemaphore = new clExternalExportableSemaphore(
vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId); vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
} }
@@ -1025,9 +1025,9 @@ int run_test_with_multi_import_diff_ctx(
VulkanExternalSemaphoreHandleType vkExternalSemaphoreHandleType) VulkanExternalSemaphoreHandleType vkExternalSemaphoreHandleType)
{ {
size_t global_work_size[1]; size_t global_work_size[1];
uint8_t *error_3; uint8_t *error_3 = nullptr;
cl_mem error_1; cl_mem error_1 = nullptr;
cl_mem error_2; cl_mem error_2 = nullptr;
int numImports = numBuffers; int numImports = numBuffers;
cl_kernel update_buffer_kernel1[MAX_IMPORTS]; cl_kernel update_buffer_kernel1[MAX_IMPORTS];
cl_kernel update_buffer_kernel2[MAX_IMPORTS]; cl_kernel update_buffer_kernel2[MAX_IMPORTS];
@@ -1071,17 +1071,17 @@ int run_test_with_multi_import_diff_ctx(
} }
else else
{ {
clVk2CLExternalSemaphore = new clExternalSemaphore( clVk2CLExternalSemaphore = new clExternalImportableSemaphore(
vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId); vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
clCl2VkExternalSemaphore = new clExternalSemaphore( clCl2VkExternalSemaphore = new clExternalExportableSemaphore(
vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId); vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
clVk2CLExternalSemaphore2 = clVk2CLExternalSemaphore2 = new clExternalImportableSemaphore(
new clExternalSemaphore(vkVk2CLSemaphore, context2, vkVk2CLSemaphore, context2, vkExternalSemaphoreHandleType,
vkExternalSemaphoreHandleType, deviceId); deviceId);
clCl2VkExternalSemaphore2 = clCl2VkExternalSemaphore2 = new clExternalExportableSemaphore(
new clExternalSemaphore(vkCl2VkSemaphore, context2, vkCl2VkSemaphore, context2, vkExternalSemaphoreHandleType,
vkExternalSemaphoreHandleType, deviceId); deviceId);
} }
const uint32_t maxIter = innerIterations; const uint32_t maxIter = innerIterations;

View File

@@ -251,9 +251,9 @@ int run_test_with_two_queue(
clExternalSemaphore *clVk2CLExternalSemaphore = NULL; clExternalSemaphore *clVk2CLExternalSemaphore = NULL;
clExternalSemaphore *clCl2VkExternalSemaphore = NULL; clExternalSemaphore *clCl2VkExternalSemaphore = NULL;
clVk2CLExternalSemaphore = new clExternalSemaphore( clVk2CLExternalSemaphore = new clExternalImportableSemaphore(
vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId); vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
clCl2VkExternalSemaphore = new clExternalSemaphore( clCl2VkExternalSemaphore = new clExternalExportableSemaphore(
vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId); vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
std::vector<VulkanDeviceMemory *> vkImage2DListDeviceMemory1; std::vector<VulkanDeviceMemory *> vkImage2DListDeviceMemory1;
@@ -816,9 +816,9 @@ int run_test_with_one_queue(
clExternalSemaphore *clVk2CLExternalSemaphore = NULL; clExternalSemaphore *clVk2CLExternalSemaphore = NULL;
clExternalSemaphore *clCl2VkExternalSemaphore = NULL; clExternalSemaphore *clCl2VkExternalSemaphore = NULL;
clVk2CLExternalSemaphore = new clExternalSemaphore( clVk2CLExternalSemaphore = new clExternalImportableSemaphore(
vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId); vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
clCl2VkExternalSemaphore = new clExternalSemaphore( clCl2VkExternalSemaphore = new clExternalExportableSemaphore(
vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId); vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId);
std::vector<VulkanDeviceMemory *> vkImage2DListDeviceMemory1; std::vector<VulkanDeviceMemory *> vkImage2DListDeviceMemory1;