Clover Git
OpenCL 1.1 software implementation
Namespaces | Functions

builtins.h File Reference

CPU built-in functions. More...

#include <string>
Include dependency graph for builtins.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  Coal

Functions

void setThreadLocalWorkGroup (Coal::CPUKernelWorkGroup *current)
 Set the current kernel work-group of this thread.
void * getBuiltin (const std::string &name)
 Return the address of a built-in function given its name.
void * getWorkItemsData (size_t &size)
 Work-item stacks.
void setWorkItemsData (void *ptr, size_t size)
 Set work-item stacks.
template<typename T >
bool incVec (unsigned long dims, T *vec, T *maxs)
 Increment a n-component vector given a maximum value.
unsigned char * imageData (unsigned char *base, size_t x, size_t y, size_t z, size_t row_pitch, size_t slice_pitch, unsigned int bytes_per_pixel)
 Address of a pixel in an image.

Detailed Description

CPU built-in functions.

Definition in file builtins.h.


Function Documentation

void* getBuiltin ( const std::string &  name)
void* getWorkItemsData ( size_t &  size)

Work-item stacks.

See also:
Implementing barriers
Parameters:
sizesize of the allocated space for stacks
Returns:
address of the allocated space for stacks

Definition at line 82 of file builtins.cpp.

References work_items_data, and work_items_size.

Referenced by Coal::CPUKernelWorkGroup::barrier(), and worker().

unsigned char* imageData ( unsigned char *  base,
size_t  x,
size_t  y,
size_t  z,
size_t  row_pitch,
size_t  slice_pitch,
unsigned int  bytes_per_pixel 
)

Address of a pixel in an image.

This function is heavily used when Clover needs to address a pixel or a byte in a rectangular or three-dimensional image or buffer.

Parameters:
baseaddress of the first pixel in the image (address of the image itself)
xX coordinate, cannot be bigger or equal to width
yY coordinate, cannot be bigger or equal to height
zZ coordinate, cannot be bigger or equal to depth (1 for 2D arrays)
row_pitchsize in bytes of a row of pixels in the image
slice_pitchsize in bytes of a slice in a 3D array
bytes_per_pixelbytes per pixel (1 for simple buffers), used when coordinates are in pixels and not in bytes.

Definition at line 57 of file builtins.cpp.

Referenced by Coal::CPUKernelWorkGroup::getImageData(), Coal::CPUDevice::initEventDeviceData(), and worker().

template<typename T >
bool incVec ( unsigned long  dims,
T *  vec,
T *  maxs 
)

Increment a n-component vector given a maximum value.

This function is used to increment a vector for which a set of maximum values each of its element can reach before the next is incremented.

For example, if dims is 3, vec starts at {0, 0, 0} and maxs if {2, 3, 1}, repeatedly calling this function with the same vector will produce the following results :

 {0, 0, 1}
 {0, 1, 0}
 {0, 1, 1}
 {0, 2, 0}
 {0, 2, 1}
 {0, 3, 0}
 {0, 3, 1}
 {1, 0, 0}
 ...

Until vec reaches {2, 3, 1}.

Parameters:
dimsnumber of elements in the vectors
vecvector whose elements will be incremented
maxsvector containing a maximum value above which each corresponding element of vec cannot go.
Returns:
false if the increment was ok, true if vec was already at it's maximum value and couldn't be further incremented.

Definition at line 101 of file builtins.h.

Referenced by Coal::CPUKernelWorkGroup::barrier(), Coal::CPUKernelWorkGroup::run(), and Coal::CPUKernelEvent::takeInstance().

void setThreadLocalWorkGroup ( Coal::CPUKernelWorkGroup current)

Set the current kernel work-group of this thread.

Parameters:
currentCoal::CPUKernelWorkGroup to be set in g_work_group.

Definition at line 77 of file builtins.cpp.

References g_work_group.

Referenced by Coal::CPUKernelWorkGroup::run().

void setWorkItemsData ( void *  ptr,
size_t  size 
)

Set work-item stacks.

See also:
Implementing barriers
Parameters:
ptraddress of allocated space for stacks
sizesize of the allocated space for stacks

Definition at line 88 of file builtins.cpp.

References work_items_data, and work_items_size.

Referenced by Coal::CPUKernelWorkGroup::barrier(), and worker().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines