Debian Codegraph @

src/acl/aclMath/aclReductionAlgGenerator.h

raw
1 /*
2 * Advanced Simulation Library <http://asl.org.il>
3 *
4 * Copyright 2015 Avtech Scientific <http://avtechscientific.com>
5 *
6 *
7 * This file is part of Advanced Simulation Library (ASL).
8 *
9 * ASL is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU Affero General Public License as
11 * published by the Free Software Foundation, version 3 of the License.
12 *
13 * ASL is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with ASL. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23
24 #ifndef ACLREDUCTIONALGGENERATUR_H
25 #define ACLREDUCTIONALGGENERATUR_H
26
27 #include "aclVectorOfElementsDef.h"
28 #include <math/aslVectors.h>
29 #include <utilities/aslUValue.h>
30
31
32 namespace acl
33 {
34 class Kernel;
35 enum ReductionOperatorType {ROT_SUM, ROT_PRODUCT, ROT_MINIMUM, ROT_MAXIMUM};
36
37 /// The class generates code corresponding to a reduction operation of elements
38 /**
39 \ingroup ComplexDataTypes
40 */
41 template <typename ResType, enum ReductionOperatorType Op> class ReductionAlgGenerator
42 {
43 private:
44 VectorOfElements ve;
45 unsigned int nGroups;
46 unsigned int nLocal;
47 public:
48 asl::UValue<asl::AVec<ResType>> res;
49 private:
50 std::vector<std::vector<ResType>> groupRes;
51 VectorOfElementsData groupResACL;
52
53 shared_ptr<Kernel> kernel;
54
55 public:
56 ReductionAlgGenerator(VectorOfElements v);
57 void compute();
58 void generateAlg(Kernel & k);
59 void generateAlg();
60 };
61
62 template <typename ResType> std::shared_ptr<ReductionAlgGenerator<ResType, ROT_SUM>>
63 generateSumAlg(VectorOfElements v);
64
65 template <typename ResType> std::shared_ptr<ReductionAlgGenerator<ResType, ROT_MINIMUM>>
66 generateMinAlg(VectorOfElements v);
67
68 template <typename ResType> std::shared_ptr<ReductionAlgGenerator<ResType, ROT_MAXIMUM>>
69 generateMaxAlg(VectorOfElements v);
70
71 template <typename ResType> std::shared_ptr<ReductionAlgGenerator<ResType, ROT_PRODUCT>>
72 generateProductAlg(VectorOfElements v);
73
74
75 } //namespace acl
76
77 #endif // ACLREDUCTIONALGGENERATUR_H