ASL 0.1.7
Advanced Simulation Library
Loading...
Searching...
No Matches
testVectorOfElements.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
28#include "acl/acl.h"
29#include "utilities/aslUValue.h"
30#include "acl/aclGenerators.h"
31#include "acl/Kernels/aclKernel.h"
32#include <acl/aclMath/aclVectorOfElements.h>
33#include "aslUtilities.h"
34#include <math.h>
35
36using namespace asl;
37using namespace acl;
38using namespace std;
39
41{
42 cout << "Test of \"Simple kernel\" function..." << flush;
43
48
49 Kernel k;
50 {
51 using namespace elementOperators;
52 k << (vec0=generateVEConstant(0.1f,1.f,2.f));
53 k << (vec1=generateVEConstant(0.f,1.f,2.f)*vec0+generateVEConstant(1.f));
54 }
55 k.setup();
56 k.compute();
57
60 copy(vec0[0], output0);
61 copy(vec0[1], output1);
62 copy(vec0[2], output2);
63 copy(vec1[0], output3);
64
65 bool status(output0[9]<0.101 && output1[2] ==1 && output2[5] ==2. && output3[1] ==6.);
67
68 return status;
69}
70
71
73{
74 cout << "Test of advanced operations..." << flush;
77 VectorOfElements res(2);
80
85 copy(generateVEData<int>(11, 2), res);
88
91 vector<cl_int> expected0({10, 10, 10, 10, 10, 10, -4, -4, -4, -4, -4});
92 vector<cl_int> expected1({12, 12, 12, 12, 12, 12, -4, -4, -4, -4, -4});
93
94
95 Kernel k;
96 {
97 k << (res = select(vec0 + vec1, vec0 - vec1, ind > c));
98 }
99 k.setup();
100 k.compute();
101
102 copy(res[0], output0);
103 copy(res[1], output1);
104
107
108 return status;
109}
110
111
112int main()
113{
114 bool allTestsPassed(true);
115
118
120}
OpenCl Kernel generator.
Definition aclKernel.h:49
void setup()
void compute()
The class represents several Element.
Updatable value. This class stores value and its TimeStamp.
Definition aslUValue.h:35
std::shared_ptr< T > p
Definition aslUValue.h:37
SPDataWrapperACLData generateDataContainerACL_SP(const Block &b, unsigned int n=1)
generates pointer to ACL Data field with n components
void errorMessage(cl_int status, const char *errorMessage)
Prints errorMessage and exits depending on the status.
VectorOfElements generateVEConstant(T a)
Generates VectorOfElements with 1 Element acl::Constant with value a.
VectorOfElements generateVEVariableSP(std::shared_ptr< T > a)
Generates VectorOfElements with 1 Element acl::VariableReference with reference on a.
VectorOfElements generateVEIndex(unsigned int size=0)
Advanced Computational Language.
Definition acl.h:41
void copy(MemBlock &source, T *destination)
Advanced Simulation Library.
Definition aslDataInc.h:31
STL namespace.
bool testAdvancedOperations()
bool testSimpleKernel()
int main()