cf4ocl (C Framework for OpenCL)  v2.1.0
Object-oriented framework for developing and benchmarking OpenCL projects in C/C++
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Kernel argument wrappers

This module defines the CCLArg* class which wraps kernel arguments. More...

Collaboration diagram for Kernel argument wrappers:

Macros

#define ccl_arg_full(value, size)   ccl_arg_new(value, size)
 Defines a kernel argument with more control. More...
 
#define ccl_arg_full(value, size)   ccl_arg_new(value, size)
 Defines a kernel argument with more control. More...
 
#define ccl_arg_local(count, type)   ccl_arg_new(NULL, count * sizeof(type))
 Defines a local kernel argument, which allocates local memory within the kernel with the specified size. More...
 
#define ccl_arg_local(count, type)   ccl_arg_new(NULL, count * sizeof(type))
 Defines a local kernel argument, which allocates local memory within the kernel with the specified size. More...
 
#define ccl_arg_priv(value, type)   ccl_arg_new(&value, sizeof(type))
 Define a private kernel argument. More...
 
#define ccl_arg_priv(value, type)   ccl_arg_new(&value, sizeof(type))
 Define a private kernel argument. More...
 

Variables

const CCLArgccl_arg_skip
 Use this constant to skip kernel arguments in the ccl_kernel_set_args(), ccl_kernel_set_args_v(), ccl_kernel_set_args_and_enqueue_ndrange() and ccl_kernel_set_args_and_enqueue_ndrange_v() functions.
 
const CCLArgccl_arg_skip
 Use this constant to skip kernel arguments in the ccl_kernel_set_args(), ccl_kernel_set_args_v(), ccl_kernel_set_args_and_enqueue_ndrange() and ccl_kernel_set_args_and_enqueue_ndrange_v() functions.
 

Detailed Description

This module defines the CCLArg* class which wraps kernel arguments.

Several functions in the kernel wrapper module, such as ccl_kernel_set_args() or ccl_kernel_set_args_and_enqueue_ndrange(), accept kernel arguments as parameters. CCLBuffer*, CCLImage* and CCLSampler* objects can be directly passed as global kernel arguments to these functions. However, local and private kernel arguments need to be passed using the macros provided in this module, namely ccl_arg_local() and ccl_arg_priv(), respectively.

The ccl_arg_skip constant can be passed to methods which accept a variable list of ordered arguments in order to skip a specific argument.

Example:

Kernel code:

__kernel void my_kernel(
__global int* g, __local int *l, __private float p) {
}

Host code:

#define LOC_SIZE 16
const cl_float pi=3.1415;
CCLKernel* krnl;
CCLBuffer* buf;
krnl = ccl_program_get_kernel(prg, "my_kernel", NULL);
ccl_kernel_set_args(krnl, buf, ccl_arg_local(LOC_SIZE, cl_int),
ccl_arg_priv(pi, cl_float), NULL);
Note
The ccl_arg_local() and ccl_arg_priv() macros invoke the ccl_arg_new() function, which returns a new CCLArg* object. CCLArg* objects are destroyed when the kernel to which they were passed is released. For further control of argument instantiation, client code can use the ccl_arg_full() macro instead of the ccl_arg_new() function in order to respect the new/destroy rule.
Attention
A CCLArg* object can only be passed once to a kernel. One way to guarantee this is to use the macros directly when setting the kernel arguments, as shown in the example above.

Macro Definition Documentation

#define ccl_arg_full (   value,
  size 
)    ccl_arg_new(value, size)

Defines a kernel argument with more control.

The created object is automatically released when kernel is enqueued.

Parameters
[in]valueMemory location of argument value. Can be NULL if argument is local.
[in]sizeSize in bytes of argument.
Returns
A private or local CCLArg* kernel argument.

Definition at line 170 of file ccl_kernel_arg.h.

#define ccl_arg_full (   value,
  size 
)    ccl_arg_new(value, size)

Defines a kernel argument with more control.

The created object is automatically released when kernel is enqueued.

Parameters
[in]valueMemory location of argument value. Can be NULL if argument is local.
[in]sizeSize in bytes of argument.
Returns
A private or local CCLArg* kernel argument.

Definition at line 170 of file ccl_kernel_arg.h.

#define ccl_arg_local (   count,
  type 
)    ccl_arg_new(NULL, count * sizeof(type))

Defines a local kernel argument, which allocates local memory within the kernel with the specified size.

The created object is automatically released when kernel is enqueued.

Parameters
[in]countNumber of values of type given in next parameter.
[in]typeArgument scalar type, such as cl_int, cl_float, etc.
Returns
A local CCLArg* kernel argument.

Definition at line 156 of file ccl_kernel_arg.h.

#define ccl_arg_local (   count,
  type 
)    ccl_arg_new(NULL, count * sizeof(type))

Defines a local kernel argument, which allocates local memory within the kernel with the specified size.

The created object is automatically released when kernel is enqueued.

Parameters
[in]countNumber of values of type given in next parameter.
[in]typeArgument scalar type, such as cl_int, cl_float, etc.
Returns
A local CCLArg* kernel argument.

Definition at line 156 of file ccl_kernel_arg.h.

#define ccl_arg_priv (   value,
  type 
)    ccl_arg_new(&value, sizeof(type))

Define a private kernel argument.

The created object is automatically released when kernel is enqueued.

Parameters
[in]valueArgument value. Must be a variable, not a literal value.
[in]typeArgument scalar type, such as cl_int, cl_float, etc.
Returns
A private CCLArg* kernel argument.

Definition at line 141 of file ccl_kernel_arg.h.

#define ccl_arg_priv (   value,
  type 
)    ccl_arg_new(&value, sizeof(type))

Define a private kernel argument.

The created object is automatically released when kernel is enqueued.

Parameters
[in]valueArgument value. Must be a variable, not a literal value.
[in]typeArgument scalar type, such as cl_int, cl_float, etc.
Returns
A private CCLArg* kernel argument.
Examples:
canon.c.

Definition at line 141 of file ccl_kernel_arg.h.