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

Coal::CPUKernelWorkGroup Class Reference

CPU kernel work-group. More...

#include <kernel.h>

Collaboration diagram for Coal::CPUKernelWorkGroup:

List of all members.

Classes

struct  Context

Public Member Functions

 CPUKernelWorkGroup (CPUKernel *kernel, KernelEvent *event, CPUKernelEvent *cpu_event, const size_t *work_group_index)
 Constructor.
 ~CPUKernelWorkGroup ()
void * callArgs (std::vector< void * > &locals_to_free)
 Build a structure of arguments.
bool run ()
 Run the work-group.
void builtinNotFound (const std::string &name) const
 Function called when a built-in name cannot be found.

Private Member Functions

template<typename T >
void writeImageImpl (Image2D *image, int x, int y, int z, T *color) const
template<typename T >
void readImageImplI (T *result, Image2D *image, int x, int y, int z, uint32_t sampler) const
template<typename T >
void readImageImplF (T *result, Image2D *image, float x, float y, float z, uint32_t sampler) const
template<typename T >
void linear3D (T *result, float a, float b, float c, int i0, int j0, int k0, int i1, int j1, int k1, Image3D *image) const
template<typename T >
void linear2D (T *result, float a, float b, float c, int i0, int j0, int i1, int j1, Image2D *image) const
ContextgetContextAddr (unsigned int index)

Private Attributes

CPUKernelp_kernel
CPUKernelEventp_cpu_event
KernelEventp_event
cl_uint p_work_dim
size_t p_index [MAX_WORK_DIMS]
size_t p_max_local_id [MAX_WORK_DIMS]
size_t p_global_id_start_offset [MAX_WORK_DIMS]
void(* p_kernel_func_addr )(void *)
void * p_args
Contextp_current_context
Context p_dummy_context
void * p_contexts
size_t p_stack_size
unsigned int p_num_work_items
unsigned int p_current_work_item
bool p_had_barrier

Native implementation of built-in OpenCL C functions

size_t getGlobalId (cl_uint dimindx) const
cl_uint getWorkDim () const
size_t getGlobalSize (cl_uint dimindx) const
size_t getLocalSize (cl_uint dimindx) const
size_t getLocalID (cl_uint dimindx) const
size_t getNumGroups (cl_uint dimindx) const
size_t getGroupID (cl_uint dimindx) const
size_t getGlobalOffset (cl_uint dimindx) const
void barrier (unsigned int flags)
void * getImageData (Image2D *image, int x, int y, int z) const
void writeImage (Image2D *image, int x, int y, int z, float *color) const
void writeImage (Image2D *image, int x, int y, int z, int32_t *color) const
void writeImage (Image2D *image, int x, int y, int z, uint32_t *color) const
void readImage (float *result, Image2D *image, int x, int y, int z, uint32_t sampler) const
void readImage (int32_t *result, Image2D *image, int x, int y, int z, uint32_t sampler) const
void readImage (uint32_t *result, Image2D *image, int x, int y, int z, uint32_t sampler) const
void readImage (float *result, Image2D *image, float x, float y, float z, uint32_t sampler) const
void readImage (int32_t *result, Image2D *image, float x, float y, float z, uint32_t sampler) const
void readImage (uint32_t *result, Image2D *image, float x, float y, float z, uint32_t sampler) const

Detailed Description

CPU kernel work-group.

This class represent a bulk of work-items that will be run. It is the one to actually run the kernel of its elements.

See also:
Using Clang and LLVM to Launch Kernels

Definition at line 150 of file cpu/kernel.h.


Constructor & Destructor Documentation

CPUKernelWorkGroup::CPUKernelWorkGroup ( CPUKernel kernel,
KernelEvent event,
CPUKernelEvent cpu_event,
const size_t *  work_group_index 
)

Constructor.

Parameters:
kernelkernel to run
eventevent containing information about the kernel run
cpu_eventCPU-specific information and cache about event
work_group_indexindex of this work-group in the kernel

Definition at line 388 of file cpu/kernel.cpp.

References Coal::KernelEvent::global_work_offset(), p_global_id_start_offset, p_index, p_max_local_id, p_num_work_items, and p_work_dim.

CPUKernelWorkGroup::~CPUKernelWorkGroup ( )

Definition at line 413 of file cpu/kernel.cpp.

References p_cpu_event, and Coal::CPUKernelEvent::workGroupFinished().


Member Function Documentation

void CPUKernelWorkGroup::barrier ( unsigned int  flags)
void CPUKernelWorkGroup::builtinNotFound ( const std::string &  name) const

Function called when a built-in name cannot be found.

Definition at line 248 of file builtins.cpp.

References Coal::CPUKernel::function(), and p_kernel.

Referenced by getBuiltin().

void * CPUKernelWorkGroup::callArgs ( std::vector< void * > &  locals_to_free)

Build a structure of arguments.

As C doesn't support calling functions with variable arguments unknown at the compilation, this function builds the list of arguments in memory. This array will then be passed to a LLVM stub function reading it and passing its values to the actuel kernel.

See also:
Using Clang and LLVM to Launch Kernels
Parameters:
locals_to_freeif this kernel takes __local arguments, they must be malloc()'ed for every work-group. They are placed in this vector to be free()'ed at the end of run().
Returns:
address of a memory location containing the arguments

Definition at line 418 of file cpu/kernel.cpp.

References Coal::MemObject::allocate(), Coal::Kernel::Arg::allocAtKernelRuntime(), Coal::Kernel::arg(), Coal::Kernel::Arg::Buffer, Coal::CPUKernelEvent::cacheKernelArgs(), Coal::CPUBuffer::data(), Coal::Kernel::Arg::data(), Coal::CPUKernel::device(), Coal::MemObject::deviceBuffer(), Coal::Kernel::Arg::file(), Coal::Kernel::hasLocals(), Coal::Kernel::Arg::Image2D, Coal::Kernel::Arg::Image3D, Coal::CPUKernel::kernel(), Coal::CPUKernelEvent::kernelArgs(), Coal::Kernel::Arg::kind(), Coal::Kernel::Arg::Local, Coal::Kernel::numArgs(), p_cpu_event, p_kernel, Coal::CPUKernel::typeOffset(), Coal::Kernel::Arg::valueSize(), and Coal::Kernel::Arg::vecDim().

Referenced by run().

CPUKernelWorkGroup::Context * CPUKernelWorkGroup::getContextAddr ( unsigned int  index) [private]

Definition at line 580 of file cpu/kernel.cpp.

References p_contexts, and p_stack_size.

Referenced by barrier(), and run().

size_t CPUKernelWorkGroup::getGlobalId ( cl_uint  dimindx) const
size_t CPUKernelWorkGroup::getGlobalOffset ( cl_uint  dimindx) const

Definition at line 151 of file builtins.cpp.

References Coal::KernelEvent::global_work_offset(), p_event, and p_work_dim.

Referenced by get_global_offset().

size_t CPUKernelWorkGroup::getGlobalSize ( cl_uint  dimindx) const

Definition at line 110 of file builtins.cpp.

References Coal::KernelEvent::global_work_size(), p_event, and p_work_dim.

Referenced by get_global_size().

size_t CPUKernelWorkGroup::getGroupID ( cl_uint  dimindx) const

Definition at line 143 of file builtins.cpp.

References p_index, and p_work_dim.

Referenced by get_group_id().

void * CPUKernelWorkGroup::getImageData ( Image2D image,
int  x,
int  y,
int  z 
) const
size_t CPUKernelWorkGroup::getLocalID ( cl_uint  dimindx) const

Definition at line 126 of file builtins.cpp.

References Coal::CPUKernelWorkGroup::Context::local_id, p_current_context, and p_work_dim.

Referenced by get_local_id().

size_t CPUKernelWorkGroup::getLocalSize ( cl_uint  dimindx) const

Definition at line 118 of file builtins.cpp.

References Coal::KernelEvent::local_work_size(), p_event, and p_work_dim.

Referenced by get_local_size().

size_t CPUKernelWorkGroup::getNumGroups ( cl_uint  dimindx) const
cl_uint CPUKernelWorkGroup::getWorkDim ( ) const

Definition at line 97 of file builtins.cpp.

References p_work_dim.

Referenced by get_work_dim().

template<typename T >
void CPUKernelWorkGroup::linear2D ( T *  result,
float  a,
float  b,
float  c,
int  i0,
int  j0,
int  i1,
int  j1,
Image2D image 
) const [private]

Definition at line 310 of file cpu/sampler.cpp.

References vec4_add(), and vec4_scalar_mul().

template<typename T >
void CPUKernelWorkGroup::linear3D ( T *  result,
float  a,
float  b,
float  c,
int  i0,
int  j0,
int  k0,
int  i1,
int  j1,
int  k1,
Image3D image 
) const [private]

Definition at line 271 of file cpu/sampler.cpp.

References vec4_add(), and vec4_scalar_mul().

void CPUKernelWorkGroup::readImage ( float *  result,
Image2D image,
int  x,
int  y,
int  z,
uint32_t  sampler 
) const
void CPUKernelWorkGroup::readImage ( int32_t *  result,
Image2D image,
int  x,
int  y,
int  z,
uint32_t  sampler 
) const

Definition at line 543 of file cpu/sampler.cpp.

void CPUKernelWorkGroup::readImage ( uint32_t *  result,
Image2D image,
int  x,
int  y,
int  z,
uint32_t  sampler 
) const

Definition at line 549 of file cpu/sampler.cpp.

void CPUKernelWorkGroup::readImage ( int32_t *  result,
Image2D image,
float  x,
float  y,
float  z,
uint32_t  sampler 
) const

Definition at line 759 of file cpu/sampler.cpp.

void CPUKernelWorkGroup::readImage ( float *  result,
Image2D image,
float  x,
float  y,
float  z,
uint32_t  sampler 
) const

Definition at line 753 of file cpu/sampler.cpp.

void CPUKernelWorkGroup::readImage ( uint32_t *  result,
Image2D image,
float  x,
float  y,
float  z,
uint32_t  sampler 
) const

Definition at line 765 of file cpu/sampler.cpp.

template<typename T >
void CPUKernelWorkGroup::readImageImplF ( T *  result,
Image2D image,
float  x,
float  y,
float  z,
uint32_t  sampler 
) const [private]
template<typename T >
void CPUKernelWorkGroup::readImageImplI ( T *  result,
Image2D image,
int  x,
int  y,
int  z,
uint32_t  sampler 
) const [private]
bool CPUKernelWorkGroup::run ( )
void CPUKernelWorkGroup::writeImage ( Image2D image,
int  x,
int  y,
int  z,
int32_t *  color 
) const

Definition at line 460 of file cpu/sampler.cpp.

void CPUKernelWorkGroup::writeImage ( Image2D image,
int  x,
int  y,
int  z,
uint32_t *  color 
) const

Definition at line 466 of file cpu/sampler.cpp.

void CPUKernelWorkGroup::writeImage ( Image2D image,
int  x,
int  y,
int  z,
float *  color 
) const

Definition at line 454 of file cpu/sampler.cpp.

Referenced by write_imagef(), write_imagei(), and write_imageui().

template<typename T >
void CPUKernelWorkGroup::writeImageImpl ( Image2D image,
int  x,
int  y,
int  z,
T *  color 
) const [private]

Member Data Documentation

Definition at line 265 of file cpu/kernel.h.

Referenced by barrier(), and run().

Definition at line 279 of file cpu/kernel.h.

Referenced by barrier(), and getContextAddr().

Definition at line 257 of file cpu/kernel.h.

Referenced by callArgs(), and ~CPUKernelWorkGroup().

Definition at line 277 of file cpu/kernel.h.

Referenced by barrier(), getGlobalId(), getLocalID(), and run().

Definition at line 281 of file cpu/kernel.h.

Referenced by barrier(), and run().

Definition at line 278 of file cpu/kernel.h.

Referenced by run().

Definition at line 258 of file cpu/kernel.h.

Referenced by getGlobalOffset(), getGlobalSize(), getLocalSize(), and getNumGroups().

size_t Coal::CPUKernelWorkGroup::p_global_id_start_offset[MAX_WORK_DIMS] [private]

Definition at line 260 of file cpu/kernel.h.

Referenced by CPUKernelWorkGroup(), and getGlobalId().

Definition at line 282 of file cpu/kernel.h.

Referenced by barrier(), and run().

size_t Coal::CPUKernelWorkGroup::p_index[MAX_WORK_DIMS] [private]

Definition at line 260 of file cpu/kernel.h.

Referenced by CPUKernelWorkGroup(), and getGroupID().

Definition at line 256 of file cpu/kernel.h.

Referenced by barrier(), builtinNotFound(), callArgs(), getImageData(), and run().

Definition at line 264 of file cpu/kernel.h.

Referenced by barrier(), and run().

size_t Coal::CPUKernelWorkGroup::p_max_local_id[MAX_WORK_DIMS] [private]

Definition at line 260 of file cpu/kernel.h.

Referenced by barrier(), CPUKernelWorkGroup(), and run().

Definition at line 281 of file cpu/kernel.h.

Referenced by barrier(), CPUKernelWorkGroup(), and run().

Definition at line 280 of file cpu/kernel.h.

Referenced by barrier(), and getContextAddr().


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