Ufo.Buffer¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Ufo.Buffer(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Represents n-dimensional data. The contents of the
Ufo.Buffer
structure are private and should only be accessed via the provided API.- classmethod new(requisition, context)¶
- Parameters:
requisition (
Ufo.Requisition
) – size requisitioncontext (
object
orNone
) – cl_context to use for creating the device array
- Returns:
A new
Ufo.Buffer
with the given dimensions.- Return type:
Create a new
Ufo.Buffer
.
- classmethod new_with_data(requisition, data, context)¶
- Parameters:
requisition (
Ufo.Requisition
) – size requisitiondata (
object
orNone
) – Pointer to host memory that will be used by
- Return type:
Create a new buffer using existing host memory.
- classmethod new_with_size(dims, context)¶
- Parameters:
- Returns:
A new
Ufo.Buffer
with the given dimensions.- Return type:
Create a new
Ufo.Buffer
with a list of dimensions.
- cmp_dimensions(requisition)¶
- Parameters:
requisition (
Ufo.Requisition
) –Ufo.Requisition
- Returns:
value < 0, 0 or > 0 if requisition is smaller, equal or larger.
- Return type:
Compare the size of self with a given requisition.
- convert(depth)¶
- Parameters:
depth (
Ufo.BufferDepth
) – Source bit depth of host data
Convert host data according to its depth to the internal 32-bit floating point representation.
- convert_from_data(data, depth)¶
- Parameters:
data (
object
orNone
) – Pointer to data that should be converteddepth (
Ufo.BufferDepth
) – Source bit depth of host data
Convert data according from depth to the internal 32-bit floating point representation.
Note: data must provide as many bytes as the buffer was initialized with.
- copy(dst)¶
- Parameters:
dst (
Ufo.Buffer
) – DestinationUfo.Buffer
Copy contents of self to dst. The final memory location is determined by the destination buffer.
- copy_host_array(array)¶
- Parameters:
array (
int
) – A pointer to a float array with suitable size.
Copy data into the buffer.
- copy_metadata(dst)¶
- Parameters:
dst (
Ufo.Buffer
) – Destination buffer
Copies meta data content from self to dst.
- discard_location()¶
Discard the current and use the last location without copying to it first.
- dup()¶
- Returns:
A
Ufo.Buffer
with the same size as self.- Return type:
Create a new buffer with the same requisition as self. Note, that this is not a copy of self!
- get_device_array(cmd_queue)¶
- Parameters:
cmd_queue (
object
orNone
) – A cl_command_queue object orNone
.- Returns:
A cl_mem object associated with self.
- Return type:
Return the current cl_mem object of self. If the data is not yet in device memory, it is transfered via cmd_queue to the object. If cmd_queue is
None
cmd_queue, the last used command queue is used.
- get_device_array_view(cmd_queue, region)¶
- Parameters:
region (
Ufo.Region
) – AUfo.Region
specifying the view of the sub buffer
- Returns:
A newly allocated cl_mem that the user must release himself with clReleaseMemObject().
- Return type:
This method creates a new memory buffer that must be freed by the user. Moreover, the original self is kept intact.
- get_device_array_with_offset(cmd_queue, offset)¶
- Parameters:
- Returns:
A cl_mem sub buffer of the original data.
- Return type:
Creates a new cl_mem object with the given offset and a size that is the original size minus the offset.
- get_device_image(cmd_queue)¶
- Parameters:
cmd_queue (
object
orNone
) – A cl_command_queue object orNone
.- Returns:
A cl_mem image object associated with self.
- Return type:
Return the current cl_mem image object of self. If the data is not yet in device memory, it is transfered via cmd_queue to the object. If cmd_queue is
None
cmd_queue, the last used command queue is used.
- get_host_array(cmd_queue)¶
- Parameters:
cmd_queue (
object
orNone
) – A cl_command_queue object orNone
.- Returns:
Float array.
- Return type:
Returns a flat C-array containing the raw float data.
- get_layout()¶
- Return type:
Return current layout of self.
- get_location()¶
- Return type:
Return current location of data backed by self.
- get_metadata(name)¶
- Parameters:
name (
str
) – Name of the associated meta data- Returns:
previously defined metadata
GObject.Value
for this buffer.- Return type:
Retrieve meta data.
- get_metadata_keys()¶
- Returns:
A
GLib.List
with C strings. The content of the list owned by the buffer and should not be modified or freed. Use #g_list_free() when done using the list.- Return type:
[
str
]
Get all meta data keys associated with self.
- get_requisition()¶
- Returns:
A location to store the requisition of self
- Return type:
requisition:
Ufo.Requisition
Return the size of self.
- get_size()¶
- Returns:
The size of self's data.
- Return type:
Get the number of bytes of raw data that is managed by the self.
- max(cmd_queue)¶
- Parameters:
cmd_queue (
object
orNone
) – An OpenCL command queue orNone
- Returns:
The maximum found.
- Return type:
Return the maximum value of self.
- min(cmd_queue)¶
- Parameters:
cmd_queue (
object
orNone
) – An OpenCL command queue orNone
- Returns:
The minimum found.
- Return type:
Return the minimum value of self.
- resize(requisition)¶
- Parameters:
requisition (
Ufo.Requisition
) – AUfo.Requisition
structure
Resize an existing buffer. If the new requisition has the same size as before, resizing is a no-op.
New in version 0.2.
- set_device_array(array, free_data)¶
- Parameters:
Set the current cl_mem object.
- set_host_array(array, free_data)¶
- Parameters:
Use this function to set a host array with a user-provided memory buffer. This is useful to expose private data of a generator filter to a subsequent consumer. Note, that the buffer *must* have an appropriate size.
- set_layout(layout)¶
- Parameters:
layout (
Ufo.BufferLayout
) – Layout of the currently residing data
Set layout of the buffer.
- set_metadata(name, value)¶
- Parameters:
name (
str
) – Name of the associated meta datavalue (
GObject.Value
) –GObject.Value
of the meta data
Associates a key-value pair with self.
- swap_data(dst)¶
- Parameters:
dst (
Ufo.Buffer
) – Buffer to receive data from self
Swap the *content* of the two buffers if possible (i.e. data resides on the same memory type) or copy from self to dst otherwise.
New in version 0.16.