5.13.7. Retaining and Releasing Semaphores
5.13.7. 保留和释放信号量
To release a semaphore object, call the function
要释放信号量对象,请调用函数
// Provided by cl_khr_semaphore
cl_int clReleaseSemaphoreKHR(
cl_semaphore_khr sema_object);
clReleaseSemaphoreKHR is provided by the clReleaseSemaphoreKHR由cl_khr_maphore扩展提供。 |
-
sema_object specifies the semaphore object to be released.
-
sema_object指定要释放的信号量对象。
The sema_object reference count is decremented.
sema_object引用计数递减。
clReleaseSemaphoreKHR returns CL_SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:
如果函数执行成功,clReleaseSemaphoreKHR将返回CL_SUCCESS。否则,它将返回以下错误之一:
-
CL_INVALID_SEMAPHORE_KHR if sema_object is not a valid semaphore object.
-
CL_INVALID_SEMAPHORE_KHR,如果sema_object不是有效的信号量对象。
-
CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.
-
CL_OUT_OF_RESOURCES,如果无法在设备上分配OpenCL实现所需的资源。
-
CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.
-
CL_OUT_OF_HOST_MEMORY,如果无法在主机上分配OpenCL实现所需的资源。
After the reference count becomes zero and commands queued for execution on a command-queue(s) that use sema_object have finished, the semaphore object is deleted. Using this function to release a reference that was not obtained by creating the object via clCreateSemaphoreWithPropertiesKHR or by calling clRetainSemaphoreKHR causes undefined behavior.
在引用计数变为零并且在使用sema_object的命令队列上排队等待执行的命令完成后,信号量对象将被删除。使用此函数释放不是通过clCreateSemaphoreWithPropertiesKHR创建对象或调用clRetainSemaphoreKHR获得的引用会导致未定义的行为。
To retain a semaphore object, call the function
要保留信号量对象,请调用函数
// Provided by cl_khr_semaphore
cl_int clRetainSemaphoreKHR(
cl_semaphore_khr sema_object);
clRetainSemaphoreKHR is provided by the clRetainSemaphoreKHR由cl_khr_maphore扩展提供。 |
-
sema_object specifies the semaphore object to be retained.
-
sema_object指定要保留的信号量对象。
clRetainSemaphoreKHR increments the reference count of sema_object.
clRetainSemaphoreKHR递增sema_object的引用计数。
clRetainSemaphoreKHR returns CL_SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:
如果函数执行成功,clRetainSemaphoreKHR将返回CL_SUCCESS。否则,它将返回以下错误之一:
-
CL_INVALID_SEMAPHORE_KHR if sema_object is not a valid semaphore object.
-
CL_INVALID_SEMAPHORE_KHR,如果sema_object不是有效的信号量对象。
-
CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.
-
CL_OUT_OF_RESOURCES,如果无法在设备上分配OpenCL实现所需的资源。
-
CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.
-
CL_OUT_OF_HOST_MEMORY,如果无法在主机上分配OpenCL实现所需的资源。