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
Zip.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 ZIP_H_
41 #define ZIP_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 
56 template<typename> class Zip;
58 
68 
96 template<typename Tleft,
97  typename Tright,
98  typename Tout>
99 class Zip<Tout(Tleft, Tright)> : public detail::Skeleton {
100 public:
110  Zip<Tout(Tleft, Tright)>(const Source& source,
111  const std::string& funcName
112  = std::string("func"));
113 
151  template <template <typename> class C,
152  typename... Args>
153  C<Tout> operator()(const C<Tleft>& left,
154  const C<Tright>& right,
155  Args&&... args);
156 
200  template <template <typename> class C,
201  typename... Args>
202  C<Tout>& operator()(Out<C<Tout>> output,
203  const C<Tleft>& left,
204  const C<Tright>& right,
205  Args&&... args);
206 
212  const std::string& source() const;
213 
219  const std::string& func() const;
220 
221 private:
222  template <template <typename> class C,
223  typename... Args>
224  void execute(C<Tout>& output,
225  const C<Tleft>& left,
226  const C<Tright>& right,
227  Args&&... args);
228 
229  template <template <typename> class C>
230  void prepareInput(const C<Tleft>& left,
231  const C<Tright>& right);
232 
233  template <template <typename> class C>
234  void prepareOutput(C<Tout>& output,
235  const C<Tleft>& left,
236  const C<Tright>& right);
237 
238  detail::Program createAndBuildProgram(const std::string& source,
239  const std::string& funcName) const;
240 
241  const std::string _source;
242  const std::string _funcName;
243  const detail::Program _program;
244 };
245 
273 template<typename Tleft,
274  typename Tright>
275 class Zip<void(Tleft, Tright)> : public detail::Skeleton {
276 public:
286  Zip<void(Tleft, Tright)>(const Source& source,
287  const std::string& funcName
288  = std::string("func"));
289 
326  template <template <typename> class C,
327  typename... Args>
328  void operator()(const C<Tleft>& left,
329  const C<Tright>& right,
330  Args&&... args);
331 
332 private:
333  template <template <typename> class C,
334  typename... Args>
335  void execute(const C<Tleft>& left,
336  const C<Tright>& right,
337  Args&&... args);
338 
339  template <template <typename> class C>
340  void prepareInput(const C<Tleft>& left,
341  const C<Tright>& right);
342 
343  detail::Program createAndBuildProgram(const std::string& source,
344  const std::string& funcName) const;
345 
346  const detail::Program _program;
347 };
348 
349 // TODO: when template aliases are available:
350 // template<typename T>
351 // using Zip = Zip<T(T, T)>;
352 
353 } // namespace skelcl
354 
355 #include "detail/ZipDef.h"
356 
357 #endif // ZIP_H_
358 
This class is a unified wrapper for defining source code in SkelCL.
Definition: Source.h:61
An instance of the Zip class describes a calculation which can be performed on one or more devices...
Definition: Zip.h:99
An instance of the Zip class describes a calculation which can be performed on one or more devices...
Definition: Zip.h:275