1 #ifndef VIENNACL_OCL_HANDLE_HPP_
2 #define VIENNACL_OCL_HANDLE_HPP_
25 #include <OpenCL/cl.h>
42 template<
class OCL_TYPE>
45 typedef typename OCL_TYPE::ERROR_TEMPLATE_ARGUMENT_FOR_CLASS_INVALID ErrorType;
53 static void inc(cl_mem & something)
55 cl_int err = clRetainMemObject(something);
59 static void dec(cl_mem & something)
62 cl_int err = clReleaseMemObject(something);
72 static void inc(cl_program & something)
74 cl_int err = clRetainProgram(something);
78 static void dec(cl_program & something)
81 cl_int err = clReleaseProgram(something);
91 static void inc(cl_kernel & something)
93 cl_int err = clRetainKernel(something);
97 static void dec(cl_kernel & something)
100 cl_int err = clReleaseKernel(something);
110 static void inc(cl_command_queue & something)
112 cl_int err = clRetainCommandQueue(something);
116 static void dec(cl_command_queue & something)
119 cl_int err = clReleaseCommandQueue(something);
129 static void inc(cl_context & something)
131 cl_int err = clRetainContext(something);
135 static void dec(cl_context & something)
138 cl_int err = clReleaseContext(something);
145 template<
class OCL_TYPE>
150 handle(
const OCL_TYPE & _something) : something(_something) {}
155 if (something != 0)
dec();
156 something = h.something;
162 if (something != 0)
dec();
163 something = _something;
166 operator OCL_TYPE()
const {
return something; }
172 OCL_TYPE tmp = other.something;
173 other.something = this->something;
174 this->something = tmp;