OpenCL C++ Wrapper API 1.1
 All Classes Namespaces Files Functions Variables Typedefs Defines
Public Member Functions | Static Public Member Functions | Static Private Attributes
cl::Context Class Reference

#include <cl.hpp>

Inheritance diagram for cl::Context:
cl::detail::Wrapper< cl_context >

List of all members.

Public Member Functions

 Context (const VECTOR_CLASS< Device > &devices, cl_context_properties *properties=NULL, void(CL_CALLBACK *notifyFptr)(const char *, const void *,::size_t, void *)=NULL, void *data=NULL, cl_int *err=NULL)
 Context (cl_device_type type, cl_context_properties *properties=NULL, void(CL_CALLBACK *notifyFptr)(const char *, const void *,::size_t, void *)=NULL, void *data=NULL, cl_int *err=NULL)
 Context ()
 Context (const Context &context)
 Context (const cl_context &context)
Contextoperator= (const Context &rhs)
Contextoperator= (const cl_context &rhs)
template<typename T >
cl_int getInfo (cl_context_info name, T *param) const
template<cl_int name>
detail::param_traits
< detail::cl_context_info,
name >::param_type 
getInfo (cl_int *err=NULL) const
cl_int getSupportedImageFormats (cl_mem_flags flags, cl_mem_object_type type, VECTOR_CLASS< ImageFormat > *formats) const

Static Public Member Functions

static Context getDefault (cl_int *err=NULL)

Static Private Attributes

static volatile int default_initialized_
static Context default_
static volatile cl_int default_error_

Detailed Description

Definition at line 1609 of file cl.hpp.


Constructor & Destructor Documentation

cl::Context::Context ( const VECTOR_CLASS< Device > &  devices,
cl_context_properties *  properties = NULL,
void(CL_CALLBACK *notifyFptr)(const char *,const void *,::size_t,void *)  = NULL,
void *  data = NULL,
cl_int *  err = NULL 
) [inline]

Definition at line 1616 of file cl.hpp.

    {
        cl_int error;
        object_ = ::clCreateContext(
            properties, (cl_uint) devices.size(),
            (cl_device_id*) &devices.front(),
            notifyFptr, data, &error);

        detail::errHandler(error, __CREATE_CONTEXT_ERR);
        if (err != NULL) {
            *err = error;
        }
    }
cl::Context::Context ( cl_device_type  type,
cl_context_properties *  properties = NULL,
void(CL_CALLBACK *notifyFptr)(const char *,const void *,::size_t,void *)  = NULL,
void *  data = NULL,
cl_int *  err = NULL 
) [inline]

Definition at line 1639 of file cl.hpp.

    {
        cl_int error;

#if !defined(__APPLE__) || !defined(__MACOS)
        cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 };    
        if (properties == NULL) {
            prop[1] = (cl_context_properties)Platform::get(&error)();
            if (error != CL_SUCCESS) {
                detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
                if (err != NULL) {
                    *err = error;
                    return;
                }
            }

            properties = &prop[0];
        }
#endif
        object_ = ::clCreateContextFromType(
            properties, type, notifyFptr, data, &error);

        detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR);
        if (err != NULL) {
            *err = error;
        }
    }
cl::Context::Context ( ) [inline]

Definition at line 1719 of file cl.hpp.

: detail::Wrapper<cl_type>() { }
cl::Context::Context ( const Context context) [inline]

Definition at line 1721 of file cl.hpp.

: detail::Wrapper<cl_type>(context) { }
cl::Context::Context ( const cl_context &  context) [inline]

Definition at line 1723 of file cl.hpp.

: detail::Wrapper<cl_type>(context) { }

Member Function Documentation

static Context cl::Context::getDefault ( cl_int *  err = NULL) [inline, static]

Definition at line 1676 of file cl.hpp.

    {
        int state = detail::compare_exchange(
            &default_initialized_, 
            __DEFAULT_BEING_INITIALIZED, __DEFAULT_NOT_INITIALIZED);
        
        if (state & __DEFAULT_INITIALIZED) {
            if (err != NULL) {
                *err = default_error_;
            }
            return default_;
        }

        if (state & __DEFAULT_BEING_INITIALIZED) {
              // Assume writes will propagate eventually...
              while(default_initialized_ != __DEFAULT_INITIALIZED) {
                                ;
              }

            if (err != NULL) {
                *err = default_error_;
            }
            return default_;
        }

        cl_int error;
        default_ = Context(
            CL_DEVICE_TYPE_DEFAULT,
            NULL,
            NULL,
            NULL,
            &error);

        default_error_ = error;
        // Assume writes will propagate eventually...
        default_initialized_ = __DEFAULT_INITIALIZED;
        if (err != NULL) {
            *err = default_error_;
        }
        return default_;

    }
template<typename T >
cl_int cl::Context::getInfo ( cl_context_info  name,
T *  param 
) const [inline]

Definition at line 1740 of file cl.hpp.

    {
        return detail::errHandler(
            detail::getInfo(&::clGetContextInfo, object_, name, param),
            __GET_CONTEXT_INFO_ERR);
    }
template<cl_int name>
detail::param_traits<detail::cl_context_info, name>::param_type cl::Context::getInfo ( cl_int *  err = NULL) const [inline]

Definition at line 1749 of file cl.hpp.

    {
        typename detail::param_traits<
            detail::cl_context_info, name>::param_type param;
        cl_int result = getInfo(name, &param);
        if (err != NULL) {
            *err = result;
        }
        return param;
    }
cl_int cl::Context::getSupportedImageFormats ( cl_mem_flags  flags,
cl_mem_object_type  type,
VECTOR_CLASS< ImageFormat > *  formats 
) const [inline]

Definition at line 1760 of file cl.hpp.

    {
        cl_uint numEntries;
        cl_int err = ::clGetSupportedImageFormats(
           object_, 
           flags,
           type, 
           0, 
           NULL, 
           &numEntries);
        if (err != CL_SUCCESS) {
            return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
        }

        ImageFormat* value = (ImageFormat*)
            alloca(numEntries * sizeof(ImageFormat));
        err = ::clGetSupportedImageFormats(
            object_, 
            flags, 
            type, 
            numEntries,
            (cl_image_format*) value, 
            NULL);
        if (err != CL_SUCCESS) {
            return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR);
        }

        formats->assign(&value[0], &value[numEntries]);
        return CL_SUCCESS;
    }
Context& cl::Context::operator= ( const Context rhs) [inline]

Definition at line 1725 of file cl.hpp.

    {
        if (this != &rhs) {
            detail::Wrapper<cl_type>::operator=(rhs);
        }
        return *this;
    }
Context& cl::Context::operator= ( const cl_context &  rhs) [inline]

Reimplemented from cl::detail::Wrapper< cl_context >.

Definition at line 1733 of file cl.hpp.

    {
        detail::Wrapper<cl_type>::operator=(rhs);
        return *this;
    }

Member Data Documentation

Context cl::Context::default_ [static, private]

Definition at line 1613 of file cl.hpp.

volatile cl_int cl::Context::default_error_ [static, private]

Definition at line 1614 of file cl.hpp.

volatile int cl::Context::default_initialized_ [static, private]

Definition at line 1612 of file cl.hpp.


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