\class kernel \brief A compute kernel. \see command_queue, program
| 41 | /// |
| 42 | /// \see command_queue, program |
| 43 | class kernel |
| 44 | { |
| 45 | public: |
| 46 | /// Creates a null kernel object. |
| 47 | kernel() |
| 48 | : m_kernel(0) |
| 49 | { |
| 50 | } |
| 51 | |
| 52 | /// Creates a new kernel object for \p kernel. If \p retain is |
| 53 | /// \c true, the reference count for \p kernel will be incremented. |
| 54 | explicit kernel(cl_kernel kernel, bool retain = true) |
| 55 | : m_kernel(kernel) |
| 56 | { |
| 57 | if(m_kernel && retain){ |
| 58 | clRetainKernel(m_kernel); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | /// Creates a new kernel object with \p name from \p program. |
| 63 | kernel(const program &program, const std::string &name) |
| 64 | { |
| 65 | cl_int error = 0; |
| 66 | m_kernel = clCreateKernel(program.get(), name.c_str(), &error); |
| 67 | |
| 68 | if(!m_kernel){ |
| 69 | BOOST_THROW_EXCEPTION(opencl_error(error)); |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | /// Creates a new kernel object as a copy of \p other. |
| 74 | kernel(const kernel &other) |
| 75 | : m_kernel(other.m_kernel) |
| 76 | { |
| 77 | if(m_kernel){ |
| 78 | clRetainKernel(m_kernel); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | /// Copies the kernel object from \p other to \c *this. |
| 83 | kernel& operator=(const kernel &other) |
| 84 | { |
| 85 | if(this != &other){ |
| 86 | if(m_kernel){ |
| 87 | clReleaseKernel(m_kernel); |
| 88 | } |
| 89 | |
| 90 | m_kernel = other.m_kernel; |
| 91 | |
| 92 | if(m_kernel){ |
| 93 | clRetainKernel(m_kernel); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | return *this; |
| 98 | } |
| 99 | |
| 100 | #ifndef BOOST_COMPUTE_NO_RVALUE_REFERENCES |
no outgoing calls
no test coverage detected