Clover Git
OpenCL 1.1 software implementation
|
Helper macros for info()
functions.
More...
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. |
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 MEM_ASSIGN | ( | size, | |
buf | |||
) |
do { \ value_length = size; \ value = (void *)buf; \ } while (0);
Assign a memory buffer to the return value.
info()
call size | size of the buffer |
buf | buffer (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 | |||
) |
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.
type | type of the argument |
_value | value 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 | ) |
do { \ static const char str[] = string; \ value_length = sizeof(str); \ value = (void *)str; \ } while (0);
Assign a string to the return value.
string | the string to assign, as a constant |
Definition at line 102 of file propertylist.h.
Referenced by Coal::CPUDevice::info().