OpenCL™规范 5.17.4. 命令缓冲区排队

5.17.4. Enqueuing a Command-Buffer
5.17.4. 命令缓冲区排队

To finalize command recording ready for enqueuinga command-buffer on a command-queue, call the function

要完成命令记录,准备查询命令队列上的命令缓冲区,请调用以下函数

// Provided by cl_khr_command_buffer
cl_int clFinalizeCommandBufferKHR(
    cl_command_buffer_khr command_buffer);

clFinalizeCommandBufferKHR is provided by the cl_khr_command_buffer extension.

clFinalizeCommandBufferKHR由cl_khr_command_buffer扩展提供。

  • command_buffer refers to a valid command-buffer object.

  • command_buffer引用了一个有效的命令缓冲区对象。

clFinalizeCommandBufferKHR places the command-buffer in the Executable state where commands can no longer be recorded, at this point the command-buffer is ready to be enqueued.

clFinalizeCommandBufferKHR将命令缓冲区置于可执行状态,在该状态下无法再记录命令,此时命令缓冲区已准备好排队。

clFinalizeCommandBufferKHR returns CL_SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:

如果函数执行成功,clFinalizeCommandBufferKHR将返回CL_SUCCESS。否则,它将返回以下错误之一:

  • CL_INVALID_COMMAND_BUFFER_KHR if command_buffer is not a valid command-buffer.

  • 如果command_buffer不是有效的命令缓冲区,则返回CL_INVALID_COMMAND_BUFFER_KHR。

  • CL_INVALID_OPERATION if command_buffer is not in the Recording state.

  • 如果command_buffer未处于录制状态,则为CL_INVALID_OPERATION。

  • 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实现所需的资源。

To enqueue a command-buffer to execute on command-queues, call the function

要将命令缓冲区排队以在命令队列上执行,请调用以下函数

// Provided by cl_khr_command_buffer
cl_int clEnqueueCommandBufferKHR(
    cl_uint num_queues,
    cl_command_queue* queues,
    cl_command_buffer_khr command_buffer,
    cl_uint num_events_in_wait_list,
    const cl_event* event_wait_list,
    cl_event* event);

clEnqueueCommandBufferKHR is provided by the cl_khr_command_buffer extension.

clEnqueueCommandBufferKHR由cl_khr_command_buffer扩展提供。

  • num_queues is the number of command-queues listed in queues.

  • num_queues是队列中列出的命令队列的数量。

  • queues is a pointer to an ordered list of command-queues compatible with the command-queues used on recording. queues can be NULL, in which case the default command-queues used on command-buffer creation are used and num_queues must be 0.

  • queues是指向与录制时使用的命令队列兼容的命令队列的有序列表的指针。queues可以为NULL,在这种情况下,将使用创建命令缓冲区时使用的默认命令队列,并且num_queues必须为0。

  • command_buffer refers to a valid command-buffer object.

  • command_buffer引用了一个有效的命令缓冲区对象。

  • event_wait_listnum_events_in_wait_list specify events that need to complete before this particular command can be executed. If event_wait_list is NULL, then this particular command does not wait on any event to complete. If event_wait_list is NULLnum_events_in_wait_list must be 0. If event_wait_list is not NULL, the list of events pointed to by event_wait_list must be valid and num_events_in_wait_list must be greater than 0. The events specified in event_wait_list act as synchronization points. The context associated with events in event_wait_list and command_queue must be the same. The memory associated with event_wait_list can be reused or freed after the function returns.

  • event_wait_listnum_events_in_wait_list指定了在执行此特定命令之前需要完成的事件。如果event_wait_list为NULL,则此特定命令不会等待任何事件完成。如果event_wait_list为NULL,则num_events_in_wait_list必须为0。如果event_wait_list不为NULL,则event_wait-list指向的事件列表必须有效,num_events_in_wait_list必须大于0。event_wait_list中指定的事件充当同步点。与event_wait_list和command_queue中的事件关联的上下文必须相同。函数返回后,可以重用或释放与event_wait_list关联的内存。

  • event will return an event object that identifies this command and can be used to query for profiling information or queue a wait for this particular command to complete. event can be NULL in which case it will not be possible for the application to wait on this command or query it for profiling information.

  • event将返回一个事件对象,该对象标识此命令,可用于查询分析信息或排队等待此特定命令完成。event可以为NULL,在这种情况下,应用程序将无法等待此命令或查询其分析信息。

