8 #ifndef OCL_LIBRARY_WRAPPER_H 9 #define OCL_LIBRARY_WRAPPER_H 11 #define CL_HPP_MINIMUM_OPENCL_VERSION 110 12 #define CL_HPP_TARGET_OPENCL_VERSION 110 18 #include <boost/shared_ptr.hpp> 29 typedef std::shared_ptr<cl::CommandQueue>
QueuePtr;
49 const std::string& program_name);
60 buffer = cl::Buffer(*context, CL_MEM_WRITE_ONLY,
sizeof(T) * n_elements);
65 buffer = cl::Buffer(*context, CL_MEM_READ_ONLY,
sizeof(T) * n_elements);
70 buffer = cl::Buffer(*context, CL_MEM_READ_WRITE,
sizeof(T) * n_elements);
75 throw std::runtime_error(
"Unknown access type!");
78 return std::make_shared<cl::Buffer>(buffer);
84 queue->enqueueWriteBuffer(*buffer, CL_TRUE, 0,
sizeof(T) * array.size(),
90 const unsigned int size,
const T* array)
92 queue->enqueueWriteBuffer(*buffer, CL_TRUE, 0,
sizeof(T) * size, array);
98 queue->enqueueReadBuffer(*buffer, CL_TRUE, 0,
sizeof(T) * array.size(),
102 template <
typename T>
104 const unsigned int size, T* array)
106 queue->enqueueReadBuffer(*buffer, CL_TRUE, 0,
sizeof(T) * size, array);
111 #endif // OCL_LIBRARY_WRAPPER_H void read_ocl_buffer(QueuePtr queue, BufferPtr buffer, std::vector< T > &array)
ContextPtr get_ocl_context(DevicePtr device)
QueuePtr create_ocl_command_queue(ContextPtr context, DevicePtr device)
static const int R_ACCESS
DevicePtr get_ocl_default_device()
std::shared_ptr< cl::Device > DevicePtr
StringPtr load_kernel_definition(const std::string &path)
std::shared_ptr< std::string > StringPtr
void write_ocl_buffer(QueuePtr queue, BufferPtr buffer, std::vector< T > &array)
std::shared_ptr< cl::Program > ProgramPtr
std::shared_ptr< cl::CommandQueue > QueuePtr
std::shared_ptr< cl::Buffer > BufferPtr
static const int W_ACCESS
BufferPtr create_ocl_buffer(ContextPtr context, unsigned int n_elements, int access_type)
KernelPtr create_ocl_kernel(ProgramPtr program, const std::string &program_name)
static const int RW_ACCESS
This namespace is used by the nodelets inside our package pses_kinect_utilities.
std::shared_ptr< cl::Context > ContextPtr
std::shared_ptr< cl::Kernel > KernelPtr
ProgramPtr build_ocl_program(DevicePtr device, ContextPtr context, StringPtr kernel)