ASL 0.1.7
Advanced Simulation Library
Loading...
Searching...
No Matches
testASLData.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 "acl/aclGenerators.h"
30#include "acl/DataTypes/aclGroupID.h"
31#include "acl/DataTypes/aclConstant.h"
32#include "aslGenerators.h"
33#include "aslUtilities.h"
34#include "acl/Kernels/aclKernel.h"
35#include "data/aslDataUtilities.h"
36#include <acl/aclMath/aclVectorOfElements.h>
37#include <data/aslDataWithGhostNodes.h>
38
39using namespace acl;
40using namespace asl;
41using namespace std;
42
44{
45 Block bl(makeAVec(10,5),0.1);
48
49 Kernel k;
50
51 k<<(a->getEContainer()=acl::generateVEConstant<double>(0));
52 k<<(b->getEContainer()=acl::generateVEConstant<double>(0));
53
54 k.setup();
56
57 return true;
58}
59
60
62{
63 Block bl(makeAVec(10,5),0.1);
65
66 initData(a->getEContainer(),acl::generateVEConstant<double>(0));
67
68 return true;
69}
70
71
73{
74 cout << "Test of UploadToLocalMem()..." << flush;
75
76 unsigned int componentsNum = 2;
77 unsigned int groupSize = 27;
79 kConf.local = true;
80 Kernel kernel(kConf);
81 Element groupID(new GroupID());
83
85 // dx = 1
87
88 // boundary = 0
91 0u));
92 // initialize source with value "13"
94 13));
95
96 // boundary = 0
97 auto destination(asl::generateDataContainerACL_SP<float>(block,
99 0u));
100 // initialize source with value "27"
101 acl::initData(destination->getEContainer(), acl::generateVEConstantN(componentsNum,
102 27));
103
104
106
109 unsigned int groupsNumber = totalSize / portionSize;
111 kernel.setGroupsNumber(groupsNumber);
112
115
116 using namespace elementOperators;
117 kernel.addExpression(barrier("CLK_LOCAL_MEM_FENCE | CLK_GLOBAL_MEM_FENCE"));
118 // overwrite destination with localSource
119 for (unsigned int i = 0; i < componentsNum; ++i)
120 kernel.addExpression(syncCopy(localSource[i], destination->getEContainer()[i],
122
123 kernel.setup();
124 kernel.compute();
125
126
127 bool status(true);
130 for (unsigned int i = 0; i < componentsNum; ++i)
131 {
132 copy(source->getEContainer()[i], src);
133 copy(destination->getEContainer()[i], dst);
134
135 cout << src << endl << endl << dst << endl;
136
137 status &= (src == dst);
138 }
139
141
142 return status;
143}
144
void addExpression(Element expression_)
ACL Kernel configuration class.
OpenCl Kernel generator.
Definition aclKernel.h:49
std::string getKernelSource()
void setGroupsNumber(unsigned int n)
void setup()
void compute()
The class represents several Element.
SPDataWrapperACLData generateDataContainerACL_SP(const Block &b, unsigned int n=1)
generates pointer to ACL Data field with n components
acl::VectorOfElements uploadToLocalMem(AbstractData &source, const AVec< int > &size, unsigned int groupSize, acl::Kernel &kernel)
void errorMessage(cl_int status, const char *errorMessage)
Prints errorMessage and exits depending on the status.
const KernelConfiguration KERNEL_BASIC
void initData(Element a, Element initializationValue, const KernelConfiguration &kernelConfig=KERNEL_BASIC)
VectorOfElements generateVEConstantN(unsigned int n, T a)
Generates VectorOfElements with n Elements acl::Constant with values a.
Advanced Computational Language.
Definition acl.h:41
void copy(MemBlock &source, T *destination)
std::shared_ptr< ElementBase > Element
Definition acl.h:49
Advanced Simulation Library.
Definition aslDataInc.h:31
AVec< T > makeAVec(T a1)
T productOfElements(const AVec< T > &a)
STL namespace.
bool testInitData()
bool testSimpleKernel()
bool testUploadToLocalMem()
int main()
const acl::KernelConfiguration & kConf(acl::KERNEL_BASIC)