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
Map.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 MAP_H_
41 #define MAP_H_
42 
43 #include <istream>
44 #include <string>
45 
46 #include "detail/MapHelper.h"
47 #include "detail/Skeleton.h"
48 #include "detail/skelclDll.h"
49 
50 namespace skelcl {
51 
54 class Index;
55 class IndexPoint;
56 class Source;
57 template <typename> class Out;
58 namespace detail { class Program; }
59 
60 template<typename> class Map;
62 
94 
99 //
129 template<typename Tin, typename Tout>
130 class Map<Tout(Tin)> : public detail::Skeleton,
131  private detail::MapHelper<Tout(Tin)> {
132 public:
141  Map<Tout(Tin)>(const Source& source,
142  const std::string& funcName = std::string("func"));
143 
164  template <template <typename> class C,
165  typename... Args>
166  C<Tout> operator()(const C<Tin>& input,
167  Args&&... args) const;
168 
196  template <template <typename> class C,
197  typename... Args>
198  C<Tout>& operator()(Out<C<Tout>> output,
199  const C<Tin>& input,
200  Args&&... args) const;
201 
202 private:
203  template <template <typename> class C,
204  typename... Args>
205  void execute(C<Tout>& output,
206  const C<Tin>& input,
207  Args&&... args) const;
208 
209  detail::Program createAndBuildProgram(const std::string& source,
210  const std::string& funcName) const;
211 };
212 
245 template<typename Tin>
246 class Map<void(Tin)> : public detail::Skeleton,
247  private detail::MapHelper<void(Tin)> {
248 public:
257  Map<void(Tin)>(const Source& source,
258  const std::string& funcName = std::string("func"));
259 
273  template <template <typename> class C,
274  typename... Args>
275  void operator()(const C<Tin>& input,
276  Args&&... args) const;
277 
278 private:
279  template <template <typename> class C,
280  typename... Args>
281  void execute(const C<Tin>& input,
282  Args&&... args) const;
283 
284  detail::Program createAndBuildProgram(const std::string& source,
285  const std::string& funcName) const;
286 };
287 
320 template<typename Tout>
321 class Map<Tout(Index)> : public detail::Skeleton,
322  private detail::MapHelper<Tout(Index)> {
323 public:
332  Map<Tout(Index)>(const Source& source,
333  const std::string& funcName = std::string("func"));
334 
352  template <typename... Args>
353  Vector<Tout> operator()(const Vector<Index>& input,
354  Args&&... args) const;
355 
380  template <typename... Args>
381  Vector<Tout>& operator()(Out<Vector<Tout>> output,
382  const Vector<Index>& input,
383  Args&&... args) const;
384 
385 private:
386  template <typename... Args>
387  void execute(Vector<Tout>& output,
388  const Vector<Index>& input,
389  Args&&... args) const;
390 
391  detail::Program createAndBuildProgram(const std::string& source,
392  const std::string& funcName) const;
393 };
394 
426 template<>
427 class SKELCL_DLL Map<void(Index)> : public detail::Skeleton,
428  private detail::MapHelper<void(Index)> {
429 public:
438  Map(const Source& source, const std::string& funcName = std::string("func"));
439 
452  template <typename... Args>
453  void operator()(const Vector<Index>& input,
454  Args&&... args) const;
455 
456 private:
457  template <typename... Args>
458  void execute(const Vector<Index>& input,
459  Args&&... args) const;
460 
461  detail::Program createAndBuildProgram(const std::string& source,
462  const std::string& funcName) const;
463 };
464 
497 template<typename Tout>
498 class Map<Tout(IndexPoint)> : public detail::Skeleton,
499  private detail::MapHelper<Tout(IndexPoint)> {
500 public:
509  Map<Tout(IndexPoint)>(const Source& source,
510  const std::string& funcName = std::string("func"));
511 
529  template <typename... Args>
530  Matrix<Tout> operator()(const Matrix<IndexPoint>& input,
531  Args&&... args) const;
532 
557  template <typename... Args>
558  Matrix<Tout>& operator()(Out<Matrix<Tout>> output,
559  const Matrix<IndexPoint>& input,
560  Args&&... args) const;
561 
562 private:
563  template <typename... Args>
564  void execute(Matrix<Tout>& output,
565  const Matrix<IndexPoint>& input,
566  Args&&... args) const;
567 
568  detail::Program createAndBuildProgram(const std::string& source,
569  const std::string& funcName) const;
570 };
571 
603 template<>
604 class SKELCL_DLL Map<void(IndexPoint)>
605  : public detail::Skeleton, private detail::MapHelper<void(IndexPoint)> {
606 public:
615  Map(const Source& source, const std::string& funcName = std::string("func"));
616 
629  template <typename... Args>
630  void operator()(const Matrix<IndexPoint>& input,
631  Args&&... args) const;
632 
633 private:
634  template <typename... Args>
635  void execute(const Matrix<IndexPoint>& input,
636  Args&&... args) const;
637 
638  detail::Program createAndBuildProgram(const std::string& source,
639  const std::string& funcName) const;
640 };
641 
642 } // namespace skelcl
643 
644 // including the definition of the templates
645 #include "detail/MapDef.h"
646 
647 #endif // MAP_H_
This version of the Map skeleton is executed over an two-dimensional index space defined b...
Definition: Map.h:498
The Matrix class is a two dimensional container which makes its data accessible on the host as well a...
Definition: Matrix.h:190
This class is a unified wrapper for defining source code in SkelCL.
Definition: Source.h:61
This class implements the Map skeleton, which describes calculations performed on one or more devices...
Definition: Map.h:130
The Vector class is a one dimensional container which makes its data accessible on the host as well a...
Definition: Vector.h:113
This class defines an two-dimensional IndexPoint, i.e. a pair of unsigned integers representing a val...
Definition: Index.h:128
This class defines an Index, i.e. an unsigned integer representing a value in a one-dimensional index...
Definition: Index.h:54
This version of the Map skeleton is executed over an one-dimensional index space defined b...
Definition: Map.h:321
This version of the Map skeleton is used, when the user-defined function has the return ty...
Definition: Map.h:246
The IndexVector (a.k.a. Vector) class is a special implementation of a Vector with Elements of...
Definition: IndexVector.h:72
The IndexMatrix (a.k.a. Matrix) class is a special implementation of a Matrix with Elemen...
Definition: IndexMatrix.h:73