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

Coal::Kernel::Arg Class Reference

Kernel argument. More...

#include <kernel.h>

List of all members.

Public Types

enum  File { Private = 0, Global = 1, Local = 2, Constant = 3 }
 

Memory address space qualifier.

More...
enum  Kind {
  Invalid, Int8, Int16, Int32,
  Int64, Float, Double, Buffer,
  Image2D, Image3D, Sampler
}
 

Kind of argument (its datatype)

More...

Public Member Functions

 Arg (unsigned short vec_dim, File file, Kind kind)
 Constructor.
 ~Arg ()
void alloc ()
 Allocate the argument.
void loadData (const void *data)
 Load a value into the argument.
void setAllocAtKernelRuntime (size_t size)
 Set the number of bytes that must be allocated at run-time.
void refineKind (Kind kind)
 Changes the Kind of this argument.
bool operator!= (const Arg &b)
 Compares this argument with another.
size_t valueSize () const
 Size of a field of this arg.
unsigned short vecDim () const
 Vector dimension.
File file () const
 File.
Kind kind () const
 Kind.
bool defined () const
 Has the value of this argument already beed loaded by the host application ?
size_t allocAtKernelRuntime () const
 Size of the __local buffer to allocate at kernel runtime.
const void * value (unsigned short index) const
 Pointer to the value of this argument, for the index vector element.
const void * data () const
 Pointer to the data of this arg, equivalent to value(0)

Private Attributes

unsigned short p_vec_dim
File p_file
Kind p_kind
void * p_data
bool p_defined
size_t p_runtime_alloc

Detailed Description

Kernel argument.

This class holds OpenCL-related information about the arguments of a kernel. It is also used to check that a kernel takes the same arguments on every device on which it has been built.

Definition at line 82 of file kernel.h.


Member Enumeration Documentation

Memory address space qualifier.

Enumerator:
Private 

__private

Global 

__global

Local 

__local

Constant 

__constant

Definition at line 88 of file kernel.h.

Kind of argument (its datatype)

Enumerator:
Invalid 

Invalid argument.

Int8 

uchar or char, i8 in LLVM

Int16 

ushort or short, i16 in LLVM

Int32 

uint or int, i32 in LLVM

Int64 

ulong or long, i64 in LLVM

Float 

float, float in LLVM

Double 

double, double in LLVM

Buffer 

Coal::Buffer or Coal::SubBuffer, type* in LLVM

Image2D 

Coal::Image2D, %struct.image2d* in LLVM

Image3D 

Coal::Image3D, %struct.image3d* in LLVM

Sampler 

Coal::Sampler::bitfield(), i32 in LLVM, see Coal::Kernel::setArg()

Definition at line 99 of file kernel.h.


Constructor & Destructor Documentation

Kernel::Arg::Arg ( unsigned short  vec_dim,
File  file,
Kind  kind 
)

Constructor.

Parameters:
vec_dimvector dimension of the argument, 1 if not a vector
fileFile of the argument
kindKind of the argument

Definition at line 446 of file kernel.cpp.

Kernel::Arg::~Arg ( )

Definition at line 453 of file kernel.cpp.


Member Function Documentation

void Kernel::Arg::alloc ( )

Allocate the argument.

This function must be called before loadData(). It allocates a buffer in which the argument value can be stored.

See also:
valueSize()

Definition at line 459 of file kernel.cpp.

Referenced by Coal::Kernel::setArg().

size_t Kernel::Arg::allocAtKernelRuntime ( ) const

Size of the __local buffer to allocate at kernel runtime.

Definition at line 539 of file kernel.cpp.

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

const void * Kernel::Arg::data ( ) const

Pointer to the data of this arg, equivalent to value(0)

Definition at line 554 of file kernel.cpp.

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

bool Kernel::Arg::defined ( ) const

Has the value of this argument already beed loaded by the host application ?

Definition at line 534 of file kernel.cpp.

Kernel::Arg::File Kernel::Arg::file ( ) const

File.

Definition at line 524 of file kernel.cpp.

Referenced by Coal::CPUKernelWorkGroup::callArgs(), and Coal::Kernel::setArg().

Kernel::Arg::Kind Kernel::Arg::kind ( ) const
void Kernel::Arg::loadData ( const void *  data)

Load a value into the argument.

Note:
alloc() must have been called before this function.
See also:
valueSize()

Definition at line 465 of file kernel.cpp.

Referenced by Coal::Kernel::setArg().

bool Kernel::Arg::operator!= ( const Arg b)

Compares this argument with another.

They are different if they vec_dim, file or kind are not the same.

Parameters:
bother argument to compare
Returns:
true if the this arguments doesn't match b

Definition at line 482 of file kernel.cpp.

References p_file, p_kind, and p_vec_dim.

void Kernel::Arg::refineKind ( Kind  kind)

Changes the Kind of this argument.

Parameters:
kindnew Kind

Definition at line 477 of file kernel.cpp.

Referenced by Coal::Kernel::setArg().

void Kernel::Arg::setAllocAtKernelRuntime ( size_t  size)

Set the number of bytes that must be allocated at run-time.

__local arguments don't take a value given by the host application, but take pointers allocated on the device for each work-group.

This function allows to set the size of the device-allocated memory buffer used by this argument.

Parameters:
sizesize in byte of the buffer the device has to allocate for each work-group of this kernel

Definition at line 471 of file kernel.cpp.

Referenced by Coal::Kernel::setArg().

const void * Kernel::Arg::value ( unsigned short  index) const

Pointer to the value of this argument, for the index vector element.

Definition at line 544 of file kernel.cpp.

Referenced by Coal::KernelEvent::KernelEvent().

size_t Kernel::Arg::valueSize ( ) const

Size of a field of this arg.

This function returns the size of this argument based on its Kind

Note:
This size is not multiplied by vecDim(), you must do this by yourself to find the total space taken by this arg.
Returns:
the size of this argument, in bytes, without any padding

Definition at line 491 of file kernel.cpp.

Referenced by Coal::CPUKernelWorkGroup::callArgs(), Coal::CPUKernel::callFunction(), and Coal::Kernel::setArg().

unsigned short Kernel::Arg::vecDim ( ) const

Vector dimension.

Definition at line 519 of file kernel.cpp.

Referenced by Coal::CPUKernelWorkGroup::callArgs(), and Coal::CPUKernel::callFunction().


Member Data Documentation

void* Coal::Kernel::Arg::p_data [private]

Definition at line 196 of file kernel.h.

Definition at line 197 of file kernel.h.

Definition at line 194 of file kernel.h.

Referenced by operator!=().

Definition at line 195 of file kernel.h.

Referenced by operator!=().

Definition at line 198 of file kernel.h.

unsigned short Coal::Kernel::Arg::p_vec_dim [private]

Definition at line 193 of file kernel.h.

Referenced by operator!=().


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