Clover Git
OpenCL 1.1 software implementation
Functions | Variables

builtins.cpp File Reference

Native OpenCL C built-in functions. More...

#include "builtins.h"
#include "kernel.h"
#include "buffer.h"
#include "../events.h"
#include "../memobject.h"
#include <sys/mman.h>
#include <signal.h>
#include <llvm/Function.h>
#include <iostream>
#include <cstring>
#include <stdio.h>
Include dependency graph for builtins.cpp:

Go to the source code of this file.

Functions

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.
void setThreadLocalWorkGroup (Coal::CPUKernelWorkGroup *current)
 Set the current kernel work-group of this thread.
void * getWorkItemsData (size_t &size)
 Work-item stacks.
void setWorkItemsData (void *ptr, size_t size)
 Set work-item stacks.
static size_t get_global_id (cl_uint dimindx)
static cl_uint get_work_dim ()
static size_t get_global_size (uint dimindx)
static size_t get_local_size (uint dimindx)
static size_t get_local_id (uint dimindx)
static size_t get_num_groups (uint dimindx)
static size_t get_group_id (uint dimindx)
static size_t get_global_offset (uint dimindx)
static void barrier (unsigned int flags)
static int get_image_width (Image2D *image)
static int get_image_height (Image2D *image)
static int get_image_depth (Image3D *image)
static int get_image_channel_data_type (Image2D *image)
static int get_image_channel_order (Image2D *image)
static void * image_data (Image2D *image, int x, int y, int z, int *order, int *type)
static bool is_image_3d (Image3D *image)
static void write_imagef (Image2D *image, int x, int y, int z, float *color)
static void write_imagei (Image2D *image, int x, int y, int z, int32_t *color)
static void write_imageui (Image2D *image, int x, int y, int z, uint32_t *color)
static void read_imagefi (float *result, Image2D *image, int x, int y, int z, int32_t sampler)
static void read_imageii (int32_t *result, Image2D *image, int x, int y, int z, int32_t sampler)
static void read_imageuii (uint32_t *result, Image2D *image, int x, int y, int z, int32_t sampler)
static void read_imageff (float *result, Image2D *image, float x, float y, float z, int32_t sampler)
static void read_imageif (int32_t *result, Image2D *image, float x, float y, float z, int32_t sampler)
static void read_imageuif (uint32_t *result, Image2D *image, float x, float y, float z, int32_t sampler)
static void unimplemented_stub ()
void * getBuiltin (const std::string &name)
 Return the address of a built-in function given its name.

Variables

__thread Coal::CPUKernelWorkGroupg_work_group
 Coal::CPUKernelWorkGroup currently running on this thread
__thread void * work_items_data
 Space allocated for work-items stacks, see Implementing barriers.
__thread size_t work_items_size
 Size of work_items_data, see Implementing barriers.

Detailed Description

Native OpenCL C built-in functions.

All these built-ins are directly called by kernels. When the LLVM JIT sees a function name it doesn't know, it calls getBuiltin() with this name as parameter. This function then returns the address of an actual function implementation, that finally gets called by the kernel when it is run.

Definition in file builtins.cpp.


Function Documentation

static void barrier ( unsigned int  flags) [static]

Definition at line 299 of file builtins.cpp.

References Coal::CPUKernelWorkGroup::barrier(), and g_work_group.

Referenced by getBuiltin().

static size_t get_global_id ( cl_uint  dimindx) [static]

Definition at line 259 of file builtins.cpp.

References g_work_group, and Coal::CPUKernelWorkGroup::getGlobalId().

Referenced by getBuiltin().

static size_t get_global_offset ( uint  dimindx) [static]

Definition at line 294 of file builtins.cpp.

References g_work_group, and Coal::CPUKernelWorkGroup::getGlobalOffset().

Referenced by getBuiltin().

static size_t get_global_size ( uint  dimindx) [static]

Definition at line 269 of file builtins.cpp.

References g_work_group, and Coal::CPUKernelWorkGroup::getGlobalSize().

Referenced by getBuiltin().

static size_t get_group_id ( uint  dimindx) [static]

Definition at line 289 of file builtins.cpp.

References g_work_group, and Coal::CPUKernelWorkGroup::getGroupID().

Referenced by getBuiltin().

static int get_image_channel_data_type ( Image2D image) [static]

Definition at line 324 of file builtins.cpp.

References Coal::Image2D::format().

Referenced by getBuiltin().

static int get_image_channel_order ( Image2D image) [static]

Definition at line 329 of file builtins.cpp.

References Coal::Image2D::format().

Referenced by getBuiltin().

static int get_image_depth ( Image3D image) [static]

Definition at line 316 of file builtins.cpp.

References Coal::Image3D::depth(), Coal::MemObject::Image3D, and Coal::Image3D::type().

Referenced by getBuiltin().

