Image Component Library (ICL)
CLBuffer.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLUtils/src/ICLUtils/CLBuffer.h **
10 ** Module : ICLUtils **
11 ** Authors: Viktor Losing **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.GPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 #ifdef ICL_HAVE_OPENCL
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLUtils/CLException.h>
35 #include <ICLUtils/CLMemory.h>
36 #include <string>
37 
39 namespace cl{
40  class Buffer;
41  class Context;
42  class CommandQueue;
43 }
46 namespace icl {
47  namespace utils {
48 
50 
52  class ICLUtils_API CLBuffer : public CLMemory {
53  struct Impl;
54  Impl *impl;
55 
57  CLBuffer(cl::Context& context, cl::CommandQueue &cmdQueue,
58  const string &accessMode, size_t size, const void *src=NULL) ;
59 
60  CLBuffer(cl::Context& context, cl::CommandQueue &cmdQueue, const string &accessMode,
61  size_t length, size_t byte_depth, const void *src=NULL) ;
62 
64  cl::Buffer &getBuffer();
65  const cl::Buffer &getBuffer() const;
66 
67  public:
68  friend class CLProgram;
69  friend class CLKernel;
70  friend class CLDeviceContext;
71 
73  CLBuffer();
74 
76  CLBuffer(const CLBuffer& other);
77 
79  CLBuffer& operator=(const CLBuffer& other);
80 
82  ~CLBuffer();
83 
85  void copy(CLBuffer &dst, int len, int src_offset = 0, int dst_offset = 0) ;
86 
88  void read(void *dst, int len, int offset = 0, bool block = true) ;
89 
91  void write(const void *src, int len, int offset = 0, bool block = true) ;
92 
94  bool isNull() const {
95  return !impl;
96  }
97 
99  operator bool() const {
100  return impl;
101  }
102 
103  };
104  }
105 }
106 #endif
undocument this line if you encounter any issues!
Definition: Any.h:37
bool isNull() const
checks whether buffer is null
Definition: CLBuffer.h:94
Definition: CLDeviceContext.h:43
#define ICLUtils_API
this macros are important for creating dll's
Definition: CompatMacros.h:171
Wrapper for an OpenCL Kernel.
Definition: CLKernel.h:72
Impl * impl
internal hidden implementation type
Definition: CLBuffer.h:53
Wrapper for an OpenCL Buffer.
Definition: CLBuffer.h:52
The CLDeviceContext class allows preparation of the device used for CLPrograms.
Definition: CLDeviceContext.h:61
The CLMemory class is a base class for CLBuffer and CLImage2D.
Definition: CLMemory.h:48
void copy(const T *src, const T *srcEnd, T *dst)
moves data from source to destination array (no casting possible)
Definition: CoreFunctions.h:216
Main class for OpenCL based accelleration.
Definition: CLProgram.h:259