ASL 0.1.7
Advanced Simulation Library
Loading...
Searching...
No Matches
testKernelMerger.cc
Go to the documentation of this file.
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
29#include "acl/acl.h"
34#include "aslUtilities.h"
35#include <math.h>
36#include <initializer_list>
37
38using namespace acl;
39using namespace std;
40
42{
43 cout << "Test of \"KernelMerger\" functionality..." << flush;
44 ElementData vec0(new Array<cl_float> (10));
45 ElementData vec1(new Array<cl_float> (5));
46 ElementData vec2(new Array<cl_float> (8));
47 ElementData vec3(new Array<cl_float> (20));
48
53
54 SPKernel k0(new Kernel());
55 SPKernel k1(new Kernel());
56 SPKernel k2(new Kernel());
57 SPKernel k3(new Kernel());
58 {
59 using namespace elementOperators;
60 k0->addExpression(operatorAssignment (vec0, c0));
61 k1->addExpression(operatorAssignment (vec1, c1));
62 k2->addExpression(operatorAssignment (vec2, c2));
63 k3->addExpression(operatorAssignment (vec3, c3));
64 }
65
66 KernelMerger km;
67 km.addKernel(k0);
68 km.addKernel(k1);
69 km.addKernel(k2);
70// km.addKernel(k3);
71
72 km.setup();
73 km.compute();
74
75 bool status((acl::map<float>(vec0).get()[9] == 2) &&
76 (acl::map<float>(vec1).get()[3] == 1) &&
77 (acl::map<float>(vec2).get()[7] == 4));// &&
78// (acl::map<float>(vec3).get()[19] == 7));
79 errorMessage(status);
80 cout << km.getKernelSource() << endl;
81 return status;
82}
83
84int main()
85{
86 bool allTestsPassed(true);
87
88 allTestsPassed &= testKernelMerger();
89
90 return allTestsPassed ? EXIT_SUCCESS : EXIT_FAILURE;
91}
useful common utilities
Global array.
Definition: aclArray.h:37
OpenCl Kernel generator.
Definition: aclKernel.h:49
OpenCl Kernel merger.
std::string getKernelSource()
void addKernel(SPKernel k)
void errorMessage(cl_int status, const char *errorMessage)
Prints errorMessage and exits depending on the status.
Advanced Computational Language.
Definition: acl.h:41
std::shared_ptr< MemBlock > ElementData
Definition: acl.h:48
std::shared_ptr< Kernel > SPKernel
std::shared_ptr< ElementBase > Element
Definition: acl.h:49
STL namespace.
bool testKernelMerger()
int main()