static int get_image_height ( Image2D image) [static]

Definition at line 311 of file builtins.cpp.

References Coal::Image2D::height().

Referenced by getBuiltin().

static int get_image_width ( Image2D image) [static]

Definition at line 306 of file builtins.cpp.

References Coal::Image2D::width().

Referenced by getBuiltin().

static size_t get_local_id ( uint  dimindx) [static]

Definition at line 279 of file builtins.cpp.

References g_work_group, and Coal::CPUKernelWorkGroup::getLocalID().

Referenced by getBuiltin().

static size_t get_local_size ( uint  dimindx) [static]

Definition at line 274 of file builtins.cpp.

References g_work_group, and Coal::CPUKernelWorkGroup::getLocalSize().

Referenced by getBuiltin().

static size_t get_num_groups ( uint  dimindx) [static]

Definition at line 284 of file builtins.cpp.

References g_work_group, and Coal::CPUKernelWorkGroup::getNumGroups().

Referenced by getBuiltin().

static cl_uint get_work_dim ( ) [static]

Definition at line 264 of file builtins.cpp.

References g_work_group, and Coal::CPUKernelWorkGroup::getWorkDim().

Referenced by getBuiltin().

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().

static void* image_data ( Image2D image,
int  x,
int  y,
int  z,
int *  order,
int *  type 
) [static]

Definition at line 334 of file builtins.cpp.

References Coal::Image2D::format(), g_work_group, and Coal::CPUKernelWorkGroup::getImageData().

Referenced by getBuiltin().

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().

static bool is_image_3d ( Image3D image) [static]

Definition at line 342 of file builtins.cpp.

References Coal::MemObject::Image3D, and Coal::Image3D::type().

Referenced by getBuiltin().

static void read_imageff ( float *  result,
Image2D image,
float  x,
float  y,
float  z,
int32_t  sampler 
) [static]

Definition at line 380 of file builtins.cpp.

References g_work_group, and Coal::CPUKernelWorkGroup::readImage().

Referenced by getBuiltin().

static void read_imagefi ( float *  result,
Image2D image,
int  x,
int  y,
int  z,
int32_t  sampler 
) [static]

Definition at line 362 of file builtins.cpp.

References g_work_group, and Coal::CPUKernelWorkGroup::readImage().

Referenced by getBuiltin().

static void read_imageif ( int32_t *  result,
Image2D image,
float  x,
float  y,
float  z,
int32_t  sampler 
) [static]

Definition at line 386 of file builtins.cpp.

References g_work_group, and Coal::CPUKernelWorkGroup::readImage().

Referenced by getBuiltin().

static void read_imageii ( int32_t *  result,
Image2D image,
int  x,
int  y,
int  z,
int32_t  sampler 
) [static]

Definition at line 368 of file builtins.cpp.

References g_work_group, and Coal::CPUKernelWorkGroup::readImage().

Referenced by getBuiltin().

static void read_imageuif ( uint32_t *  result,
Image2D image,
float  x,
float  y,
float  z,
int32_t  sampler 
) [static]

Definition at line 392 of file builtins.cpp.

References g_work_group, and Coal::CPUKernelWorkGroup::readImage().

Referenced by getBuiltin().

static void read_imageuii ( uint32_t *  result,
Image2D image,
int  x,
int  y,
int  z,
int32_t  sampler 
) [static]

Definition at line 374 of file builtins.cpp.

References g_work_group, and Coal::CPUKernelWorkGroup::readImage().

Referenced by getBuiltin().

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().

static void unimplemented_stub ( ) [static]

Definition at line 401 of file builtins.cpp.

Referenced by getBuiltin().

static void write_imagef ( Image2D image,
int  x,
int  y,
int  z,
float *  color 
) [static]

Definition at line 347 of file builtins.cpp.

References g_work_group, and Coal::CPUKernelWorkGroup::writeImage().

Referenced by getBuiltin().

static void write_imagei ( Image2D image,
int  x,
int  y,
int  z,
int32_t *  color 
) [static]

Definition at line 352 of file builtins.cpp.

References g_work_group, and Coal::CPUKernelWorkGroup::writeImage().

Referenced by getBuiltin().

static void write_imageui ( Image2D image,
int  x,
int  y,
int  z,
uint32_t *  color 
) [static]

Definition at line 357 of file builtins.cpp.

References g_work_group, and Coal::CPUKernelWorkGroup::writeImage().

Referenced by getBuiltin().


Variable Documentation

__thread void* work_items_data

Space allocated for work-items stacks, see Implementing barriers.

Definition at line 74 of file builtins.cpp.

Referenced by getWorkItemsData(), and setWorkItemsData().

__thread size_t work_items_size

Size of work_items_data, see Implementing barriers.

Definition at line 75 of file builtins.cpp.

Referenced by getWorkItemsData(), and setWorkItemsData().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines