gpuip::ImageProcessor Class Reference

Public Types

typedef std::tr1::shared_ptr
< ImageProcessor
Ptr
 Smart pointer.

Public Member Functions

GpuEnvironment Environment () const
 Returns the current GpuEnvironment.
void SetDimensions (unsigned int width, unsigned int height)
 Set the dimensions of algorithms. Must be set explicitly.
unsigned int Width () const
 Returns the images width in number of pixels.
unsigned int Height () const
 Returns the images height in number of pixels.
Buffer::Ptr CreateBuffer (const std::string &name, Buffer::Type type, unsigned int channels)
 Creates a Buffer object with allocation info.
Kernel::Ptr CreateKernel (const std::string &name)
 Creates and registeres a Kernel object.
virtual double Allocate (std::string *error)
 Allocates needed memory on the GPU.
virtual double Build (std::string *error)
 Compiles the Kernel::Code for each Kernel object.
virtual double Run (std::string *error)
 Runs all of the image processing kernels.
virtual double Copy (Buffer::Ptr buffer, Buffer::CopyOperation operation, void *data, std::string *error)
 Data tranfser from the CPU and the GPU.
virtual std::string BoilerplateCode (Kernel::Ptr kernel) const
 Returns a boilerplate code for a given kernel.

Static Public Member Functions

static ImageProcessor::Ptr Create (GpuEnvironment env)
 Factory function to create an ImageProcessor entity.
static bool CanCreate (GpuEnvironment env)
 Check if gpuip was compiled with a GpuEnvironment.

Protected Member Functions

 ImageProcessor (GpuEnvironment env)
unsigned int _BufferSize (Buffer::Ptr buffer) const

Protected Attributes

const GpuEnvironment _env
unsigned int _w
unsigned int _h
std::map< std::string,
Buffer::Ptr
_buffers
std::vector< Kernel::Ptr_kernels

Member Function Documentation

virtual double gpuip::ImageProcessor::Allocate ( std::string *  error  )  [virtual]

Allocates needed memory on the GPU.

Parameters:
error if function fails, the explaining error string is stored here
Returns:
execution time in milliseconds. GPUIP_ERROR on failure

Call this function once all buffers have been created. Once things have been allocated on the GPU, ImageProcessor::Copy can be called. This function can be called multiple times since it starts with resetting previous allocated memory.

virtual std::string gpuip::ImageProcessor::BoilerplateCode ( Kernel::Ptr  kernel  )  const [virtual]

Returns a boilerplate code for a given kernel.

Parameters:
kernel Kernel to be processed
Returns:
boilerplate code

Processes the kernel and the buffers to produce boilerplate code. Boilerplate code is often a good starting step when writing gpu kernels since they remove some of the redundent code that is shared between all kernels. It also guarantees that the argument list is correct.

virtual double gpuip::ImageProcessor::Build ( std::string *  error  )  [virtual]

Compiles the Kernel::Code for each Kernel object.

Parameters:
error if function fails, the explaining error string is stored here
Returns:
execution time in milliseconds. GPUIP_ERROR on failure

Call this function once the Kernel::code has been set for all kernels. Can be called multiple times to rebuild the kernels.

virtual double gpuip::ImageProcessor::Copy ( Buffer::Ptr  buffer,
Buffer::CopyOperation  operation,
void *  data,
std::string *  error 
) [virtual]

Data tranfser from the CPU and the GPU.

Parameters:
buffer buffer on the gpu to copy to/from
operation decides if the copy is from the gpu or to the gpu
data points to allocated memory on the CPU
error if function fails, the explaining error string is stored here
Returns:
execution time in milliseconds. GPUIP_ERROR on failure

Copies data between the CPU and the GPU. User must guarantee that data is pointing to a memory space on the CPU with enough allocated memory. ImageProcessor::Allocate must be called at least once before this function.

Buffer::Ptr gpuip::ImageProcessor::CreateBuffer ( const std::string &  name,
Buffer::Type  type,
unsigned int  channels 
)

Creates a Buffer object with allocation info.

Parameters:
name Unique identifying name of buffer
type per channel data type
channels number of channels of data per pixel
Returns:
A smart pointer to new registered Buffer object

This is the only way a buffer can be registered to an ImageProcessor. Modifications can be made to the Buffer object as long as they are made before the ImageProcessor::Allocate call.

Kernel::Ptr gpuip::ImageProcessor::CreateKernel ( const std::string &  name  ) 

Creates and registeres a Kernel object.

Parameters:
name Unique identifying name of the kernel
Returns:
A smart pointer to new registered Kernel object

This is the only way a kernel can be registered to an ImageProcessor. Kernels will be run in the order they are created. Modifications can be made to the Kernel object as long as Kernel::code is set before the ImageProcessor::Build call and Kernel::inBuffers, Kernel::outBuffers, Kernel::paramsInt, Kernel::paramsFloat are set before the ImageProcessor::Run call.

virtual double gpuip::ImageProcessor::Run ( std::string *  error  )  [virtual]

Runs all of the image processing kernels.

Parameters:
error if function fails, the explaining error string is stored here
Returns:
execution time in milliseconds. GPUIP_ERROR on failure

Runs all the image processing kernels in the order they were created. ImageProcessor::Build and ImageProcessor::Allocate must have called before this function.


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

Generated on 21 Aug 2014 for gpuip by  doxygen 1.6.1