Muesli
 All Classes Namespaces Files Functions Typedefs Enumerations
functors.h
1 /*
2  * functors.h
3  *
4  * Author: Steffen Ernsting <s.ernsting@uni-muenster.de>
5  *
6  * -------------------------------------------------------------------------------
7  *
8  * The MIT License
9  *
10  * Copyright 2014 Steffen Ernsting <s.ernsting@uni-muenster.de>,
11  * Herbert Kuchen <kuchen@uni-muenster.de.
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a copy
14  * of this software and associated documentation files (the "Software"), to deal
15  * in the Software without restriction, including without limitation the rights
16  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17  * copies of the Software, and to permit persons to whom the Software is
18  * furnished to do so, subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be included in
21  * all copies or substantial portions of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29  * THE SOFTWARE.
30  *
31  */
32 
33 #pragma once
34 
35 #include "argtype.h"
36 #include "functor_base.h"
37 #include "lmatrix.h"
38 
39 namespace msl {
40 
48 template <typename T, typename R>
50 {
51 public:
59  MSL_USERFUNC
60  virtual R operator() (T value) const = 0;
61 
65  virtual ~MMapFunctor()
66  {
67  }
68 };
69 
77 template <typename T, typename R>
79 {
80 public:
90  MSL_USERFUNC
91  virtual R operator() (int rowIndex, int colIndex, T value) const = 0;
92 
97  {
98  }
99 };
100 
101 template <typename T>
102 class PLMatrix;
103 
111 template <typename T, typename R>
113 {
114 public:
121  : stencil_size(1)
122  {
123  this->setTileWidth(msl::DEFAUL_TILE_WIDTH);
124  }
125 
135  MSL_USERFUNC
136  virtual R operator() (int rowIndex, int colIndex, const PLMatrix<T>& input) const = 0;
137 
144  {
145  return stencil_size;
146  }
147 
153  void setStencilSize(int value)
154  {
155  stencil_size = value;
156  }
157 
162  {
163  }
164 
165 protected:
166  int stencil_size;
167 };
168 
177 template <typename T1, typename T2, typename R>
179 {
180 public:
189  MSL_USERFUNC
190  virtual R operator() (T1 l_value, T2 r_value) const = 0;
191 
195  virtual ~MZipFunctor()
196  {
197  }
198 };
199 
208 template <typename T1, typename T2, typename R>
210 {
211 public:
222  MSL_USERFUNC
223  virtual R operator() (int rowIndex, int colIndex, T1 l_value, T2 r_value) const = 0;
224 
229  {
230  }
231 };
232 
240 template <typename T, typename R>
242 {
243 public:
252  MSL_USERFUNC
253  virtual R operator() (T value1, T value2) const = 0;
254 
258  virtual ~MFoldFunctor()
259  {
260  }
261 };
262 
270 template <typename T, typename R>
272 {
273 public:
281  MSL_USERFUNC
282  virtual R operator() (T value) const = 0;
283 
287  virtual ~AMapFunctor()
288  {
289  }
290 };
291 
299 template <typename T, typename R>
301 {
302 public:
311  MSL_USERFUNC
312  virtual R operator() (int index, T value) const = 0;
313 
318  {
319  }
320 };
321 
322 template <typename T>
323 class PLArray;
324 
332 template <typename T, typename R>
334 {
335 public:
342  : stencil_size(1)
343  {
344  this->setTileWidth(msl::DEFAUL_TILE_WIDTH);
345  }
346 
355  MSL_USERFUNC
356  virtual R operator() (int index, const PLArray<T>& input) const = 0;
357 
364  {
365  return stencil_size;
366  }
367 
373  void setStencilSize(int value)
374  {
375  stencil_size = value;
376  }
377 
382  {
383  }
384 protected:
385  int stencil_size;
386 };
387 
396 template <typename T1, typename T2, typename R>
398 {
399 public:
408  MSL_USERFUNC
409  virtual R operator() (T1 l_value, T2 r_value) const = 0;
410 
414  virtual ~AZipFunctor()
415  {
416  }
417 };
418 
427 template <typename T1, typename T2, typename R>
429 {
430 public:
440  MSL_USERFUNC
441  virtual R operator() (int index, T1 l_value, T2 r_value) const = 0;
442 
447  {
448  }
449 };
450 
458 template <typename T, typename R>
460 {
461 public:
470  MSL_USERFUNC
471  virtual R operator() (T value1, T value2) const = 0;
472 
476  virtual ~AFoldFunctor()
477  {
478  }
479 };
480 
487 template <typename T, typename R>
489 {
490 public:
498  MSL_USERFUNC
499  virtual R operator() (T value) const = 0;
500 
504  virtual ~FarmFunctor()
505  {
506  }
507 };
508 
509 } // namespace msl
virtual ~MZipFunctor()
Destructor.
Definition: functors.h:195
virtual ~MMapFunctor()
Destructor.
Definition: functors.h:65
virtual MSL_USERFUNC R operator()(int rowIndex, int colIndex, T value) const =0
Function call operator has to be implemented by the user. Here, the actual function is implemented...
virtual MSL_USERFUNC R operator()(T value) const =0
Function call operator has to be implemented by the user. Here, the actual function is implemented...
Class MZipFunctor represents a functor for the zip skeleton of the distributed matrix.
Definition: functors.h:178
virtual MSL_USERFUNC R operator()(T value1, T value2) const =0
Function call operator has to be implemented by the user. Here, the actual function is implemented...
Class AZipIndexFunctor represents a functor for the zipIndex skeleton of the distributed array...
Definition: functors.h:428
Class ArrayFunctorBase represents the base class for all functors to be used with any distributed arr...
Definition: functor_base.h:168
int getStencilSize()
Returns the stencil size.
Definition: functors.h:363
Class MMapIndexFunctor represents a functor for the mapIndex skeleton of the distributed matrix...
Definition: functors.h:78
void setTileWidth(int value)
Sets the tile width.
Definition: functor_base.h:99
virtual MSL_USERFUNC R operator()(int index, T value) const =0
Function call operator has to be implemented by the user. Here, the actual function is implemented...
virtual MSL_USERFUNC R operator()(T value) const =0
Function call operator has to be implemented by the user. Here, the actual function is implemented...
virtual MSL_USERFUNC R operator()(int index, const PLArray< T > &input) const =0
Function call operator has to be implemented by the user. Here, the actual function is implemented...
Class MatrixFunctorBase represents the base class for all functors to be used with any distributed ma...
Definition: functor_base.h:141
Class PLArray represents a padded local array (partition). It serves as input for the mapStencil skel...
Definition: functors.h:323
Class AZipFunctor represents a functor for the zip skeleton of the distributed array.
Definition: functors.h:397
Class AFoldFunctor represents a functor for the fold skeleton of the distributed array.
Definition: functors.h:459
virtual MSL_USERFUNC R operator()(T1 l_value, T2 r_value) const =0
Function call operator has to be implemented by the user. Here, the actual function is implemented...
virtual MSL_USERFUNC R operator()(T1 l_value, T2 r_value) const =0
Function call operator has to be implemented by the user. Here, the actual function is implemented...
virtual ~AFoldFunctor()
Destructor.
Definition: functors.h:476
virtual MSL_USERFUNC R operator()(int index, T1 l_value, T2 r_value) const =0
Function call operator has to be implemented by the user. Here, the actual function is implemented...
Class MMapStencilFunctor represents a functor for the mapStencil skeleton of the distributed matrix...
Definition: functors.h:112
virtual ~AMapIndexFunctor()
Destructor.
Definition: functors.h:317
virtual MSL_USERFUNC R operator()(int rowIndex, int colIndex, const PLMatrix< T > &input) const =0
Function call operator has to be implemented by the user. Here, the actual function is implemented...
virtual ~FarmFunctor()
Destructor.
Definition: functors.h:504
Class PLMatrix represents a padded local matrix (partition). It serves as input for the mapStencil sk...
Definition: functors.h:102
void setStencilSize(int value)
Sets the stencil size.
Definition: functors.h:373
Class MFoldFunctor represents a functor for the fold skeleton of the distributed matrix.
Definition: functors.h:241
Class AMapIndexFunctor represents a functor for the mapIndex skeleton of the distributed array...
Definition: functors.h:300
virtual MSL_USERFUNC R operator()(T value) const =0
Function call operator has to be implemented by the user. Here, the actual function is implemented...
int getStencilSize()
Returns the stencil size.
Definition: functors.h:143
virtual MSL_USERFUNC R operator()(int rowIndex, int colIndex, T1 l_value, T2 r_value) const =0
Function call operator has to be implemented by the user. Here, the actual function is implemented...
Class MMapFunctor represents a functor for the map skeleton of the distributed matrix.
Definition: functors.h:49
virtual ~MFoldFunctor()
Destructor.
Definition: functors.h:258
virtual ~AZipFunctor()
Destructor.
Definition: functors.h:414
virtual ~AMapFunctor()
Destructor.
Definition: functors.h:287
virtual ~MMapIndexFunctor()
Destructor.
Definition: functors.h:96
virtual ~AMapStencilFunctor()
Destructor.
Definition: functors.h:381
virtual MSL_USERFUNC R operator()(T value1, T value2) const =0
Function call operator has to be implemented by the user. Here, the actual function is implemented...
MMapStencilFunctor()
Default Constructor.
Definition: functors.h:120
Class FarmFunctor represents a functor for the farm skeleton.
Definition: functors.h:488
virtual ~MZipIndexFunctor()
Destructor.
Definition: functors.h:228
Class AMapFunctor represents a functor for the fold skeleton of the distributed array.
Definition: functors.h:271
Class AMapStencilFunctor represents a functor for the mapStencil skeleton of the distributed array...
Definition: functors.h:333
AMapStencilFunctor()
Default Constructor.
Definition: functors.h:341
virtual ~MMapStencilFunctor()
Destructor.
Definition: functors.h:161
Class MZipIndexFunctor represents a functor for the zipIndex skeleton of the distributed matrix...
Definition: functors.h:209
void setStencilSize(int value)
Sets the stencil size.
Definition: functors.h:153
Class FarmFunctorBase represents the base class for all functors to be used with the farm skeleton...
Definition: functor_base.h:191
virtual ~AZipIndexFunctor()
Destructor.
Definition: functors.h:446