Clover Git
OpenCL 1.1 software implementation
Defines

propertylist.h File Reference

Helper macros for info() functions. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define SIMPLE_ASSIGN(type, _value)
 Assign a value of a given type to the return value.
#define STRING_ASSIGN(string)
 Assign a string to the return value.
#define MEM_ASSIGN(size, buf)
 Assign a memory buffer to the return value.

Detailed Description

Helper macros for info() functions.

The OpenCL API is full of functions like clGetXXXInfo(). They all take the same arguments and are handled the same way. This file contains macros easing the implementation of these info functions.

One info function, using these macros, looks like that:

 cl_int Foo::info(cl_foo_info param_name,
                  size_t param_value_size,
                  void *param_value,
                  size_t *param_value_size_ret) const
 {
     void *value = 0;
     size_t value_length = 0;
 
     union {
         cl_uint cl_uint_var;
         cl_context cl_context_var;
     };
 
     switch (param_name)
     {
                case CL_UINT_PARAM:
                    SIMPLE_ASSIGN(cl_uint, the_value);
                    break;
                case CL_CONTEXT_PARAM:
                    SIMPLE_ASSIGN(cl_context, a_call());
                    break;
                case CL_STRING_PARAM:
                    STRING_ASSIGN("This is a string");
                    break;
                case CL_BINARY_PARAM:
                    MEM_ASSIGN(sizeof(something), something);
                    break;
      default:
          return CL_INVALID_VALUE;
     }
 
     if (param_value && param_value_size < value_length)
         return CL_INVALID_VALUE;
 
     if (param_value_size_ret)
         *param_value_size_ret = value_length;
 
     if (param_value)
         std::memcpy(param_value, value, value_length);
 
     return CL_SUCCESS;
 }

Definition in file propertylist.h.


Define Documentation

#define MEM_ASSIGN (   size,
  buf 
)
Value:
do {          \
    value_length = size;                    \
    value = (void *)buf;                    \
} while (0);

Assign a memory buffer to the return value.

Note:
the buffer must remain valid after the end of the info() call
Parameters:
sizesize of the buffer
bufbuffer (of type void * for instance)

Definition at line 114 of file propertylist.h.

Referenced by Coal::Program::info(), Coal::Kernel::info(), and Coal::Context::info().

#define SIMPLE_ASSIGN (   type,
  _value 
)
Value:
do {    \
    value_length = sizeof(type);            \
    type##_var = (type)_value;              \
    value = & type##_var;                   \
} while (0);

Assign a value of a given type to the return value.

Parameters:
typetype of the argument
_valuevalue to assign

Definition at line 92 of file propertylist.h.

Referenced by Coal::Program::buildInfo(), Coal::Image2D::imageInfo(), Coal::Sampler::info(), Coal::Program::info(), Coal::MemObject::info(), Coal::Kernel::info(), Coal::CPUDevice::info(), Coal::Context::info(), Coal::Event::info(), Coal::CommandQueue::info(), Coal::Event::profilingInfo(), and Coal::Kernel::workGroupInfo().

#define STRING_ASSIGN (   string)
Value:
do {          \
    static const char str[] = string;       \
    value_length = sizeof(str);             \
    value = (void *)str;                    \
} while (0);

Assign a string to the return value.

Parameters:
stringthe string to assign, as a constant

Definition at line 102 of file propertylist.h.

Referenced by Coal::CPUDevice::info().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines