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
Reduce.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 REDUCE_H_
41 #define REDUCE_H_
42 
43 #include <istream>
44 #include <memory>
45 #include <string>
46 
47 #include "Source.h"
48 
49 #include "detail/Program.h"
50 #include "detail/Skeleton.h"
51 
52 namespace skelcl {
53 
56 template <typename> class Out;
57 template <typename> class Vector;
58 namespace detail { class DeviceList; }
59 
60 template <typename> class Reduce;
62 
72 
95 template <typename T>
96 class Reduce<T(T)> : public detail::Skeleton {
97 public:
112  Reduce(const Source& source, const std::string& id = "0",
113  const std::string& funcName = "func");
114 
133  template <typename... Args>
134  Vector<T> operator()(const Vector<T>& input, Args&&... args);
135 
160  template <typename... Args>
161  Vector<T>& operator()(Out<Vector<T>> output, const Vector<T>& input,
162  Args&&... args);
163 
169  std::string source() const;
170 
176  std::string func() const;
177 
183  std::string id() const;
184 
185 private:
186  void prepareInput(const Vector<T>& input);
187 
188  void prepareOutput(Vector<T>& output, const Vector<T>& input,
189  const size_t size);
190 
191  template <typename... Args>
192  void execute_first_step(const detail::Device& device,
193  const detail::DeviceBuffer& input,
194  detail::DeviceBuffer& output, size_t data_size,
195  size_t global_size, Args&&... args);
196 
197  template <typename... Args>
198  void execute_second_step(const detail::Device& device,
199  const detail::DeviceBuffer& input,
200  detail::DeviceBuffer& output, size_t data_size,
201  Args&&... args);
202 
203  skelcl::detail::Program createPrepareAndBuildProgram();
204 
207  std::string _id;
208 
210  std::string _funcName;
211 
213  std::string _userSource;
214 
216  skelcl::detail::Program _program;
217 };
218 
219 } // namespace skelcl
220 
221 #include "detail/ReduceDef.h"
222 
223 #endif // REDUCE_H_
224 
This class is a unified wrapper for defining source code in SkelCL.
Definition: Source.h:61
SKELCL_DLL detail::DeviceID device(size_t dID)
Creates an OpenCL device ID to be used as parameter of the init(detail::PlatformID, detail::DeviceID) function.
Definition: SkelCL.cpp:76
The Vector class is a one dimensional container which makes its data accessible on the host as well a...
Definition: Vector.h:113