Gocl - Documentation and Reference Manual | ||||
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces | Properties |
struct GoclContext; struct GoclContextClass; GoclContext * gocl_buffer_get_context (GoclBuffer *buffer
); GoclBuffer * gocl_context_create_buffer (GoclContext *self
,guint flags
,gsize size
,gpointer host_ptr
,GError **error
); cl_context gocl_context_get_context (GoclContext *self
); GoclContext * gocl_context_get_default_cpu (GError **error
); GoclContext * gocl_context_get_default_gpu (GError **error
); GoclDevice * gocl_context_get_device_by_index (GoclContext *self
,guint device_index
); guint gocl_context_get_num_devices (GoclContext *self
); GoclContext * gocl_context_new (GoclDeviceType device_type
,GError **error
); GoclContext * gocl_device_get_context (GoclDevice *device
);
A GoclContext enables access to OpenCL objects such as devices, command queues, buffers, programs, kernels, etc. Obtaining a GoclContext is always the first step an OpenCL application performs.
A GoclContext can be created with gocl_context_new()
, providing the type of
device which is a value from GoclDeviceType. For convenience, the methods
gocl_context_get_default_cpu()
and gocl_context_get_default_gpu()
are
provided to easily retrieve pre-created CPU and GPU contexts, respectively.
Once a context is successfully created, devices can be obtained by calling
gocl_context_get_device_by_index()
, where index must be a value between 0 and
the maximum number of devices in the context, minus one. Number of devices can
be obtained with gocl_context_get_num_devices()
.
Memory buffers can be created in context's memory to that kernels can access
and share them during execution. To create a buffer,
gocl_context_create_buffer()
method is provided.
struct GoclContextClass { GObjectClass parent_class; };
The class for GoclContext objects.
GObjectClass |
The parent class |
GoclContext * gocl_buffer_get_context (GoclBuffer *buffer
);
Retrieves the GoclContext the buffer belongs to.
|
The GoclBuffer |
Returns : |
A GoclContext object. [transfer none] |
GoclBuffer * gocl_context_create_buffer (GoclContext *self
,guint flags
,gsize size
,gpointer host_ptr
,GError **error
);
Creates a new buffer on context's memory. Depending on flags, the host_ptr
pointer can be
used to initialize the contents of the buffer from a block of memory in the host.
|
The GoclContext |
|
An OR'ed combination of values from GoclBufferFlags |
|
The size of the buffer, in bytes |
|
A pointer to memory in the host system, or NULL . [allow-none][type guint64]
|
|
A pointer to a GError, or NULL . [out][allow-none]
|
Returns : |
A newly created GoclBuffer, or NULL on error. [transfer full]
|
cl_context gocl_context_get_context (GoclContext *self
);
Retrieves the internal OpenCL cl_context object. This is not normally called by applications. It is rather a low-level, internal API.
|
The GoclContext |
Returns : |
The internal cl_context object. [transfer none][type guint] |
GoclContext * gocl_context_get_default_cpu (GError **error
);
Returns platform's default CPU context. The first call to this method will
attempt to create a new GoclContext using a device type of
GOCL_DEVICE_TYPE_CPU
. Upon success, the context is cached and subsequent calls
will return the same object, increasing its reference count.
|
A pointer to a GError, or NULL . [out][allow-none]
|
Returns : |
A GoclContext object, or NULL on error. [transfer full]
|
GoclContext * gocl_context_get_default_gpu (GError **error
);
Returns platform's default GPU context. The first call to this method will
attempt to create a new GoclContext using a device type of
GOCL_DEVICE_TYPE_GPU
. Upon success, the context is cached and subsequent calls
will return the same object, increasing its reference count.
|
A pointer to a GError, or NULL . [out][allow-none]
|
Returns : |
A GoclContext object, or NULL on error. [transfer full]
|
GoclDevice * gocl_context_get_device_by_index (GoclContext *self
,guint device_index
);
Retrieves the device_index
-th device from the list of context devices.
Use gocl_context_get_num_devices()
to get the number of devices in the
context.
Notice that method creates a new GoclDevice instance every time is called.
|
The GoclContext |
|
The index of the device to retrieve |
Returns : |
A newly created GoclDevice. [transfer full] |
guint gocl_context_get_num_devices (GoclContext *self
);
Obtains the number of devices in this context. Calls to
gocl_context_get_device_by_index()
must provide a device index between
0 and the number of devices returned by this method, minus one.
|
The GoclContext |
Returns : |
The number of devices |
GoclContext * gocl_context_new (GoclDeviceType device_type
,GError **error
);
Attempts to create a GoclContext of the type specified in device_type
.
Upon error, NULL
is returned and error
is filled accordingly. On success,
a new GoclContext object is returned.
|
A value from GoclDeviceType |
|
A pointer to a GError, or NULL . [out][allow-none]
|
Returns : |
A newly created GoclContext. [transfer full] |
GoclContext * gocl_device_get_context (GoclDevice *device
);
Obtains the GoclContext the device belongs to.
|
The GoclDevice |
Returns : |
A GoclContext. The returned object is owned by the device, do not free. [transfer none] |
"device-type"
property"device-type" guint : Read / Write / Construct Only
The device type for this context.
Allowed values: >= 1
Default value: 1