From 2cce1460c88cf8b4d497f8065904f4bc5d5c85f4 Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Wed, 24 Apr 2024 08:08:45 +0200 Subject: [PATCH 1/7] Added set of negative tests for clCreateSemaphoreWithPropertiesKHR --- .../cl_khr_semaphore/CMakeLists.txt | 2 + .../extensions/cl_khr_semaphore/main.cpp | 6 + .../extensions/cl_khr_semaphore/procs.h | 19 + .../cl_khr_semaphore/semaphore_base.h | 203 ++++++ .../test_semaphores_negative_create.cpp | 682 ++++++++++++++++++ 5 files changed, 912 insertions(+) create mode 100644 test_conformance/extensions/cl_khr_semaphore/semaphore_base.h create mode 100644 test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp diff --git a/test_conformance/extensions/cl_khr_semaphore/CMakeLists.txt b/test_conformance/extensions/cl_khr_semaphore/CMakeLists.txt index 824784a13..9e4e111ff 100644 --- a/test_conformance/extensions/cl_khr_semaphore/CMakeLists.txt +++ b/test_conformance/extensions/cl_khr_semaphore/CMakeLists.txt @@ -3,6 +3,8 @@ set(MODULE_NAME CL_KHR_SEMAPHORE) set(${MODULE_NAME}_SOURCES main.cpp test_semaphores.cpp + test_semaphores_negative_create.cpp + semaphore_base.h ) include(../../CMakeCommon.txt) diff --git a/test_conformance/extensions/cl_khr_semaphore/main.cpp b/test_conformance/extensions/cl_khr_semaphore/main.cpp index 0ae7206a0..322d94e16 100644 --- a/test_conformance/extensions/cl_khr_semaphore/main.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/main.cpp @@ -35,6 +35,12 @@ test_definition test_list[] = { ADD_TEST_VERSION(semaphores_multi_wait, Version(1, 2)), ADD_TEST_VERSION(semaphores_queries, Version(1, 2)), ADD_TEST_VERSION(semaphores_import_export_fd, Version(1, 2)), + ADD_TEST_VERSION(semaphores_negative_create_invalid_context, Version(1, 2)), + ADD_TEST_VERSION(semaphores_negative_create_invalid_property, Version(1, 2)), + ADD_TEST_VERSION(semaphores_negative_create_multi_device_property, Version(1, 2)), + ADD_TEST_VERSION(semaphores_negative_create_invalid_device, Version(1, 2)), + ADD_TEST_VERSION(semaphores_negative_create_invalid_value, Version(1, 2)), + ADD_TEST_VERSION(semaphores_negative_create_invalid_operation, Version(1, 2)), }; const int test_num = ARRAY_SIZE(test_list); diff --git a/test_conformance/extensions/cl_khr_semaphore/procs.h b/test_conformance/extensions/cl_khr_semaphore/procs.h index f7c1aaa30..bb72ca383 100644 --- a/test_conformance/extensions/cl_khr_semaphore/procs.h +++ b/test_conformance/extensions/cl_khr_semaphore/procs.h @@ -45,3 +45,22 @@ extern int test_semaphores_import_export_fd(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); +extern int test_semaphores_negative_create_invalid_context( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); +extern int test_semaphores_negative_create_invalid_property( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); +extern int test_semaphores_negative_create_multi_device_property( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); +extern int test_semaphores_negative_create_invalid_device( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); +extern int test_semaphores_negative_create_invalid_value(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements); +extern int test_semaphores_negative_create_invalid_operation( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); diff --git a/test_conformance/extensions/cl_khr_semaphore/semaphore_base.h b/test_conformance/extensions/cl_khr_semaphore/semaphore_base.h new file mode 100644 index 000000000..d6f2316b2 --- /dev/null +++ b/test_conformance/extensions/cl_khr_semaphore/semaphore_base.h @@ -0,0 +1,203 @@ +// +// 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. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef CL_KHR_SEMAPHORE_BASE_H +#define CL_KHR_SEMAPHORE_BASE_H + +#include +#include "harness/deviceInfo.h" +#include "harness/testHarness.h" + +#include "harness/typeWrappers.h" + +struct SemaphoreBase +{ + SemaphoreBase(cl_device_id device) : device(device) {} + + cl_int init_extension_functions() + { + cl_platform_id platform; + cl_int error = + clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), + &platform, nullptr); + test_error(error, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed"); + + // If it is supported get the addresses of all the APIs here. + // clang-format off +#define GET_EXTENSION_ADDRESS(FUNC) \ + FUNC = reinterpret_cast( \ + clGetExtensionFunctionAddressForPlatform(platform, #FUNC)); \ + if (FUNC == nullptr) \ + { \ + log_error("ERROR: clGetExtensionFunctionAddressForPlatform failed" \ + " with " #FUNC "\n"); \ + return TEST_FAIL; \ + } + // clang-format on + + GET_EXTENSION_ADDRESS(clCreateSemaphoreWithPropertiesKHR); + GET_EXTENSION_ADDRESS(clEnqueueSignalSemaphoresKHR); + GET_EXTENSION_ADDRESS(clEnqueueWaitSemaphoresKHR); + GET_EXTENSION_ADDRESS(clReleaseSemaphoreKHR); + GET_EXTENSION_ADDRESS(clGetSemaphoreInfoKHR); + GET_EXTENSION_ADDRESS(clRetainSemaphoreKHR); + GET_EXTENSION_ADDRESS(clGetSemaphoreHandleForTypeKHR); + +#undef GET_EXTENSION_ADDRESS + return CL_SUCCESS; + } + + clCreateSemaphoreWithPropertiesKHR_fn clCreateSemaphoreWithPropertiesKHR = nullptr; + clEnqueueSignalSemaphoresKHR_fn clEnqueueSignalSemaphoresKHR = nullptr; + clEnqueueWaitSemaphoresKHR_fn clEnqueueWaitSemaphoresKHR = nullptr; + clReleaseSemaphoreKHR_fn clReleaseSemaphoreKHR = nullptr; + clGetSemaphoreInfoKHR_fn clGetSemaphoreInfoKHR = nullptr; + clRetainSemaphoreKHR_fn clRetainSemaphoreKHR = nullptr; + clGetSemaphoreHandleForTypeKHR_fn clGetSemaphoreHandleForTypeKHR = nullptr; + + cl_device_id device = nullptr; +}; + +// Wrapper class based off generic typeWrappers.h wrappers. However, because +// the release/retain functions are queried at runtime from the platform, +// rather than known at compile time we cannot link the instantiated template. +// Instead, pass an instance of `SemaphoreTestBase` on wrapper construction +// to access the release/retain functions. +class clSemaphoreWrapper { + cl_semaphore_khr object = nullptr; + + void retain() + { + if (!object) return; + + auto err = base->clRetainSemaphoreKHR(object); + if (err != CL_SUCCESS) + { + print_error(err, "clRetainCommandBufferKHR() failed"); + std::abort(); + } + } + + void release() + { + if (!object) return; + + auto err = base->clReleaseSemaphoreKHR(object); + if (err != CL_SUCCESS) + { + print_error(err, "clReleaseCommandBufferKHR() failed"); + std::abort(); + } + } + + // Used to access release/retain functions + SemaphoreBase *base; + +public: + // We always want to have base available to dereference + clSemaphoreWrapper() = delete; + + clSemaphoreWrapper(SemaphoreBase *base): base(base) {} + + // On assignment, assume the object has a refcount of one. + clSemaphoreWrapper &operator=(cl_semaphore_khr rhs) + { + reset(rhs); + return *this; + } + + // Copy semantics, increase retain count. + clSemaphoreWrapper(clSemaphoreWrapper const &w) { *this = w; } + clSemaphoreWrapper &operator=(clSemaphoreWrapper const &w) + { + reset(w.object); + retain(); + return *this; + } + + // Move semantics, directly take ownership. + clSemaphoreWrapper(clSemaphoreWrapper &&w) { *this = std::move(w); } + clSemaphoreWrapper &operator=(clSemaphoreWrapper &&w) + { + reset(w.object); + w.object = nullptr; + return *this; + } + + ~clSemaphoreWrapper() { reset(); } + + // Release the existing object, if any, and own the new one, if any. + void reset(cl_semaphore_khr new_object = nullptr) + { + release(); + object = new_object; + } + + operator cl_semaphore_khr() const { return object; } + operator const cl_semaphore_khr*() { return &object; } +}; + +struct SemaphoreTestBase : public SemaphoreBase +{ + SemaphoreTestBase(cl_device_id device, cl_context context, + cl_command_queue queue) + : SemaphoreBase(device), context(context), semaphore(this) + { + cl_int error = init_extension_functions(); + if (error != CL_SUCCESS) + throw std::runtime_error("init_extension_functions failed\n"); + + error = clRetainCommandQueue(queue); + if (error != CL_SUCCESS) + throw std::runtime_error("clRetainCommandQueue failed\n"); + this->queue = queue; + } + + virtual cl_int Run() = 0; + +protected: + + cl_context context = nullptr; + clCommandQueueWrapper queue = nullptr; + clSemaphoreWrapper semaphore = nullptr; +}; + +template +int MakeAndRunTest(cl_device_id device, cl_context context, + cl_command_queue queue) +{ + if (!is_extension_available(device, "cl_khr_semaphore")) + { + log_info( + "Device does not support 'cl_khr_semaphore'. Skipping the test.\n"); + return TEST_SKIPPED_ITSELF; + } + + cl_int status = TEST_PASS; + try + { + auto test_fixture = T(device, context, queue); + status = test_fixture.Run(); + } + catch (const std::runtime_error &e) + { + log_error("%s", e.what()); + return TEST_FAIL; + } + + return status; +} + +#endif // CL_KHR_SEMAPHORE_BASE_H diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp new file mode 100644 index 000000000..fd97252f2 --- /dev/null +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp @@ -0,0 +1,682 @@ +// +// 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. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "semaphore_base.h" + +#include "harness/errorHelpers.h" +#include +#include +#include +#include + + +namespace { + +// CL_INVALID_CONTEXT if context is nullptr. +struct CreateInvalidContext : public SemaphoreTestBase +{ + CreateInvalidContext(cl_device_id device, cl_context context, + cl_command_queue queue) + : SemaphoreTestBase(device, context, queue) + {} + + cl_int Run() override + { + // Create semaphore + cl_semaphore_properties_khr sema_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast( + CL_SEMAPHORE_TYPE_BINARY_KHR), + 0 + }; + + cl_int err = CL_SUCCESS; + semaphore = + clCreateSemaphoreWithPropertiesKHR(nullptr, sema_props, &err); + test_failure_error( + err, CL_INVALID_CONTEXT, + "Unexpected clCreateSemaphoreWithPropertiesKHR return"); + + return CL_SUCCESS; + } +}; + +// scope guard helper to ensure proper releasing of sub devices +struct SubDevicesScopeGuarded +{ + SubDevicesScopeGuarded(const cl_int dev_count) + { + sub_devices.resize(dev_count); + } + ~SubDevicesScopeGuarded() + { + for (auto& device : sub_devices) + { + cl_int err = clReleaseDevice(device); + if (err != CL_SUCCESS) + log_error("\n Releasing sub-device failed \n"); + } + } + + std::vector sub_devices; +}; + +// (1) property name in sema_props is not a supported property name, +// (2) value specified for a supported property name is not valid, +// (3) the same property name is specified more than once. +struct CreateInvalidProperty : public SemaphoreTestBase +{ + CreateInvalidProperty(cl_device_id device, cl_context context, + cl_command_queue queue) + : SemaphoreTestBase(device, context, queue) + {} + + cl_int Run() override + { + cl_int err = CL_SUCCESS; + // Create semaphore with invalid properties: + // 1) Property name in sema_props is not a supported property name + { + cl_semaphore_properties_khr sema_props[] = { + static_cast( + CL_INVALID_SEMAPHORE_KHR), + static_cast( + CL_SEMAPHORE_TYPE_BINARY_KHR), + 0 + }; + + semaphore = + clCreateSemaphoreWithPropertiesKHR(context, sema_props, &err); + test_failure_error( + err, CL_INVALID_PROPERTY, + "Unexpected clCreateSemaphoreWithPropertiesKHR return"); + } + + // 2) Value specified for a supported property name is not valid + { + cl_semaphore_properties_khr sema_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast( + CL_INVALID_SEMAPHORE_KHR), + 0 + }; + + semaphore = + clCreateSemaphoreWithPropertiesKHR(context, sema_props, &err); + test_failure_error( + err, CL_INVALID_PROPERTY, + "Unexpected clCreateSemaphoreWithPropertiesKHR return"); + } + + // 3) The same property name is specified more than once + { + cl_semaphore_properties_khr sema_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast( + CL_SEMAPHORE_TYPE_BINARY_KHR), + static_cast(CL_SEMAPHORE_TYPE_KHR), + 0 + }; + + semaphore = + clCreateSemaphoreWithPropertiesKHR(context, sema_props, &err); + test_failure_error( + err, CL_INVALID_PROPERTY, + "Unexpected clCreateSemaphoreWithPropertiesKHR return"); + } + + return CL_SUCCESS; + } +}; + +// Context is a multiple device context and sema_props does not +// specify CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR. +struct CreateInvalidMultiDeviceProperty : public SemaphoreTestBase +{ + CreateInvalidMultiDeviceProperty(cl_device_id device, cl_context context, + cl_command_queue queue) + : SemaphoreTestBase(device, context, queue) + {} + + cl_int Run() override + { + // partition device and create new context if possible + cl_uint maxComputeUnits = 0; + cl_int err = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, + sizeof(maxComputeUnits), &maxComputeUnits, + NULL); + test_error(err, "Unable to get maximal number of compute units"); + + cl_device_partition_property partitionProp[] = { + CL_DEVICE_PARTITION_EQUALLY, maxComputeUnits / 2, 0 + }; + + cl_uint deviceCount = 0; + // how many sub-devices can we create? + err = clCreateSubDevices(device, partitionProp, 0, nullptr, + &deviceCount); + if(err!=CL_SUCCESS) + { + log_info("Can't partition device, test not supported\n"); + return TEST_SKIPPED_ITSELF; + } + + if (deviceCount < 2) + test_error_ret( + CL_INVALID_VALUE, + "Multi context test for CL_INVALID_PROPERTY not supported", + TEST_SKIPPED_ITSELF); + + // get the list of subDevices + SubDevicesScopeGuarded scope_guard(deviceCount); + err = clCreateSubDevices(device, partitionProp, deviceCount, + scope_guard.sub_devices.data(), + &deviceCount); + if(err!=CL_SUCCESS) + { + log_info("Can't partition device, test not supported\n"); + return TEST_SKIPPED_ITSELF; + } + + /* Create a multi device context */ + clContextWrapper multi_device_context = clCreateContext( + NULL, (cl_uint)deviceCount, scope_guard.sub_devices.data(), + nullptr, nullptr, &err); + test_error_ret(err, "Unable to create testing context", CL_SUCCESS); + + cl_semaphore_properties_khr sema_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast( + CL_SEMAPHORE_TYPE_BINARY_KHR), + 0 + }; + + // Try to create semaphore with multi device context - expect + // CL_INVALID_PROPERTY error + semaphore = clCreateSemaphoreWithPropertiesKHR(multi_device_context, + sema_props, &err); + test_failure_error( + err, CL_INVALID_PROPERTY, + "Unexpected clCreateSemaphoreWithPropertiesKHR return"); + + return CL_SUCCESS; + } +}; + +// (1) CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR is specified as part of sema_props, +// but it does not identify exactly one valid device, +// (2) device identified by CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR is not one of +// the devices within context. +struct CreateInvalidDevice : public SemaphoreTestBase +{ + CreateInvalidDevice(cl_device_id device, cl_context context, + cl_command_queue queue) + : SemaphoreTestBase(device, context, queue) + {} + + cl_int Run() override + { + // create sub devices if possible + cl_uint maxComputeUnits = 0; + int err = + clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, + sizeof(maxComputeUnits), &maxComputeUnits, NULL); + test_error(err, "Unable to get maximal number of compute units"); + + cl_device_partition_property partitionProp[] = { + CL_DEVICE_PARTITION_EQUALLY, maxComputeUnits / 2, 0 + }; + + cl_uint deviceCount = 0; + // how many sub-devices can we create? + err = + clCreateSubDevices(device, partitionProp, 0, nullptr, &deviceCount); + if(err!=CL_SUCCESS) + { + log_info("Can't partition device, test not supported\n"); + return TEST_SKIPPED_ITSELF; + } + + if (deviceCount < 2) + test_error_ret( + CL_INVALID_VALUE, + "Multi context test for CL_INVALID_PROPERTY not supported", + TEST_SKIPPED_ITSELF); + + // get the list of subDevices + SubDevicesScopeGuarded scope_guard(deviceCount); + err = clCreateSubDevices(device, partitionProp, deviceCount, + scope_guard.sub_devices.data(), &deviceCount); + if(err!=CL_SUCCESS) + { + log_info("Can't partition device, test not supported\n"); + return TEST_SKIPPED_ITSELF; + } + + // CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR is specified as part of + // sema_props, but it does not identify exactly one valid device; + { + cl_semaphore_properties_khr sema_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast( + CL_SEMAPHORE_TYPE_BINARY_KHR), + static_cast( + CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR), + (cl_semaphore_properties_khr)device, + (cl_semaphore_properties_khr)scope_guard.sub_devices.front(), + CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR, + 0 + }; + + // Try to create semaphore with more than one valid device, + // expect CL_INVALID_DEVICE error + semaphore = + clCreateSemaphoreWithPropertiesKHR(context, sema_props, &err); + test_failure_error( + err, CL_INVALID_DEVICE, + "Unexpected clCreateSemaphoreWithPropertiesKHR return"); + } + + // or if a device identified by CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR + // is not one of the devices within context. + { + /* Create new context with sub-device */ + clContextWrapper new_context = clCreateContext( + NULL, (cl_uint)1, scope_guard.sub_devices.data(), nullptr, + nullptr, &err); + test_error_ret(err, "Unable to create testing context", CL_SUCCESS); + + cl_semaphore_properties_khr sema_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast( + CL_SEMAPHORE_TYPE_BINARY_KHR), + static_cast( + CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR), + (cl_semaphore_properties_khr)device, + CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR, + 0 + }; + + // Try to create semaphore with device not one of the devices within + // context, expect CL_INVALID_DEVICE error + semaphore = clCreateSemaphoreWithPropertiesKHR(new_context, + sema_props, &err); + test_failure_error( + err, CL_INVALID_DEVICE, + "Unexpected clCreateSemaphoreWithPropertiesKHR return"); + } + + return CL_SUCCESS; + } +}; + +// CL_INVALID_DEVICE if one or more devices identified by properties +// CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR cannot import the requested +// external semaphore handle type. +struct CreateImportExternalWithInvalidDevice : public SemaphoreTestBase +{ + CreateImportExternalWithInvalidDevice(cl_device_id device, + cl_context context, + cl_command_queue queue) + : SemaphoreTestBase(device, context, queue), semaphore_second(this) + {} + + cl_int Run() override + { + if (!is_extension_available(device, + "cl_khr_external_semaphore_sync_fd")) + { + log_info( + "cl_khr_external_semaphore_opaque_fd is not supported on this " + "platoform. Skipping test.\n"); + return TEST_SKIPPED_ITSELF; + } + + // The idea is to find two devices, one supporting cl_khr_semaphore, + // other not. Then create semaphore with valid device and import to new + // semaphore with incapable device. + cl_platform_id platform_id = 0; + cl_uint num_devices = 0; + // find out what platform the harness is using. + cl_int err = + clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), + &platform_id, nullptr); + test_error(err, "clGetDeviceInfo failed"); + + cl_uint num_platforms = 0; + err = clGetPlatformIDs(16, nullptr, &num_platforms); + test_error(err, "clGetPlatformIDs failed"); + + std::vector platforms(num_platforms); + + err = clGetPlatformIDs(num_platforms, platforms.data(), &num_platforms); + test_error(err, "clGetPlatformIDs failed"); + + cl_device_id invalid_device = nullptr; + for (int p = 0; p < (int)num_platforms; p++) + { + if (platform_id == platforms[p]) continue; + + err = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_ALL, 0, nullptr, + &num_devices); + test_error(err, "clGetDeviceIDs failed"); + + std::vector devices(num_devices); + err = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_ALL, num_devices, + devices.data(), nullptr); + test_error(err, "clGetDeviceIDs failed"); + + // try to find invalid device + for (auto did : devices) + { + if (did != device + && !is_extension_available(device, "cl_khr_semaphore")) + { + invalid_device = did; + break; + } + } + + if (invalid_device != nullptr) break; + } + + if (invalid_device == nullptr) + { + log_info("Can't find appropriate resources. Skipping test.\n"); + return TEST_SKIPPED_ITSELF; + } + + // Create ooo queue + clCommandQueueWrapper queue = clCreateCommandQueue( + context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err); + test_error(err, "Could not create command queue"); + + // Create semaphore + cl_semaphore_properties_khr sema_1_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast( + CL_SEMAPHORE_TYPE_BINARY_KHR), + static_cast( + CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR), + static_cast( + CL_SEMAPHORE_HANDLE_SYNC_FD_KHR), + static_cast( + CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR), + 0 + }; + semaphore = + clCreateSemaphoreWithPropertiesKHR(context, sema_1_props, &err); + test_error(err, "Could not create semaphore"); + + // Signal semaphore + clEventWrapper signal_event; + err = clEnqueueSignalSemaphoresKHR(queue, 1, semaphore, nullptr, 0, + nullptr, &signal_event); + test_error(err, "Could not signal semaphore"); + + // Extract sync fd + int handle = -1; + size_t handle_size; + err = clGetSemaphoreHandleForTypeKHR( + semaphore, device, CL_SEMAPHORE_HANDLE_SYNC_FD_KHR, sizeof(handle), + &handle, &handle_size); + test_error(err, "Could not extract semaphore handle"); + test_assert_error(sizeof(handle) == handle_size, "Invalid handle size"); + test_assert_error(handle >= 0, "Invalid handle"); + + /* Create invalid device context */ + clContextWrapper invalid_device_context = + clCreateContext(NULL, 1, &invalid_device, nullptr, nullptr, &err); + test_error_ret(err, "Unable to create testing context", CL_SUCCESS); + + // Create semaphore from sync fd + cl_semaphore_properties_khr sema_2_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast( + CL_SEMAPHORE_TYPE_BINARY_KHR), + static_cast( + CL_SEMAPHORE_HANDLE_SYNC_FD_KHR), + static_cast(handle), + static_cast( + CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR), + (cl_semaphore_properties_khr)invalid_device, + CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR, + 0 + }; + + semaphore_second = clCreateSemaphoreWithPropertiesKHR( + invalid_device_context, sema_2_props, &err); + test_failure_error( + err, CL_INVALID_DEVICE, + "Unexpected clCreateSemaphoreWithPropertiesKHR return"); + + return TEST_PASS; + } + + clSemaphoreWrapper semaphore_second = nullptr; +}; + +// (1) if sema_props is NULL, +// (2) if sema_props do not specify pairs for minimum set of +// properties (i.e. CL_SEMAPHORE_TYPE_KHR) required for successful creation of a +// cl_semaphore_khr, +// (3) one or more devices identified by properties +// CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR cannot import the requested external +// semaphore handle type. +struct CreateInvalidValue : public SemaphoreTestBase +{ + CreateInvalidValue(cl_device_id device, cl_context context, + cl_command_queue queue) + : SemaphoreTestBase(device, context, queue) + {} + + cl_int Run() override + { + cl_int err = CL_SUCCESS; + + // (1) + semaphore = clCreateSemaphoreWithPropertiesKHR(context, nullptr, &err); + test_failure_error( + err, CL_INVALID_VALUE, + "Unexpected clCreateSemaphoreWithPropertiesKHR return"); + + // (2) + cl_semaphore_properties_khr sema_props[] = { 0 }; + semaphore = + clCreateSemaphoreWithPropertiesKHR(context, sema_props, &err); + test_failure_error( + err, CL_INVALID_VALUE, + "Unexpected clCreateSemaphoreWithPropertiesKHR return"); + + + // (3) + { + if (!is_extension_available(device, + "cl_khr_external_semaphore_sync_fd")) + { + log_info("cl_khr_external_semaphore_opaque_fd is not supported " + "on this " + "platoform. Skipping test.\n"); + return TEST_SKIPPED_ITSELF; + } + + if (!is_extension_available(device, + "cl_khr_external_semaphore_opaque_fd")) + { + log_info("cl_khr_external_semaphore_opaque_fd is not supported " + "on this " + "platoform. Skipping test.\n"); + return TEST_SKIPPED_ITSELF; + } + + // Create semaphore + cl_semaphore_properties_khr sema_1_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast( + CL_SEMAPHORE_TYPE_BINARY_KHR), + static_cast( + CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR), + static_cast( + CL_SEMAPHORE_HANDLE_SYNC_FD_KHR), + static_cast( + CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR), + static_cast( + CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR), + 0 + }; + semaphore = + clCreateSemaphoreWithPropertiesKHR(context, sema_1_props, &err); + test_failure_error( + err, CL_INVALID_VALUE, + "Unexpected clCreateSemaphoreWithPropertiesKHR return"); + } + + return CL_SUCCESS; + } +}; + +// props_list specifies a cl_external_semaphore_handle_type_khr followed by +// a handle as well as CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR. +struct CreateInvalidOperation : public SemaphoreTestBase +{ + CreateInvalidOperation(cl_device_id device, cl_context context, + cl_command_queue queue) + : SemaphoreTestBase(device, context, queue), semaphore_second(this) + {} + + cl_int Run() override + { + if (!is_extension_available(device, + "cl_khr_external_semaphore_sync_fd")) + { + log_info( + "cl_khr_external_semaphore_sync_fd is not supported on this " + "platoform. Skipping test.\n"); + return TEST_SKIPPED_ITSELF; + } + + cl_int err = CL_SUCCESS; + clCommandQueueWrapper queue = clCreateCommandQueue( + context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err); + test_error(err, "Could not create command queue"); + + // Create semaphore + cl_semaphore_properties_khr sema_1_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast( + CL_SEMAPHORE_TYPE_BINARY_KHR), + static_cast( + CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR), + static_cast( + CL_SEMAPHORE_HANDLE_SYNC_FD_KHR), + static_cast( + CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR), + 0 + }; + semaphore = + clCreateSemaphoreWithPropertiesKHR(context, sema_1_props, &err); + test_error(err, "Could not create semaphore"); + + // Signal semaphore + clEventWrapper signal_event; + err = clEnqueueSignalSemaphoresKHR(queue, 1, semaphore, nullptr, 0, + nullptr, &signal_event); + test_error(err, "Could not signal semaphore"); + + // Extract sync fd + int handle = -1; + size_t handle_size; + err = clGetSemaphoreHandleForTypeKHR( + semaphore, device, CL_SEMAPHORE_HANDLE_SYNC_FD_KHR, sizeof(handle), + &handle, &handle_size); + test_error(err, "Could not extract semaphore handle"); + test_assert_error(sizeof(handle) == handle_size, "Invalid handle size"); + test_assert_error(handle >= 0, "Invalid handle"); + + // Create semaphore from sync fd. Exporting a semaphore handle from + // a semaphore that was created by importing an external semaphore + // handle is not permitted. + cl_semaphore_properties_khr sema_2_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast( + CL_SEMAPHORE_TYPE_BINARY_KHR), + static_cast( + CL_SEMAPHORE_HANDLE_SYNC_FD_KHR), + static_cast(handle), + static_cast( + CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR), + static_cast( + CL_SEMAPHORE_HANDLE_SYNC_FD_KHR), + static_cast( + CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR), + 0 + }; + + semaphore_second = + clCreateSemaphoreWithPropertiesKHR(context, sema_2_props, &err); + test_failure_error( + err, CL_INVALID_DEVICE, + "Unexpected clCreateSemaphoreWithPropertiesKHR return"); + + return CL_SUCCESS; + } + + clSemaphoreWrapper semaphore_second = nullptr; +}; + +} + +// Confirm that creation semaphore with nullptr context would return CL_INVALID_CONTEXT +int test_semaphores_negative_create_invalid_context(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements) +{ + return MakeAndRunTest(device, context, queue); +} + +// Confirm that creation semaphore with invalid properties return CL_INVALID_PROPERTY +int test_semaphores_negative_create_invalid_property(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements) +{ + return MakeAndRunTest(device, context, queue); +} + +// Confirm that creation semaphore with multi device property return CL_INVALID_PROPERTY +int test_semaphores_negative_create_multi_device_property(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements) +{ + return MakeAndRunTest(device, context, queue); +} + +// Confirm that creation semaphore with invalid device(s) return CL_INVALID_DEVICE +int test_semaphores_negative_create_invalid_device(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements) +{ + return MakeAndRunTest(device, context, queue); +} + +// Confirm that creation semaphore with invalid props values return CL_INVALID_VALUE +int test_semaphores_negative_create_invalid_value(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements) +{ + return MakeAndRunTest(device, context, queue); +} + +// Confirm that creation semaphore with invalid props values return CL_INVALID_VALUE +int test_semaphores_negative_create_invalid_operation(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements) +{ + return MakeAndRunTest(device, context, queue); +} From 1557effae578bdf4d6434e27f028a39be46a88f8 Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Mon, 6 May 2024 15:09:57 +0200 Subject: [PATCH 2/7] Limited external extensions dependency --- .../test_semaphores_negative_create.cpp | 31 +++++++------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp index fd97252f2..ef014dce5 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp @@ -337,7 +337,7 @@ struct CreateImportExternalWithInvalidDevice : public SemaphoreTestBase cl_int Run() override { if (!is_extension_available(device, - "cl_khr_external_semaphore_sync_fd")) + "cl_khr_external_semaphore_opaque_fd")) { log_info( "cl_khr_external_semaphore_opaque_fd is not supported on this " @@ -412,7 +412,7 @@ struct CreateImportExternalWithInvalidDevice : public SemaphoreTestBase static_cast( CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR), static_cast( - CL_SEMAPHORE_HANDLE_SYNC_FD_KHR), + CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR), static_cast( CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR), 0 @@ -431,7 +431,7 @@ struct CreateImportExternalWithInvalidDevice : public SemaphoreTestBase int handle = -1; size_t handle_size; err = clGetSemaphoreHandleForTypeKHR( - semaphore, device, CL_SEMAPHORE_HANDLE_SYNC_FD_KHR, sizeof(handle), + semaphore, device, CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR, sizeof(handle), &handle, &handle_size); test_error(err, "Could not extract semaphore handle"); test_assert_error(sizeof(handle) == handle_size, "Invalid handle size"); @@ -448,7 +448,7 @@ struct CreateImportExternalWithInvalidDevice : public SemaphoreTestBase static_cast( CL_SEMAPHORE_TYPE_BINARY_KHR), static_cast( - CL_SEMAPHORE_HANDLE_SYNC_FD_KHR), + CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR), static_cast(handle), static_cast( CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR), @@ -504,15 +504,6 @@ struct CreateInvalidValue : public SemaphoreTestBase // (3) { - if (!is_extension_available(device, - "cl_khr_external_semaphore_sync_fd")) - { - log_info("cl_khr_external_semaphore_opaque_fd is not supported " - "on this " - "platoform. Skipping test.\n"); - return TEST_SKIPPED_ITSELF; - } - if (!is_extension_available(device, "cl_khr_external_semaphore_opaque_fd")) { @@ -530,7 +521,7 @@ struct CreateInvalidValue : public SemaphoreTestBase static_cast( CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR), static_cast( - CL_SEMAPHORE_HANDLE_SYNC_FD_KHR), + CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR), static_cast( CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR), static_cast( @@ -560,10 +551,10 @@ struct CreateInvalidOperation : public SemaphoreTestBase cl_int Run() override { if (!is_extension_available(device, - "cl_khr_external_semaphore_sync_fd")) + "cl_khr_external_semaphore_opaque_fd")) { log_info( - "cl_khr_external_semaphore_sync_fd is not supported on this " + "cl_khr_external_semaphore_opaque_fd is not supported on this " "platoform. Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -581,7 +572,7 @@ struct CreateInvalidOperation : public SemaphoreTestBase static_cast( CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR), static_cast( - CL_SEMAPHORE_HANDLE_SYNC_FD_KHR), + CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR), static_cast( CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR), 0 @@ -600,7 +591,7 @@ struct CreateInvalidOperation : public SemaphoreTestBase int handle = -1; size_t handle_size; err = clGetSemaphoreHandleForTypeKHR( - semaphore, device, CL_SEMAPHORE_HANDLE_SYNC_FD_KHR, sizeof(handle), + semaphore, device, CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR, sizeof(handle), &handle, &handle_size); test_error(err, "Could not extract semaphore handle"); test_assert_error(sizeof(handle) == handle_size, "Invalid handle size"); @@ -614,12 +605,12 @@ struct CreateInvalidOperation : public SemaphoreTestBase static_cast( CL_SEMAPHORE_TYPE_BINARY_KHR), static_cast( - CL_SEMAPHORE_HANDLE_SYNC_FD_KHR), + CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR), static_cast(handle), static_cast( CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR), static_cast( - CL_SEMAPHORE_HANDLE_SYNC_FD_KHR), + CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR), static_cast( CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR), 0 From e31bd984bddea50788f64ee9c6e5e15a922dae3d Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Tue, 7 May 2024 10:35:40 +0200 Subject: [PATCH 3/7] Corrected INVALID_DEVICE test, cosmetic fixes and clang format --- .../extensions/cl_khr_semaphore/main.cpp | 11 +- .../extensions/cl_khr_semaphore/procs.h | 3 + .../test_semaphores_negative_create.cpp | 162 ++++++++---------- 3 files changed, 83 insertions(+), 93 deletions(-) diff --git a/test_conformance/extensions/cl_khr_semaphore/main.cpp b/test_conformance/extensions/cl_khr_semaphore/main.cpp index 322d94e16..ba78e9bfd 100644 --- a/test_conformance/extensions/cl_khr_semaphore/main.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/main.cpp @@ -36,11 +36,16 @@ test_definition test_list[] = { ADD_TEST_VERSION(semaphores_queries, Version(1, 2)), ADD_TEST_VERSION(semaphores_import_export_fd, Version(1, 2)), ADD_TEST_VERSION(semaphores_negative_create_invalid_context, Version(1, 2)), - ADD_TEST_VERSION(semaphores_negative_create_invalid_property, Version(1, 2)), - ADD_TEST_VERSION(semaphores_negative_create_multi_device_property, Version(1, 2)), + ADD_TEST_VERSION(semaphores_negative_create_invalid_property, + Version(1, 2)), + ADD_TEST_VERSION(semaphores_negative_create_multi_device_property, + Version(1, 2)), ADD_TEST_VERSION(semaphores_negative_create_invalid_device, Version(1, 2)), + ADD_TEST_VERSION(semaphores_negative_create_import_invalid_device, + Version(1, 2)), ADD_TEST_VERSION(semaphores_negative_create_invalid_value, Version(1, 2)), - ADD_TEST_VERSION(semaphores_negative_create_invalid_operation, Version(1, 2)), + ADD_TEST_VERSION(semaphores_negative_create_invalid_operation, + Version(1, 2)), }; const int test_num = ARRAY_SIZE(test_list); diff --git a/test_conformance/extensions/cl_khr_semaphore/procs.h b/test_conformance/extensions/cl_khr_semaphore/procs.h index bb72ca383..b900d6ee1 100644 --- a/test_conformance/extensions/cl_khr_semaphore/procs.h +++ b/test_conformance/extensions/cl_khr_semaphore/procs.h @@ -57,6 +57,9 @@ extern int test_semaphores_negative_create_multi_device_property( extern int test_semaphores_negative_create_invalid_device( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); +extern int test_semaphores_negative_create_import_invalid_device( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); extern int test_semaphores_negative_create_invalid_value(cl_device_id device, cl_context context, cl_command_queue queue, diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp index ef014dce5..2bea1e905 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp @@ -22,7 +22,6 @@ #include #include - namespace { // CL_INVALID_CONTEXT if context is nullptr. @@ -37,10 +36,8 @@ struct CreateInvalidContext : public SemaphoreTestBase { // Create semaphore cl_semaphore_properties_khr sema_props[] = { - static_cast(CL_SEMAPHORE_TYPE_KHR), - static_cast( - CL_SEMAPHORE_TYPE_BINARY_KHR), - 0 + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR, 0 }; cl_int err = CL_SUCCESS; @@ -91,11 +88,8 @@ struct CreateInvalidProperty : public SemaphoreTestBase // 1) Property name in sema_props is not a supported property name { cl_semaphore_properties_khr sema_props[] = { - static_cast( - CL_INVALID_SEMAPHORE_KHR), - static_cast( - CL_SEMAPHORE_TYPE_BINARY_KHR), - 0 + (cl_semaphore_properties_khr)CL_INVALID_SEMAPHORE_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR, 0 }; semaphore = @@ -108,10 +102,8 @@ struct CreateInvalidProperty : public SemaphoreTestBase // 2) Value specified for a supported property name is not valid { cl_semaphore_properties_khr sema_props[] = { - static_cast(CL_SEMAPHORE_TYPE_KHR), - static_cast( - CL_INVALID_SEMAPHORE_KHR), - 0 + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR, + (cl_semaphore_properties_khr)CL_INVALID_SEMAPHORE_KHR, 0 }; semaphore = @@ -124,11 +116,9 @@ struct CreateInvalidProperty : public SemaphoreTestBase // 3) The same property name is specified more than once { cl_semaphore_properties_khr sema_props[] = { - static_cast(CL_SEMAPHORE_TYPE_KHR), - static_cast( - CL_SEMAPHORE_TYPE_BINARY_KHR), - static_cast(CL_SEMAPHORE_TYPE_KHR), - 0 + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR, 0 }; semaphore = @@ -198,10 +188,8 @@ struct CreateInvalidMultiDeviceProperty : public SemaphoreTestBase test_error_ret(err, "Unable to create testing context", CL_SUCCESS); cl_semaphore_properties_khr sema_props[] = { - static_cast(CL_SEMAPHORE_TYPE_KHR), - static_cast( - CL_SEMAPHORE_TYPE_BINARY_KHR), - 0 + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR, 0 }; // Try to create semaphore with multi device context - expect @@ -270,14 +258,14 @@ struct CreateInvalidDevice : public SemaphoreTestBase // sema_props, but it does not identify exactly one valid device; { cl_semaphore_properties_khr sema_props[] = { - static_cast(CL_SEMAPHORE_TYPE_KHR), - static_cast( - CL_SEMAPHORE_TYPE_BINARY_KHR), - static_cast( - CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR), + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR, + (cl_semaphore_properties_khr) + CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR, (cl_semaphore_properties_khr)device, (cl_semaphore_properties_khr)scope_guard.sub_devices.front(), - CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR, + (cl_semaphore_properties_khr) + CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR, 0 }; @@ -300,13 +288,13 @@ struct CreateInvalidDevice : public SemaphoreTestBase test_error_ret(err, "Unable to create testing context", CL_SUCCESS); cl_semaphore_properties_khr sema_props[] = { - static_cast(CL_SEMAPHORE_TYPE_KHR), - static_cast( - CL_SEMAPHORE_TYPE_BINARY_KHR), - static_cast( - CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR), + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR, + (cl_semaphore_properties_khr) + CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR, (cl_semaphore_properties_khr)device, - CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR, + (cl_semaphore_properties_khr) + CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR, 0 }; @@ -370,20 +358,19 @@ struct CreateImportExternalWithInvalidDevice : public SemaphoreTestBase { if (platform_id == platforms[p]) continue; - err = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_ALL, 0, nullptr, + err = clGetDeviceIDs(platforms[p], CL_DEVICE_TYPE_ALL, 0, nullptr, &num_devices); test_error(err, "clGetDeviceIDs failed"); std::vector devices(num_devices); - err = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_ALL, num_devices, + err = clGetDeviceIDs(platforms[p], CL_DEVICE_TYPE_ALL, num_devices, devices.data(), nullptr); test_error(err, "clGetDeviceIDs failed"); // try to find invalid device for (auto did : devices) { - if (did != device - && !is_extension_available(device, "cl_khr_semaphore")) + if (!is_extension_available(did, "cl_khr_semaphore")) { invalid_device = did; break; @@ -395,7 +382,7 @@ struct CreateImportExternalWithInvalidDevice : public SemaphoreTestBase if (invalid_device == nullptr) { - log_info("Can't find appropriate resources. Skipping test.\n"); + log_info("Can't find needed resources. Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -406,15 +393,12 @@ struct CreateImportExternalWithInvalidDevice : public SemaphoreTestBase // Create semaphore cl_semaphore_properties_khr sema_1_props[] = { - static_cast(CL_SEMAPHORE_TYPE_KHR), - static_cast( - CL_SEMAPHORE_TYPE_BINARY_KHR), - static_cast( - CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR), - static_cast( - CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR), - static_cast( - CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR), + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR, + (cl_semaphore_properties_khr) + CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR, 0 }; semaphore = @@ -444,16 +428,14 @@ struct CreateImportExternalWithInvalidDevice : public SemaphoreTestBase // Create semaphore from sync fd cl_semaphore_properties_khr sema_2_props[] = { - static_cast(CL_SEMAPHORE_TYPE_KHR), - static_cast( - CL_SEMAPHORE_TYPE_BINARY_KHR), - static_cast( - CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR), - static_cast(handle), - static_cast( - CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR), + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR, + (cl_semaphore_properties_khr)handle, + (cl_semaphore_properties_khr)CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR, (cl_semaphore_properties_khr)invalid_device, - CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR, + (cl_semaphore_properties_khr) + CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR, 0 }; @@ -515,17 +497,14 @@ struct CreateInvalidValue : public SemaphoreTestBase // Create semaphore cl_semaphore_properties_khr sema_1_props[] = { - static_cast(CL_SEMAPHORE_TYPE_KHR), - static_cast( - CL_SEMAPHORE_TYPE_BINARY_KHR), - static_cast( - CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR), - static_cast( - CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR), - static_cast( - CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR), - static_cast( - CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR), + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR, + (cl_semaphore_properties_khr) + CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR, + (cl_semaphore_properties_khr) + CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR, 0 }; semaphore = @@ -566,15 +545,12 @@ struct CreateInvalidOperation : public SemaphoreTestBase // Create semaphore cl_semaphore_properties_khr sema_1_props[] = { - static_cast(CL_SEMAPHORE_TYPE_KHR), - static_cast( - CL_SEMAPHORE_TYPE_BINARY_KHR), - static_cast( - CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR), - static_cast( - CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR), - static_cast( - CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR), + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR, + (cl_semaphore_properties_khr) + CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR, 0 }; semaphore = @@ -601,18 +577,14 @@ struct CreateInvalidOperation : public SemaphoreTestBase // a semaphore that was created by importing an external semaphore // handle is not permitted. cl_semaphore_properties_khr sema_2_props[] = { - static_cast(CL_SEMAPHORE_TYPE_KHR), - static_cast( - CL_SEMAPHORE_TYPE_BINARY_KHR), - static_cast( - CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR), - static_cast(handle), - static_cast( - CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR), - static_cast( - CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR), - static_cast( - CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR), + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR, + (cl_semaphore_properties_khr)(handle), + (cl_semaphore_properties_khr)CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR, + (cl_semaphore_properties_khr) + CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR, 0 }; @@ -658,6 +630,16 @@ int test_semaphores_negative_create_invalid_device(cl_device_id device, cl_conte return MakeAndRunTest(device, context, queue); } +// Confirm that creation semaphore with invalid device(s) return +// CL_INVALID_DEVICE +int test_semaphores_negative_create_import_invalid_device( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest( + device, context, queue); +} + // Confirm that creation semaphore with invalid props values return CL_INVALID_VALUE int test_semaphores_negative_create_invalid_value(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements) From a3d5e4bcef2edd32a0f0c986e1b8ff8709daacd6 Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Tue, 7 May 2024 12:12:27 +0200 Subject: [PATCH 4/7] more clang-format corrections --- .../cl_khr_semaphore/semaphore_base.h | 11 +-- .../test_semaphores_negative_create.cpp | 91 +++++++++++-------- 2 files changed, 59 insertions(+), 43 deletions(-) diff --git a/test_conformance/extensions/cl_khr_semaphore/semaphore_base.h b/test_conformance/extensions/cl_khr_semaphore/semaphore_base.h index d6f2316b2..e50f33aed 100644 --- a/test_conformance/extensions/cl_khr_semaphore/semaphore_base.h +++ b/test_conformance/extensions/cl_khr_semaphore/semaphore_base.h @@ -24,7 +24,7 @@ struct SemaphoreBase { - SemaphoreBase(cl_device_id device) : device(device) {} + SemaphoreBase(cl_device_id device): device(device) {} cl_int init_extension_functions() { @@ -59,7 +59,8 @@ struct SemaphoreBase return CL_SUCCESS; } - clCreateSemaphoreWithPropertiesKHR_fn clCreateSemaphoreWithPropertiesKHR = nullptr; + clCreateSemaphoreWithPropertiesKHR_fn clCreateSemaphoreWithPropertiesKHR = + nullptr; clEnqueueSignalSemaphoresKHR_fn clEnqueueSignalSemaphoresKHR = nullptr; clEnqueueWaitSemaphoresKHR_fn clEnqueueWaitSemaphoresKHR = nullptr; clReleaseSemaphoreKHR_fn clReleaseSemaphoreKHR = nullptr; @@ -146,7 +147,7 @@ class clSemaphoreWrapper { } operator cl_semaphore_khr() const { return object; } - operator const cl_semaphore_khr*() { return &object; } + operator const cl_semaphore_khr *() { return &object; } }; struct SemaphoreTestBase : public SemaphoreBase @@ -168,7 +169,6 @@ struct SemaphoreTestBase : public SemaphoreBase virtual cl_int Run() = 0; protected: - cl_context context = nullptr; clCommandQueueWrapper queue = nullptr; clSemaphoreWrapper semaphore = nullptr; @@ -190,8 +190,7 @@ int MakeAndRunTest(cl_device_id device, cl_context context, { auto test_fixture = T(device, context, queue); status = test_fixture.Run(); - } - catch (const std::runtime_error &e) + } catch (const std::runtime_error &e) { log_error("%s", e.what()); return TEST_FAIL; diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp index 2bea1e905..b95bc40b8 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp @@ -137,7 +137,7 @@ struct CreateInvalidProperty : public SemaphoreTestBase struct CreateInvalidMultiDeviceProperty : public SemaphoreTestBase { CreateInvalidMultiDeviceProperty(cl_device_id device, cl_context context, - cl_command_queue queue) + cl_command_queue queue) : SemaphoreTestBase(device, context, queue) {} @@ -145,9 +145,9 @@ struct CreateInvalidMultiDeviceProperty : public SemaphoreTestBase { // partition device and create new context if possible cl_uint maxComputeUnits = 0; - cl_int err = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, - sizeof(maxComputeUnits), &maxComputeUnits, - NULL); + cl_int err = + clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, + sizeof(maxComputeUnits), &maxComputeUnits, NULL); test_error(err, "Unable to get maximal number of compute units"); cl_device_partition_property partitionProp[] = { @@ -156,9 +156,9 @@ struct CreateInvalidMultiDeviceProperty : public SemaphoreTestBase cl_uint deviceCount = 0; // how many sub-devices can we create? - err = clCreateSubDevices(device, partitionProp, 0, nullptr, - &deviceCount); - if(err!=CL_SUCCESS) + err = + clCreateSubDevices(device, partitionProp, 0, nullptr, &deviceCount); + if (err != CL_SUCCESS) { log_info("Can't partition device, test not supported\n"); return TEST_SKIPPED_ITSELF; @@ -173,9 +173,8 @@ struct CreateInvalidMultiDeviceProperty : public SemaphoreTestBase // get the list of subDevices SubDevicesScopeGuarded scope_guard(deviceCount); err = clCreateSubDevices(device, partitionProp, deviceCount, - scope_guard.sub_devices.data(), - &deviceCount); - if(err!=CL_SUCCESS) + scope_guard.sub_devices.data(), &deviceCount); + if (err != CL_SUCCESS) { log_info("Can't partition device, test not supported\n"); return TEST_SKIPPED_ITSELF; @@ -183,8 +182,8 @@ struct CreateInvalidMultiDeviceProperty : public SemaphoreTestBase /* Create a multi device context */ clContextWrapper multi_device_context = clCreateContext( - NULL, (cl_uint)deviceCount, scope_guard.sub_devices.data(), - nullptr, nullptr, &err); + NULL, (cl_uint)deviceCount, scope_guard.sub_devices.data(), nullptr, + nullptr, &err); test_error_ret(err, "Unable to create testing context", CL_SUCCESS); cl_semaphore_properties_khr sema_props[] = { @@ -232,7 +231,7 @@ struct CreateInvalidDevice : public SemaphoreTestBase // how many sub-devices can we create? err = clCreateSubDevices(device, partitionProp, 0, nullptr, &deviceCount); - if(err!=CL_SUCCESS) + if (err != CL_SUCCESS) { log_info("Can't partition device, test not supported\n"); return TEST_SKIPPED_ITSELF; @@ -248,7 +247,7 @@ struct CreateInvalidDevice : public SemaphoreTestBase SubDevicesScopeGuarded scope_guard(deviceCount); err = clCreateSubDevices(device, partitionProp, deviceCount, scope_guard.sub_devices.data(), &deviceCount); - if(err!=CL_SUCCESS) + if (err != CL_SUCCESS) { log_info("Can't partition device, test not supported\n"); return TEST_SKIPPED_ITSELF; @@ -415,8 +414,8 @@ struct CreateImportExternalWithInvalidDevice : public SemaphoreTestBase int handle = -1; size_t handle_size; err = clGetSemaphoreHandleForTypeKHR( - semaphore, device, CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR, sizeof(handle), - &handle, &handle_size); + semaphore, device, CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR, + sizeof(handle), &handle, &handle_size); test_error(err, "Could not extract semaphore handle"); test_assert_error(sizeof(handle) == handle_size, "Invalid handle size"); test_assert_error(handle >= 0, "Invalid handle"); @@ -567,8 +566,8 @@ struct CreateInvalidOperation : public SemaphoreTestBase int handle = -1; size_t handle_size; err = clGetSemaphoreHandleForTypeKHR( - semaphore, device, CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR, sizeof(handle), - &handle, &handle_size); + semaphore, device, CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR, + sizeof(handle), &handle, &handle_size); test_error(err, "Could not extract semaphore handle"); test_assert_error(sizeof(handle) == handle_size, "Invalid handle size"); test_assert_error(handle >= 0, "Invalid handle"); @@ -602,30 +601,42 @@ struct CreateInvalidOperation : public SemaphoreTestBase } -// Confirm that creation semaphore with nullptr context would return CL_INVALID_CONTEXT -int test_semaphores_negative_create_invalid_context(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +// Confirm that creation semaphore with nullptr context would return +// CL_INVALID_CONTEXT +int test_semaphores_negative_create_invalid_context(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements) { return MakeAndRunTest(device, context, queue); } -// Confirm that creation semaphore with invalid properties return CL_INVALID_PROPERTY -int test_semaphores_negative_create_invalid_property(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +// Confirm that creation semaphore with invalid properties return +// CL_INVALID_PROPERTY +int test_semaphores_negative_create_invalid_property(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements) { return MakeAndRunTest(device, context, queue); } -// Confirm that creation semaphore with multi device property return CL_INVALID_PROPERTY -int test_semaphores_negative_create_multi_device_property(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +// Confirm that creation semaphore with multi device property return +// CL_INVALID_PROPERTY +int test_semaphores_negative_create_multi_device_property( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements) { - return MakeAndRunTest(device, context, queue); + return MakeAndRunTest(device, context, + queue); } -// Confirm that creation semaphore with invalid device(s) return CL_INVALID_DEVICE -int test_semaphores_negative_create_invalid_device(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +// Confirm that creation semaphore with invalid device(s) return +// CL_INVALID_DEVICE +int test_semaphores_negative_create_invalid_device(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements) { return MakeAndRunTest(device, context, queue); } @@ -640,16 +651,22 @@ int test_semaphores_negative_create_import_invalid_device( device, context, queue); } -// Confirm that creation semaphore with invalid props values return CL_INVALID_VALUE -int test_semaphores_negative_create_invalid_value(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +// Confirm that creation semaphore with invalid props values return +// CL_INVALID_VALUE +int test_semaphores_negative_create_invalid_value(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements) { return MakeAndRunTest(device, context, queue); } -// Confirm that creation semaphore with invalid props values return CL_INVALID_VALUE -int test_semaphores_negative_create_invalid_operation(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +// Confirm that creation semaphore with invalid props values return +// CL_INVALID_VALUE +int test_semaphores_negative_create_invalid_operation(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements) { return MakeAndRunTest(device, context, queue); } From 83b129c0f41c56dd469e5c3997f90c6e7f34c054 Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Mon, 17 Jun 2024 08:04:37 +0200 Subject: [PATCH 5/7] Correction related to code review --- .../cl_khr_semaphore/test_semaphores_negative_create.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp index b95bc40b8..30daf6c33 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp @@ -590,7 +590,7 @@ struct CreateInvalidOperation : public SemaphoreTestBase semaphore_second = clCreateSemaphoreWithPropertiesKHR(context, sema_2_props, &err); test_failure_error( - err, CL_INVALID_DEVICE, + err, CL_INVALID_OPERATION, "Unexpected clCreateSemaphoreWithPropertiesKHR return"); return CL_SUCCESS; From 62d8f494100830902416efc39fb056b5edcc9d59 Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Thu, 4 Jul 2024 13:48:28 +0200 Subject: [PATCH 6/7] Corrected condition to allow both CL_INVALID_PROPERTY and CL_INVALID_VALUE in overlapping cases --- .../test_semaphores_negative_create.cpp | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp index 30daf6c33..282c43c4a 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp @@ -94,9 +94,15 @@ struct CreateInvalidProperty : public SemaphoreTestBase semaphore = clCreateSemaphoreWithPropertiesKHR(context, sema_props, &err); - test_failure_error( - err, CL_INVALID_PROPERTY, - "Unexpected clCreateSemaphoreWithPropertiesKHR return"); + + if (err != CL_INVALID_PROPERTY && err != CL_INVALID_VALUE) + { + log_error("Unexpected clCreateSemaphoreWithPropertiesKHR " + "result, expected " + "CL_INVALID_PROPERTY or CL_INVALID_VALUE, got %s\n", + IGetErrorString(err)); + return TEST_FAIL; + } } // 2) Value specified for a supported property name is not valid @@ -108,9 +114,15 @@ struct CreateInvalidProperty : public SemaphoreTestBase semaphore = clCreateSemaphoreWithPropertiesKHR(context, sema_props, &err); - test_failure_error( - err, CL_INVALID_PROPERTY, - "Unexpected clCreateSemaphoreWithPropertiesKHR return"); + + if (err != CL_INVALID_PROPERTY && err != CL_INVALID_VALUE) + { + log_error("Unexpected clCreateSemaphoreWithPropertiesKHR " + "result, expected " + "CL_INVALID_PROPERTY or CL_INVALID_VALUE, got %s\n", + IGetErrorString(err)); + return TEST_FAIL; + } } // 3) The same property name is specified more than once @@ -128,7 +140,7 @@ struct CreateInvalidProperty : public SemaphoreTestBase "Unexpected clCreateSemaphoreWithPropertiesKHR return"); } - return CL_SUCCESS; + return TEST_PASS; } }; From 1c3b17b53e2dee3b58450050baded0e8d7e8637d Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Thu, 18 Jul 2024 09:04:41 +0200 Subject: [PATCH 7/7] Corrected negative test for CreateInvalidProperty ... in order to avoid using CL_INVALID_SEMAPHORE_KHR as property name or value --- .../cl_khr_semaphore/test_semaphores_negative_create.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp index 282c43c4a..753e6f42f 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp @@ -87,8 +87,9 @@ struct CreateInvalidProperty : public SemaphoreTestBase // Create semaphore with invalid properties: // 1) Property name in sema_props is not a supported property name { + cl_semaphore_properties_khr invalid_property_name = ~0UL; cl_semaphore_properties_khr sema_props[] = { - (cl_semaphore_properties_khr)CL_INVALID_SEMAPHORE_KHR, + invalid_property_name, (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR, 0 }; @@ -107,9 +108,10 @@ struct CreateInvalidProperty : public SemaphoreTestBase // 2) Value specified for a supported property name is not valid { + cl_semaphore_properties_khr invalid_property_value = ~0UL; cl_semaphore_properties_khr sema_props[] = { (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR, - (cl_semaphore_properties_khr)CL_INVALID_SEMAPHORE_KHR, 0 + invalid_property_value, 0 }; semaphore =