OpenCL Runtime: Command Queues and Events¶
Command Queue¶
-
class
pyopencl.
CommandQueue
(context, device=None, properties=None)¶ Create a new command queue. properties is a bit field consisting of
command_queue_properties
values.if device is None, one of the devices in context is chosen in an implementation-defined manner.
A
CommandQueue
may be used as a context manager, like this:with cl.CommandQueue(self.cl_context) as queue: enqueue_stuff(queue, ...)
finish()
is automatically called at the end of the context.New in version 2013.1: Context manager capability.
-
info
¶ Lower case versions of the
command_queue_info
constants may be used as attributes on instances of this class to directly query info attributes.
-
get_info
(param)¶ See
command_queue_info
for values of param.
-
set_property
(prop, enable)¶ See
command_queue_properties
for possible values of prop. enable is abool
.Unavailable in OpenCL 1.1 and newer.
-
flush
()¶
-
finish
()¶
-
from_int_ptr
(int_ptr_value, retain=True)¶ Constructs a
pyopencl
handle from a C-level pointer (given as the integer int_ptr_value). If retain is True (the defauult)pyopencl
will callclRetainXXX
on the provided object. If the previous owner of the object will not release the reference, retain should be set to False, to effectively transfer ownership topyopencl
.Changed in version 2016.1: retain added
-
int_ptr
¶
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.
-
Event¶
-
class
pyopencl.
Event
¶ -
info
¶ Lower case versions of the
event_info
constants may be used as attributes on instances of this class to directly query info attributes.
-
profile.
info
¶ Lower case versions of the
profiling_info
constants may be used as attributes on the attribute profile of this class to directly query profiling info.For example, you may use evt.profile.end instead of evt.get_profiling_info(pyopencl.profiling_info.END).
-
get_info
(param)¶ See
event_info
for values of param.
-
get_profiling_info
(param)¶ See
profiling_info
for values of param. Seeprofile
for an easier way of obtaining the same information.
-
wait
()¶
-
from_int_ptr
(int_ptr_value, retain=True)¶ Constructs a
pyopencl
handle from a C-level pointer (given as the integer int_ptr_value). If retain is True (the defauult)pyopencl
will callclRetainXXX
on the provided object. If the previous owner of the object will not release the reference, retain should be set to False, to effectively transfer ownership topyopencl
.Changed in version 2016.1: retain added
-
int_ptr
¶
-
set_callback
(type, cb)¶ Add the callback cb with signature
cb(status)
to the callback queue for the event status type (one of the values ofcommand_execution_status
, exceptcommand_execution_status.QUEUED
).See the OpenCL specification for restrictions on what cb may and may not do.
New in version 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.
-
Event Subclasses¶
-
class
pyopencl.
UserEvent
(context)¶ A subclass of
Event
. Only available with OpenCL 1.1 and newer.New in version 0.92.
-
set_status
(status)¶ See
command_execution_status
for possible values of status.
-
-
class
pyopencl.
NannyEvent
¶ Transfers between host and device return events of this type. They hold a reference to the host-side buffer and wait for the transfer to complete when they are freed. Therefore, they can safely release the reference to the object they’re guarding upon destruction.
A subclass of
Event
.New in version 2011.2.
-
get_ward
()¶
-
wait
()¶ In addition to performing the same wait as
Event.wait()
, this method also releases the reference to the guarded object.
-
Synchronization Functions¶
-
pyopencl.
wait_for_events
(events)¶