OpenCL运行时:命令队列和事件#

命令队列#

class pyopencl.CommandQueue(context, device=None, properties=None)#

创建新的命令队列。 性质 位字段由 command_queue_properties 价值观。

如果 装置 是无,是中的一个设备 语境 以实现定义的方式选择。

性质 可以是来自 queue_properties (或) None 相当于通过 0 ). 这与opencl1.x和2.x都兼容。

对于OpenCL 2.0及更高版本, 性质 也可以是来自 queue_properties 已被接受 clCreateCommandQueueWithProperties() (有关详细信息,请参见OpenCL规范)。尾随 0 是自动添加的,不需要包括在内。

A CommandQueue 可以用作上下文管理器,如下所示:

with cl.CommandQueue(self.cl_context) as queue:
    enqueue_stuff(queue, ...)

finish() 方法的末尾自动调用 with -分隔的上下文和对队列的进一步操作被视为错误。

在 2013.1 版本加入: 上下文管理器功能。

在 2018.2 版本发生变更: 为opencl2添加了属性序列接口。

在 2022.1.4 版本发生变更: 在其上下文管理器完成之后使用命令队列现在被认为是错误的。 pyopencl 将在过渡期就此发出警告,并将于2023年开始提出例外。

info#

的小写版本 command_queue_info 常量可以用作此类实例上的属性,以直接查询信息属性。

get_info(param)#

command_queue_info 对于价值 param .

set_property(prop, enable)#

command_queue_properties 对于可能的值 prop . 使可能 是一个 bool .

在opencl1.1及更新版本中不可用。

flush()#
finish()#
static from_int_ptr(int_ptr_value: int, retain: bool = True) pyopencl._cl.CommandQueue#

(静态方法)返回引用C-Level的新的Python对象 cl_command_queue 对象指向的位置上的 int_ptr_value 。相关的 clRetain* 函数将在以下情况下被调用 retain 为真。如果对象的前一个所有者将 not 释放引用, retain 应设置为 False ,以有效地将所有权转移到 pyopencl

在 2013.2 版本加入.

在 2016.1 版本发生变更: retain 添加了。

int_ptr#

返回一个整数,该整数与基础 cl_command_queue 。使用 from_int_ptr() 以转回为一个Python对象。

在 2013.2 版本加入.

Instances of this class are hashable, and two instances of this class may be compared using "==" and "!=". (Hashability was added in version 2011.2.) Two objects are considered the same if the underlying OpenCL object is the same, as established by C pointer equality.

事件#

class pyopencl.Event#
info#

的小写版本 event_info 常量可以用作此类实例上的属性,以直接查询信息属性。

profile#

的实例 ProfilingInfoGetter .

get_info(param)#

event_info 对于价值 param .

get_profiling_info(param)#

profiling_info 对于价值 param . 见 profile 为了更容易获得相同的信息。

wait()#
static from_int_ptr(int_ptr_value: int, retain: bool = True) pyopencl._cl.Event#

(静态方法)返回引用C-Level的新的Python对象 cl_event 对象指向的位置上的 int_ptr_value 。相关的 clRetain* 函数将在以下情况下被调用 retain 为真。如果对象的前一个所有者将 not 释放引用, retain 应设置为 False ,以有效地将所有权转移到 pyopencl

在 2013.2 版本加入.

在 2016.1 版本发生变更: retain 添加了。

int_ptr#

返回一个整数,该整数与基础 cl_event 。使用 from_int_ptr() 以转回为一个Python对象。

在 2013.2 版本加入.

set_callback(type, cb)#

添加回调 cb 有签名 cb(status) 事件状态的回调队列 type (价值之一) command_execution_status 除外 command_execution_status.QUEUED

请参阅OpenCL规范以了解对什么的限制 cb 可能做也可能不做。

在 2015.2 版本加入.

Instances of this class are hashable, and two instances of this class may be compared using "==" and "!=". (Hashability was added in version 2011.2.) Two objects are considered the same if the underlying OpenCL object is the same, as established by C pointer equality.

class pyopencl.ProfilingInfoGetter#
info#

的小写版本 profiling_info 常量可以用作属性上的属性 profile 来直接查询分析信息。

例如,您可以使用 evt.profile.end 而不是 evt.get_profiling_info(pyopencl.profiling_info.END) .

事件子类#

class pyopencl.UserEvent(context)#

一个子类 Event . 仅适用于OpenCL 1.1及更新版本。

在 0.92 版本加入.

set_status(status)#

command_execution_status 对于可能的值 地位 .

class pyopencl.NannyEvent#

主机和设备之间的传输返回此类型的事件。它们持有对主机端缓冲区的引用,并在释放时等待传输完成。因此,他们可以在破坏时安全地释放对所保护对象的引用。

一个子类 Event .

在 2011.2 版本加入.

get_ward()#
wait()#

除了执行与 Event.wait() ,此方法还释放对受保护对象的引用。

同步功能#

pyopencl.wait_for_events(events)#
pyopencl.enqueue_barrier(queue, wait_for=None)[源代码]#

在障碍物操作中排队。它确保命令队列中所有排队的命令都已完成执行。此命令是一个同步点。

在 0.91.5 版本加入.

在 2011.2 版本发生变更: wait_for 并返回 Event

pyopencl.enqueue_marker(queue, wait_for=None)[源代码]#

返回一个 Event .

在 2011.2 版本发生变更: wait_for .