GoclBuffer

GoclBuffer — Object that represents a block of memory in an OpenCL context

Stability Level

Unstable, unless otherwise indicated

Synopsis

struct              GoclBuffer;
struct              GoclBufferClass;
cl_mem              gocl_buffer_get_buffer              (GoclBuffer *self);
gboolean            gocl_buffer_read_sync               (GoclBuffer *self,
                                                         GoclQueue *queue,
                                                         gpointer target_ptr,
                                                         gsize size,
                                                         goffset offset,
                                                         GList *event_wait_list,
                                                         GError **error);
gboolean            gocl_buffer_write_sync              (GoclBuffer *self,
                                                         GoclQueue *queue,
                                                         const gpointer data,
                                                         gsize size,
                                                         goffset offset,
                                                         GList *event_wait_list,
                                                         GError **error);

Object Hierarchy

  GObject
   +----GoclBuffer

Implemented Interfaces

GoclBuffer implements GInitable.

Properties

  "context"                  GoclContext*          : Read / Write / Construct Only
  "flags"                    guint                 : Read / Write / Construct Only
  "size"                     guint64               : Read / Write / Construct Only

Description

A GoclBuffer represents a buffer object in an OpenCL context. These objects are directly accessible from OpenCL programs.

Buffers are created from a GoclContext, by calling gocl_context_create_buffer() method. It is possible to initialize the contents of the buffer upon creating, by specifying a block of host memory to copy data from, and the appropriate flag from GoclBufferFlags. Also, buffers can be initialized at any time by calling gocl_buffer_write_sync().

To read data from a buffer into host memory, gocl_buffer_read_sync() method is provided. This is normally used after the execution of a kernel that affected the contents of the buffer.

Both gocl_buffer_write_sync() and gocl_buffer_read_sync() are block program execution. Asynchronous function will shortly be provided as well.

Details

struct GoclBuffer

struct GoclBuffer;


struct GoclBufferClass

struct GoclBufferClass {
  GObjectClass parent_class;
};

The class for GoclBuffer objects.

GObjectClass parent_class;

The parent class

gocl_buffer_get_buffer ()

cl_mem              gocl_buffer_get_buffer              (GoclBuffer *self);

Retrieves the internal OpenCL cl_mem object. This is not normally called by applications. It is rather a low-level, internal API.

self :

The GoclBuffer

Returns :

The internal cl_mem object. [type guint64][transfer none]

gocl_buffer_read_sync ()

gboolean            gocl_buffer_read_sync               (GoclBuffer *self,
                                                         GoclQueue *queue,
                                                         gpointer target_ptr,
                                                         gsize size,
                                                         goffset offset,
                                                         GList *event_wait_list,
                                                         GError **error);

Reads a block of data of size bytes from remote context into host memory, starting at offset. The operation is actually enqueued in queue, and the program execution blocks until the read finishes. If event_wait_list is provided, the read operation will start only when all the GoclEvent in the list have triggered.

self :

The GoclBuffer

queue :

A GoclQueue where the operation will be enqueued

target_ptr :

The pointer to copy the data to. [array length=size][element-type guint8]

size :

The size of the data to be read

offset :

The offset to start reading from

event_wait_list :

List or GoclEvent object to wait for, or NULL. [element-type Gocl.Event][allow-none]

error :

A pointer to a GError, or NULL. [out][allow-none]

Returns :

TRUE on success, FALSE on error

gocl_buffer_write_sync ()

gboolean            gocl_buffer_write_sync              (GoclBuffer *self,
                                                         GoclQueue *queue,
                                                         const gpointer data,
                                                         gsize size,
                                                         goffset offset,
                                                         GList *event_wait_list,
                                                         GError **error);

Writes a block of data of size bytes from host memory into remote context memory, starting at offset. The operation is actually enqueued in queue, and the program execution blocks until the read finishes. If event_wait_list is provided, the read operation will start only when all the GoclEvent in the list have triggered.

self :

The GoclBuffer

queue :

A GoclQueue where the operation will be enqueued

data :

A pointer to write data from

size :

The size of the data to be written

offset :

The offset to start writing data to

event_wait_list :

List or GoclEvent object to wait for, or NULL. [element-type Gocl.Event][allow-none]

error :

A pointer to a GError, or NULL. [out][allow-none]

Returns :

TRUE on success, FALSE on error

Property Details

The "context" property

  "context"                  GoclContext*          : Read / Write / Construct Only

The context where this buffer was created.


The "flags" property

  "flags"                    guint                 : Read / Write / Construct Only

The flags used when creating this buffer.

Allowed values: [1,32]

Default value: 1


The "size" property

  "size"                     guint64               : Read / Write / Construct Only

The size of this buffer.

Default value: 0