@@ -46,8 +46,12 @@ class FAST_EXPORT OpenCLProgram : public Object {
4646 std::unordered_map<std::shared_ptr<OpenCLDevice>, std::map<std::string, cl::Program> > mOpenCLPrograms ;
4747};
4848
49+ /* *
50+ * @brief Access qualifier of a kernel argument
51+ * @ingroup opencl
52+ */
4953enum class KernelArgumentAccess {
50- NONE ,
54+ UNSPECIFIED ,
5155 READ_ONLY,
5256 WRITE_ONLY,
5357 READ_WRITE,
@@ -221,34 +225,86 @@ FAST_EXPORT void Kernel::setArg(const std::string& name, std::unique_ptr<OpenCLB
221225class FAST_EXPORT Queue {
222226 public:
223227 Queue (cl::CommandQueue clQueue);
228+ /* *
229+ * @brief Enqueue a Kernel to this command queue
230+ * @param kernel
231+ * @param globalSize total number of work-items for each dimension
232+ * @param offset work-item offset, if none is given, it is zero for all dimensions
233+ * @param groupSize How many work-items should be each work-group for each dimension.
234+ * If not provided, platform will decide automatically
235+ */
224236 void add (const Kernel& kernel, std::vector<int > globalSize, std::vector<int > offset = std::vector<int >(), std::vector<int> groupSize = std::vector<int>());
237+ /* *
238+ * @brief Block until entire command queue is finished
239+ */
225240 void finish ();
241+ /* *
242+ * @brief Copy data from buffer on device to pointer on host
243+ * @param buffer OpenCL buffer to read from
244+ * @param block Whether this call should block and wait until the data operation is finished.
245+ * @param offset Byte offset in OpenCL buffer
246+ * @param size nr of bytes to read (e.g. elements*sizeof(datatype))
247+ * @param pointerToData Pointer to host memory to read data into. Must be allocated with big enough size
248+ */
226249 void addReadBuffer (OpenCLBuffer buffer, bool block, std::size_t offset, std::size_t size, void * pointerToData);
250+ /* *
251+ * @brief Write data from host pointer to OpenCL buffer
252+ * @param buffer OpenCL buffer to write data to
253+ * @param block Whether this call should block and wait until the data operation is finished.
254+ * @param offset Byte offset in OpenCL buffer to write data to
255+ * @param size nr of bytes to write (e.g. elements*sizeof(datatype))
256+ * @param pointerToData Pointer to host memory to read data from. Must be bigger than size.
257+ */
227258 void addWriteBuffer (OpenCLBuffer buffer, bool block, std::size_t offset, std::size_t size, void * pointerToData);
259+ /* *
260+ * @brief Copy data from one OpenCL buffer (source) to another (destination)
261+ * @param srcBuffer source OpenCL buffer
262+ * @param dstBuffer destination OpenCL buffer
263+ * @param srcOffset offset in bytes in source buffer
264+ * @param destOffset offset in bytes in destination buffer
265+ * @param size size in bytes (e.g. elements*sizeof(datatype))
266+ */
228267 void addCopyBuffer (OpenCLBuffer srcBuffer, OpenCLBuffer dstBuffer, std::size_t srcOffset, std::size_t destOffset, std::size_t size);
229268 cl::CommandQueue getHandle () const ;
230269 private:
231270 cl::CommandQueue m_queue;
232271};
233272
273+ /* *
274+ * @brief Access to OpenCL memory granted to kernel
275+ * @ingroup opencl
276+ */
234277enum class KernelMemoryAccess {
235278 READ_WRITE = 0 ,
236279 READ_ONLY,
237280 WRITE_ONLY
238281};
282+ /* *
283+ * @brief Access to OpenCL memory granted to host
284+ * @ingroup opencl
285+ */
239286enum class HostMemoryAccess {
240287 UNSPECIFIED = 0 ,
241288 READ_ONLY,
242289 WRITE_ONLY,
243290 // READ_WRITE,
244291 NONE
245292};
293+
246294/* *
247295 * @brief OpenCL Buffer
248296 * @ingroup opencl
249297 */
250298class FAST_EXPORT OpenCLBuffer {
251299 public:
300+ /* *
301+ * @brief Create OpenCL buffer
302+ * @param size in bytes (e.g. elements*sizeof(datatype))
303+ * @param device device
304+ * @param kernelAccess Access to memory to grant to kernel (default READ+WRITE)
305+ * @param hostAccess Access to memory to grant to host (default UNSPECIFIED)
306+ * @param data Pointer to data on host which is copied to the device (default nullptr/none)
307+ */
252308 OpenCLBuffer (
253309 std::size_t size,
254310 OpenCLDevice::pointer device,
@@ -257,6 +313,10 @@ class FAST_EXPORT OpenCLBuffer {
257313 const void * data = nullptr
258314 );
259315 cl::Buffer getHandle () const ;
316+ /* *
317+ * @brief Get size of OpenCL buffer in bytes
318+ * @return number of bytes
319+ */
260320 std::size_t getSize () const ;
261321 private:
262322 cl::Buffer m_buffer;
0 commit comments