To enqueue a command-buffer it must be in a Executable state, see clFinalizeCommandBufferKHR.


要将命令缓冲区排队,它必须处于可执行状态,请参阅clFinalizeCommandBufferKHR。

clEnqueueCommandBufferKHR returns CL_SUCCESS if the command-buffer execution was successfully queued, or one of the errors below:

如果命令缓冲区执行已成功排队,或者出现以下错误之一,clEnqueueCommandBufferKHR将返回CL_SUCCESS:

  • CL_INVALID_COMMAND_BUFFER_KHR if command_buffer is not a valid command-buffer.

  • 如果command_buffer不是有效的命令缓冲区,则返回CL_INVALID_COMMAND_BUFFER_KHR。

  • CL_INVALID_OPERATION if command_buffer has not been finalized.

  • CL_INVALID_OPERATION(如果command_buffer尚未完成)。

  • CL_INVALID_OPERATION if command_buffer was not created with the CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR flag and is in the Pending state.

  • 如果command_buffer不是使用CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR标志创建的,并且处于挂起状态,则为CL_INVALID_OPERATION。

  • CL_INVALID_VALUE if queues is NULL and num_queues is > 0, or queues is not NULL and num_queues is 0.

  • CL_INVALID_VALUE,如果queues为NULL且num_queue大于0,或者队列不为NULL且num _queue为0。

  • CL_INVALID_VALUE if num_queues is > 0 and not the same value as num_queues set on command_buffer creation.

  • 如果num_queues大于0,并且与command_buffer创建时设置的num_queues值不同,则为CL_INVALID_VALUE。

  • CL_INVALID_COMMAND_QUEUE if any element of queues is not a valid command-queue.

  • CL_INVALID_COMMAND_QUEUE,如果queues的任何元素不是有效的命令队列。

  • CL_INCOMPATIBLE_COMMAND_QUEUE_KHR if any element of queues is not compatible with the command-queue set on command_buffer creation at the same list index.

  • 如果queues的任何元素与在同一列表索引处创建command_buffer时设置的命令队列不兼容,则返回CL_INCOMPATIBLE_COMMAND_QUEUE_KHR。

  • CL_INVALID_CONTEXT if any element of queues does not have the same context as the command-queue set on command_buffer creation at the same list index.

  • CL_INVALID_CONTEXT,如果queues的任何元素与在同一列表索引处创建command_buffer时设置的命令队列没有相同的上下文。

  • CL_INVALID_CONTEXT if context associated with command_buffer and events in event_wait_list are not the same.

  • 如果与command_buffer关联的上下文和event_wait_list中的事件不相同,则返回CL_INVALID_CONTEXT。

  • CL_OUT_OF_RESOURCES if there is a failure to queue the execution instance of command_buffer on the command-queues because of insufficient resources needed to execute command_buffer.

  • CL_OUT_OF_RESOURCES,如果由于执行command_buffer所需的资源不足,导致无法在命令队列上对command_buffer的执行实例进行排队。

  • CL_INVALID_EVENT_WAIT_LIST if event_wait_list is NULL and num_events_in_wait_list > 0, or event_wait_list is not NULL and num_events_in_wait_list is 0, or if event objects in event_wait_list are not valid events.

  • 如果event_wait_list为NULL且num_events_in_wait_list>0,或者event_wait_list不为NULL且num_events_in_wait_list为0,或者event_wait_list中的事件对象不是有效事件,则CL_INVALID_EVENT_WAIT_LIST。

  • 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实现所需的资源。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值