Clover Git
OpenCL 1.1 software implementation
Public Member Functions | Private Attributes

Coal::CPUBuffer Class Reference

CPU implementation of Coal::MemObject. More...

#include <buffer.h>

Inheritance diagram for Coal::CPUBuffer:
Collaboration diagram for Coal::CPUBuffer:

List of all members.

Public Member Functions

 CPUBuffer (CPUDevice *device, MemObject *buffer, cl_int *rs)
 Constructor.
 ~CPUBuffer ()
bool allocate ()
 Allocate the buffer on the device.
DeviceInterfacedevice () const
 Coal::DeviceInterface of this buffer
void * data () const
 Pointer to the buffer's data.
void * nativeGlobalPointer () const
 Host-accessible memory pointer.
bool allocated () const
 Allocation status.

Private Attributes

CPUDevicep_device
MemObjectp_buffer
void * p_data
bool p_data_malloced

Detailed Description

CPU implementation of Coal::MemObject.

This class is responsible of the actual allocation of buffer objects, using malloc() or by reusing a given host_ptr.

Definition at line 50 of file buffer.h.


Constructor & Destructor Documentation

CPUBuffer::CPUBuffer ( CPUDevice device,
MemObject buffer,
cl_int *  rs 
)

Constructor.

Parameters:
deviceDevice for which the buffer is allocated
bufferCoal::MemObject holding information about the buffer
rsreturn code (CL_SUCCESS if all is good)

Definition at line 44 of file buffer.cpp.

References data(), Coal::MemObject::deviceBuffer(), Coal::MemObject::flags(), Coal::MemObject::host_ptr(), Coal::SubBuffer::offset(), p_data, Coal::SubBuffer::parent(), Coal::MemObject::SubBuffer, and Coal::MemObject::type().

CPUBuffer::~CPUBuffer ( )

Definition at line 71 of file buffer.cpp.

References p_data, and p_data_malloced.


Member Function Documentation

bool CPUBuffer::allocate ( ) [virtual]

Allocate the buffer on the device.

Returns:
true when success, false otherwise

Implements Coal::DeviceBuffer.

Definition at line 89 of file buffer.cpp.

References Coal::MemObject::deviceAllocated(), Coal::MemObject::flags(), Coal::MemObject::host_ptr(), p_buffer, p_data, p_data_malloced, Coal::MemObject::size(), Coal::MemObject::SubBuffer, and Coal::MemObject::type().

bool CPUBuffer::allocated ( ) const [virtual]

Allocation status.

Returns:
true if already allocated, false otherwise

Implements Coal::DeviceBuffer.

Definition at line 125 of file buffer.cpp.

References p_data.

void * CPUBuffer::data ( ) const
DeviceInterface * CPUBuffer::device ( ) const [virtual]

Coal::DeviceInterface of this buffer

Returns:
parent Coal::DeviceInterface

Implements Coal::DeviceBuffer.

Definition at line 120 of file buffer.cpp.

References p_device.

void * CPUBuffer::nativeGlobalPointer ( ) const [virtual]

Host-accessible memory pointer.

This function returns what is passed as arguments to native kernels (clEnqueueNativeKernel(), Coal::NativeKernelEvent) in place of Coal::MemObject pointers.

For Coal::CPUDevice, it's simply a pointer in RAM, but hardware-accelerated devices may need to do some copying or mapping.

Warning:
Beware that this data may get written to by the native kernel.
Returns:
A memory pointer usable by a host native kernel

Implements Coal::DeviceBuffer.

Definition at line 84 of file buffer.cpp.

References data().


Member Data Documentation

Definition at line 70 of file buffer.h.

Referenced by allocate().

void* Coal::CPUBuffer::p_data [private]

Definition at line 71 of file buffer.h.

Referenced by allocate(), allocated(), CPUBuffer(), data(), and ~CPUBuffer().

Definition at line 72 of file buffer.h.

Referenced by allocate(), and ~CPUBuffer().

Definition at line 69 of file buffer.h.

Referenced by device().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines