Image Component Library (ICL)
CLMemoryAssistant.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/CLMemoryAssistant.h **
10  ** Module : ICLUtils **
11  ** Authors: Tobias Roehlig **
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 
31 #pragma once
32 
33 #ifdef ICL_HAVE_OPENCL
34 
36 #include <ICLUtils/CLMemory.h>
37 #include <ICLUtils/CLBuffer.h>
38 #include <ICLUtils/CLImage2D.h>
39 #include <ICLUtils/Exception.h>
40 #include <map>
41 
42 namespace icl {
43  namespace utils {
44 
54 
55  public:
60 
65  CLMemoryAssistant(std::string const &deviceType) ;
66 
69 
70  typedef std::string MemKeyType;
71  typedef std::map<MemKeyType,CLMemory*> CLMemoryMap;
72 
79  CLBuffer createNamedBuffer(MemKeyType const &key, const string &accessMode,
80  const size_t length, const size_t byteDepth, const void *src=0)
81  ;
82 
89  CLImage2D createNamedImage2D(MemKeyType const &key, const string &accessMode,
90  const size_t width, const size_t height, const int depth,
91  const int num_channel, const void *src=0)
92  ;
93 
99  CLMemory *operator[](MemKeyType const &key) ;
100 
106  CLBuffer &asBuf(MemKeyType const &key) ;
107 
113  CLImage2D &asImg(MemKeyType const &key) ;
114 
120  bool keyExist(MemKeyType const &key) { return (bool)m_memory_map.count(key); }
121 
125  void clearAll();
126 
131  void remove(MemKeyType const &key);
132 
137  CLDeviceContext const &getDeviceContext() { return m_context; }
138 
139  protected:
140 
145  };
146 
147  }
148 }
149 
150 #endif
undocument this line if you encounter any issues!
Definition: Any.h:37
#define ICLUtils_API
this macros are important for creating dll's
Definition: CompatMacros.h:171
std::map< MemKeyType, CLMemory * > CLMemoryMap
Definition: CLMemoryAssistant.h:71
bool keyExist(MemKeyType const &key)
keyExist Returns true if the given key exists in this instance
Definition: CLMemoryAssistant.h:120
Wrapper for an OpenCL Buffer.
Definition: CLBuffer.h:52
CLDeviceContext m_context
device context used
Definition: CLMemoryAssistant.h:142
depth
determines the pixel type of an image (8Bit-int or 32Bit-float)
Definition: Types.h:60
The CLDeviceContext class allows preparation of the device used for CLPrograms.
Definition: CLDeviceContext.h:61
std::string MemKeyType
Definition: CLMemoryAssistant.h:70
Wrapper for an OpenCL Image2D.
Definition: CLImage2D.h:57
CLMemoryMap m_memory_map
the map for internal storage
Definition: CLMemoryAssistant.h:144
CLDeviceContext const & getDeviceContext()
getDeviceContext returns the used device context that can be shared with CLProgram instances
Definition: CLMemoryAssistant.h:137
The CLMemory class is a base class for CLBuffer and CLImage2D.
Definition: CLMemory.h:48
The CLMemoryAssistant class is a helper class to maintain buffers and images for opencl-program pipel...
Definition: CLMemoryAssistant.h:53