opencl.Platform not constructable
use opencl.get_platforms() to get a list of
list of all devices attached to this platform
platform extensions as a string
plat.get_devices(device_type=opencl.Device.ALL)
return a list of devices by type.
platform name
return the plafrom profile info
platform vendor
return the version string of the platform
device type default.
test if this device supports the openc.Image class
test if this device supports native python kernels
test if this device supports out_of_order_exec_mode for queues
test if this device supports profiling for queues
The number of parallel compute cores on the OpenCL device. The minimum value is 1.
Maximum dimensions that specify the global and local work-item IDs used by the data parallel execution model. (Refer to clEnqueueNDRangeKernel).
The minimum value is 3.
Maximum number of work-items that can be specified in each dimension to opencl.Queue.enqueue_nd_range_kernel.
Returns: | n entries, where n is the value returned by the query for opencl.Device.max_work_item_dimensions |
---|
the name of this device
return the platform this device is associated with.
return queue properties as a bitfield
see also has_queue_out_of_order_exec_mode and has_queue_profiling
return device type: one of [Device.DEFAULT, Device.ALL, Device.GPU or Device.CPU]
return the vendor ID
An event object can be used to track the execution status of a command. The API calls that enqueue commands to a command-queue create a new event object that is returned in the event argument.
event.add_callback(callback) Registers a user callback function for on completion of the event.
Parameters: | callback – must be of the signature callback(event, status) |
---|
the current status of the event.
event.wait()
Waits on the host thread for commands identified by event objects in event_list to complete. A command is considered complete if its execution status is CL_COMPLETE or a negative value.
Create an opencl program.
Parameters: |
|
---|
Return a kernel object.
Memory objects are categorized into two types: buffer objects, and image objects. A buffer object stores a one-dimensional collection of elements whereas an image object is used to store a two- or three- dimensional texture, frame-buffer or image.
memobj.add_destructor_callback(callback)
Registers a user callback function with a memory object. Each call to add_destructor_callback registers the specified user callback function on a callback stack associated with memobj.
The registered user callback functions are called in the reverse order in which they were registered. The user callback functions are called and then the memory object’s resources are freed and the memory object is deleted. This provides a mechanism for the application (and libraries) using memobj to be notified when the memory referenced by host_ptr, specified when the memory object is created and used as the storage bits for the memory object, can be reused or freed.
Parameters: | callback – function with the signature callback(memobj) |
---|
Return the original memobject if this is a sub-buffer.
Return the offset from base of this is a subbuffer.
Return the context that this object was created with.
Return the pointer to the opencl memory object.
Return the size in bytes of this memory object.
return the enumed type of this object. One of MemoryObject.BUFFER, MemoryObject.IMAGE2D or MemoryObject.IMAGE3D
A buffer object stores a one-dimensional collection of elements. Elements of a buffer object can be a scalar data type (such as an int, float), vector data type, or a user-defined structure
Copy this buffer into a new object
Is ctype format of the elements
DeviceMemoryView.from_host(context, host, copy=True, readable=True, writeable=True)
Create an OpenCL buffer from a Python memoryview object.
is this array C-contiguous
Return a python object if the size of this array is 1.
Is size of each element
DeviceMemoryView.map(queue, blocking=True, readable=True, writeable=True)
enqueues a command to map a region of the buffer object given by buffer into the host address space and returns a pointer to this mapped region.
Total number of bytes
number of dimensions
buf.read(queue, out, wait_on=(), blocking=False)
Read this buffer into a memory view
Is this memory writable
Shape of the array
Total number of elements
Strides of the array
view.write(queue, buf, wait_on=(), blocking=False)
Write data from a memoryview to the device.
opencl.Context(devices=(), device_type=cl.Device.DEFAULT, ContextProperties properties=None, callback=print_context_error)
Creates an OpenCL context. An OpenCL context is created with one or more devices. Contexts are used by the OpenCL runtime for managing objects such as command-queues, memory, program and kernel objects and for executing kernels on one or more devices specified in the context.
Parameters: |
|
---|
return a list of devices associated with this context
return the number of devices
return a ContextProperties object
return opencl internal refrence count of this object
opencl.Queue(context, device=None, out_of_order_exec_mode=False, profiling=False)
OpenCL objects such as memory, program and kernel objects are created using a context. Operations on these objects are performed using a command-queue. The command-queue can be used to queue a set of operations (referred to as commands) in order. Having multiple command-queues allows applications to queue multiple independent commands without requiring synchronization. Note that this should work as long as these objects are not being shared. Sharing of objects across multiple command-queues will require the application to perform appropriate synchronization
Parameters: |
|
---|
queue.barrier()
Enqueues a barrier operation. The queue.barrier command ensures that all queued commands in command_queue have finished execution before the next batch of commands can begin execution. The queue.barrier command is a synchronization point
Return the context that this queue was created with
Return the device associated with this queue
queue.enqueue_native_kernel(function [, arg, ..., kwarg=, ...])
Enqueues a command to execute a python function.
Parameters: |
|
---|
queue.enqueue_nd_range_kernel(kernel, work_dim, global_work_size, global_work_offset=None, local_work_size=None, wait_on=())
Enqueues a command to execute a kernel on a device
Parameters: |
|
---|
Parameters: | wait_on – A list of events |
---|
queue.enqueue_task(kernel, wait_on=())
Enqueues a command to execute a kernel on a device. The kernel is executed using a single work-item.
Parameters: |
|
---|
queue.enqueue_wait_for_events(self, event, event2, ...) queue.enqueue_wait_for_events(self, eventlist)
Enqueues a wait for a specific event or a list of events to complete before any future commands queued in the command-queue are executed. num_events specifies the number of events given by event_list.
queue.finish()
Blocks until all previously queued OpenCL commands in command_queue are issued to the associated device and have completed. clFinish does not return until all queued commands in command_queue have been processed and completed. clFinish is also a synchronization point
queue.flush()
Issues all previously queued OpenCL commands in command_queue to the device associated with command_queue. clFlush only guarantees that all queued commands to command_queue will eventually be submitted to the appropriate device. There is no guarantee that they will be complete after clFlush returns.
queue.marker()
Enqueues a marker command to command_queue. The marker command is not completed until all commands enqueued before it have completed. The marker command returns an event which can be waited on, i.e. this event can be waited on to insure that all commands, which have been queued before the marker command, have been completed.