46 #include <initializer_list> 56 cout <<
"Test of \"copy\" function..." <<
flush;
59 vector<cl_float> input(10, 3);
60 vector<cl_float> output(10, 1);
65 bool status(output[3] == 3);
74 cout <<
"Test of Kernel with double..." <<
flush;
85 using namespace elementOperators;
93 vector<cl_double> output0(10), output1(10);
97 bool status(output0[9]<10.1 && output1[2]>2-1e-4 && output1[3]<3+1e-4);
106 cout <<
"Test of KernelSIMD..." <<
flush;
111 vector<cl_float> input0(11, 3);
112 vector<cl_float> input1(11, 5);
113 vector<cl_float> output(11, 0);
114 vector<cl_float> expected({8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8});
120 using namespace elementOperators;
129 bool status(output == expected);
138 cout <<
"Test of KernelSIMDUA..." <<
flush;
143 vector<cl_float> input0(11, 3);
144 vector<cl_float> input1(11, 5);
145 vector<cl_float> output(11, 0);
146 vector<cl_float> expected({8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8});
154 using namespace elementOperators;
164 bool status(output == expected);
173 cout <<
"Test of kernel with PrivateVariable..." <<
flush;
179 vector<cl_float> input1(10, 3);
180 vector<cl_float> input2(10, 5);
181 vector<cl_float> output(10, 1);
188 using namespace elementOperators;
199 bool status(output[2] ==8.);
208 cout <<
"Test of kernel with PrivateArray..." <<
flush;
210 vector<cl_int> inputGaIn({0, 4, 5});
211 vector<cl_float> inputGaOut(3, 0);
212 vector<cl_float> inputPa({-9, 2, 0, 15, 1, 3});
213 vector<cl_float> output(3);
214 vector<cl_float> expected({-9, 1, 3});
221 copy(inputGaIn, gaIn);
226 using namespace elementOperators;
235 bool status(output == expected);
244 cout <<
"Test of Variable functionality..." <<
flush;
249 vector<cl_float> output(10, 1);
261 bool status(output[2] ==10.);
269 cout <<
"Test of VariableReference functionality..." <<
flush;
275 vector<cl_float> output(10, 1);
287 bool status(output[2] ==10.);
296 cout <<
"Test of select function..." <<
flush;
301 vector<cl_double> input(10, 3.);
302 vector<cl_double> output(10, 1.);
308 using namespace elementOperators;
321 bool status(output[2] ==9.);
330 cout <<
"Test of Subvector..." <<
flush;
331 cl_float init[] = {16, 2, 77, 29, 23, 16, 2, 77, 29, 23};
334 vector<cl_float> input(init, init +
sizeof(init) /
sizeof(cl_float) );
335 vector<cl_float> output(2);
339 copy(subvec0, output);
341 bool status(output[0]==16);
350 cout <<
"Test of Swap functionality..." <<
flush;
354 vector<cl_float> input0(10, 1);
355 vector<cl_float> input1(10, 2);
356 vector<cl_float> output(10, 10);
363 bool status(output[3] == 2);
372 cout <<
"Test of LocalArray and syncCopy with barrier()..." <<
flush;
377 unsigned int groupsNumber = 5;
378 unsigned int groupSize = 2;
388 vector<cl_float> input0(groupSize * groupsNumber, 3);
389 vector<cl_float> input1(groupSize * groupsNumber, 5);
390 vector<cl_float> output(groupSize * groupsNumber, 0);
391 vector<cl_float> expected({2, 2, 2, 2, 2, 2, 2, 2, 2, 2});
398 using namespace elementOperators;
412 bool status(output == expected);
422 bool allTestsPassed(
true);
437 return allTestsPassed ? EXIT_SUCCESS : EXIT_FAILURE;
const KernelConfiguration KERNEL_SIMD
void setGroupsNumber(unsigned int n)
Advanced Computational Language.
Element barrier(std::string flags="CLK_LOCAL_MEM_FENCE")
void errorMessage(cl_int status, const char *errorMessage)
Prints errorMessage and exits depending on the status.
Element operatorAssignmentSafe(Element e1, Element e2)
void addExpression(Element expression_)
Element operatorAssignment(Element e1, Element e2)
Element select(Element e1, Element e2, Element e3)
const KernelConfiguration KERNEL_SIMDUA
void swapBuffers(std::shared_ptr< Array< T > >a, std::shared_ptr< Array< T > > b)
bool testVariableReference()
ACL Kernel configuration class.
bool testPrivateVariable()
Element powI(Element a, unsigned int i)
std::shared_ptr< ElementBase > Element
const std::vector< TypeID > TYPE_SELECT
contains trasnlation of types necessery for use in the function select
const acl::KernelConfiguration & kConf(acl::KERNEL_BASIC)
Element convert(const TypeID tName, Element e1, bool strong=true)
void copy(MemBlock &source, T *destination)
Element syncCopy(Element source, Element destination, Element srcOffset, Element dstOffset, Element length)
const KernelConfiguration KERNEL_BASIC