OpenCL运行时:平台、设备和上下文#
Platform#
- class pyopencl.Platform#
- info#
的小写版本
platform_info
常量可以用作此类实例上的属性,以直接查询信息属性。
- get_info(param)#
见
platform_info
对于价值 param .
- get_devices(device_type=device_type.ALL)#
返回匹配的设备列表 device_type . 见
device_type
对于价值 device_type .在 2013.2 版本发生变更: 如果找不到匹配的设备,则会引发异常。现在,它只返回一个空列表。
- static from_int_ptr(int_ptr_value: int, retain: bool = True) pyopencl._cl.Platform #
(静态方法)返回引用C-Level的新的Python对象
cl_platform_id
对象指向的位置上的 int_ptr_value 。相关的clRetain*
函数将在以下情况下被调用 retain 为真。如果对象的前一个所有者将 not 释放引用, retain 应设置为 False ,以有效地将所有权转移到pyopencl
。在 2013.2 版本加入.
在 2016.1 版本发生变更: retain 添加了。
- int_ptr#
返回一个整数,该整数与基础
cl_platform_id
。使用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.Device#
此类的两个实例可以使用 ==" 和 "!=" .
- info#
的小写版本
device_info
常量可以用作此类实例上的属性,以直接查询信息属性。
- get_info(param)#
见
device_info
对于价值 param .
- static from_int_ptr(int_ptr_value: int, retain: bool = True) pyopencl._cl.Device #
(静态方法)返回引用C-Level的新的Python对象
cl_device_id
对象指向的位置上的 int_ptr_value 。相关的clRetain*
函数将在以下情况下被调用 retain 为真。如果对象的前一个所有者将 not 释放引用, retain 应设置为 False ,以有效地将所有权转移到pyopencl
。在 2013.2 版本加入.
在 2016.1 版本发生变更: retain 添加了。
- int_ptr#
返回一个整数,该整数与基础
cl_device_id
。使用from_int_ptr()
以转回为一个Python对象。在 2013.2 版本加入.
- hashable_model_and_version_identifier#
一种未指定的数据类型,可用于(尽可能精确地,给定OpenCL中可用的标识信息)标识计算设备的给定模型和软件堆栈版本。请注意,此标识符不区分安装在单个主机中的同一设备的不同实例。
返回的数据类型是可哈希的。
在 2020.1 版本加入.
- create_sub_devices(properties)#
性质 是一个(或多个)形式的数组:
[ dpp.EQUALLY, 8] [ dpp.BY_COUNTS, 5, 7, 9, dpp.PARTITION_BY_COUNTS_LIST_END] [ dpp.BY_NAMES, 5, 7, 9, dpp.PARTITION_BY_NAMES_LIST_END] [ dpp.BY_AFFINITY_DOMAIN, dad.L1_CACHE]
哪里
dpp
表示device_partition_property
和dad
表示device_affinity_domain
。PROPERTIES_LIST_END_EXT
是自动添加的。仅适用于CL 1.2。
在 2011.2 版本加入.
- device_and_host_timer()#
- 返回:
元组
(device_timestamp, host_timestamp)
.
仅适用于CL 2.0。
在 2020.3 版本加入.
- host_timer()#
仅适用于CL 2.0。
在 2020.3 版本加入.
语境#
- class pyopencl.Context(devices=None, properties=None, dev_type=None, cache_dir=None)#
创建新的上下文。 properties 是键-值元组的列表,其中每个键必须是
context_properties
。最多只有一个 devices 和 dev_type 可能不是 None ,在哪里 devices 是一份Device
实例,以及 dev_type 是device_type
常量。如果两者都未指定,则具有 dev_type 的device_type.DEFAULT
被创造出来了。如果 cache_dir 不是 None -它将用作默认设置 cache_dir 对于它所有的一切
Program
实例构建(另请参阅Program.build()
)。备注
对于支持OpenCL ICD的最新CL驱动程序,调用不带参数的构造函数将失败。如果你想要类似的,只是给我一个上下文已经行为,我们建议
create_some_context()
。看到了吗,例如这个 explanation by AMD 。备注
由于OpenCL如何改变以支持opencl1.1中的可安装客户机驱动程序(icd),下面将 look 合理但通常不起作用:
import pyopencl as cl ctx = cl.Context(dev_type=cl.device_type.ALL)
相反,在按类型选择设备时,请确保选择平台:
import pyopencl as cl platforms = cl.get_platforms() ctx = cl.Context( dev_type=cl.device_type.ALL, properties=[(cl.context_properties.PLATFORM, platforms[0])])
备注
为了
context_properties.CL_GL_CONTEXT_KHR
,context_properties.CL_EGL_DISPLAY_KHR
,context_properties.CL_GLX_DISPLAY_KHR
,context_properties.CL_WGL_HDC_KHR
和context_properties.CL_CGL_SHAREGROUP_KHR
context_properties.CL_CGL_SHAREGROUP_APPLE
键值对中的值是PyOpenGL上下文或显示实例。在 0.91.2 版本发生变更: 构造函数参数 dev_type 补充。
- info#
的小写版本
context_info
常量可以用作此类实例上的属性,以直接查询信息属性。
- get_info(param)#
见
context_info
对于价值 param .
- static from_int_ptr(int_ptr_value: int, retain: bool = True) pyopencl._cl.Context #
(静态方法)返回引用C-Level的新的Python对象
cl_context
对象指向的位置上的 int_ptr_value 。相关的clRetain*
函数将在以下情况下被调用 retain 为真。如果对象的前一个所有者将 not 释放引用, retain 应设置为 False ,以有效地将所有权转移到pyopencl
。在 2013.2 版本加入.
在 2016.1 版本发生变更: retain 添加了。
- int_ptr#
返回一个整数,该整数与基础
cl_context
。使用from_int_ptr()
以转回为一个Python对象。在 2013.2 版本加入.
- set_default_device_command_queue(dev, queue)#
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.