Debian Codegraph @

src/acl/Kernels/aclKernelMerger.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 ACLKERNELMERGER_H
25 #define ACLKERNELMERGER_H
26
27 #include <memory>
28 #include <vector>
29
30 namespace acl
31 {
32 class ElementBase;
33 typedef std::shared_ptr<ElementBase> Element;
34 class Kernel;
35 typedef std::shared_ptr<Kernel> SPKernel;
36
37 /// OpenCl Kernel merger
38 /**
39 \ingroup KernelGen
40 The KernelMerger generates a big kernel containing differen
41 kernels. The number of copies is a sum of all kernels and
42 it realizes tree like "if" "else" structure in order to execute
43 different kernels
44 */
45 class KernelMerger
46 {
47 private:
48 std::vector<SPKernel> kernels;
49 SPKernel kernel;
50 unsigned int size;
51 std::vector<unsigned int> offsets;
52
53 unsigned int getKernelSize(unsigned int i);
54 void checkKernelsCompatibility();
55 void computeOffsets();
56 Element castSpliter(unsigned int i1, unsigned int i2);
57 public:
58 KernelMerger();
59 void setup();
60 void compute();
61 std::string getKernelSource();
62 /// removes all kernels
63 void clear();
64 void addKernel(SPKernel k);
65 void addKernel(const KernelMerger & km);
66 unsigned int getSize();
67 };
68
69 /// \related Kernel
70 typedef std::shared_ptr<KernelMerger> SPKernelMerger;
71
72
73
74 } // namespace acl
75
76 #endif // ACLKERNELMERGER_H