SkelCL
SkelCL is a high level multi GPU skeleton library developed at the university of Münster, Germany.
 All Classes Namespaces Files Functions Variables Typedefs Groups
Scan.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2011-2012 The SkelCL Team as listed in CREDITS.txt *
3  * http://skelcl.uni-muenster.de *
4  * *
5  * This file is part of SkelCL. *
6  * SkelCL is available under multiple licenses. *
7  * The different licenses are subject to terms and condition as provided *
8  * in the files specifying the license. See "LICENSE.txt" for details *
9  * *
10  *****************************************************************************
11  * *
12  * SkelCL is free software: you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation, either version 3 of the License, or *
15  * (at your option) any later version. See "LICENSE-gpl.txt" for details. *
16  * *
17  * SkelCL is distributed in the hope that it will be useful, *
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20  * GNU General Public License for more details. *
21  * *
22  *****************************************************************************
23  * *
24  * For non-commercial academic use see the license specified in the file *
25  * "LICENSE-academic.txt". *
26  * *
27  *****************************************************************************
28  * *
29  * If you are interested in other licensing models, including a commercial- *
30  * license, please contact the author at michel.steuwer@uni-muenster.de *
31  * *
32  *****************************************************************************/
33 
39 
40 #ifndef SCAN_H_
41 #define SCAN_H_
42 
43 #include <istream>
44 #include <string>
45 
46 #include "detail/Skeleton.h"
47 #include "detail/Program.h"
48 
49 namespace skelcl {
50 
53 class Source;
54 template <typename> class Out;
55 template <typename> class Vector;
56 
57 template<typename> class Scan;
59 
70 
80 template<typename T>
81 class Scan<T(T)> : public detail::Skeleton {
82 public:
97  Scan(const Source& source,
98  const std::string& id = "0",
99  const std::string& funcName = std::string("func"));
100 
119  template <typename... Args>
120  Vector<T> operator()(const Vector<T>& input, Args&&... args);
121 
146  template <typename... Args>
147  Vector<T>& operator()(Out<Vector<T>> output,
148  const Vector<T>& input,
149  Args&&... args);
150 
151 private:
152  template <typename... Args>
153  void execute(Vector<T>& output,
154  const Vector<T>& input,
155  Args&&... args);
156 
157  size_t calculateNumberOfPasses(size_t workGroupSize,
158  size_t elements) const;
159 
160  std::vector<detail::DeviceBuffer>
161  createImmediateBuffers(size_t passes,
162  size_t wgSize,
163  size_t elements,
164  const detail::Device::ptr_type& devicePtr);
165 
166  void performScanPasses(size_t passes,
167  size_t wgSize,
168  const detail::Device::ptr_type& devicePtr,
169  const std::vector<detail::DeviceBuffer>& tmpBuffers,
170  const detail::DeviceBuffer& inputBuffer,
171  const detail::DeviceBuffer& outputBuffer);
172 
173  void performUniformCombination(size_t passes,
174  size_t wgSize,
175  const detail::Device::ptr_type& devicePtr,
176  const std::vector<detail::DeviceBuffer>&
177  tmpBuffers,
178  const detail::DeviceBuffer& outputBuffer);
179 
180  void prepareInput(const Vector<T>& input);
181 
182  void prepareOutput(Vector<T>& output,
183  const Vector<T>& input);
184 
185  detail::Program createAndBuildProgram(const std::string& source,
186  const std::string& id,
187  const std::string& funcName) const;
188 
189  const detail::Program _program;
190 };
191 
192 } // namespace skelcl
193 
194 #include "detail/ScanDef.h"
195 
196 #endif // Scan_H_
197 
This class is a unified wrapper for defining source code in SkelCL.
Definition: Source.h:61
The Vector class is a one dimensional container which makes its data accessible on the host as well a...
Definition: Vector.h:113