#include "acl/acl.h"
#include "acl/DataTypes/aclIndex.h"
#include "acl/DataTypes/aclGroupID.h"
#include "acl/DataTypes/aclConstant.h"
#include "acl/DataTypes/aclVariable.h"
#include "acl/DataTypes/aclVariableReference.h"
#include "acl/DataTypes/aclPrivateVariable.h"
#include "acl/DataTypes/aclPrivateArray.h"
#include "acl/DataTypes/aclArray.h"
#include "acl/DataTypes/aclSubvector.h"
#include "acl/DataTypes/aclLocalArray.h"
#include "acl/Operators/aclElementFor.h"
#include "acl/Operators/aclElementIfElse.h"
#include "acl/Operators/aclElementExcerpt.h"
#include "acl/Kernels/aclKernel.h"
#include "aslUtilities.h"
#include <math.h>
#include <initializer_list>
#include <acl/Kernels/aclKernelConfigurationTemplates.h>
{
cout << "Test of \"copy\" function..." << flush;
vector<cl_float> input(10, 3);
vector<cl_float> output(10, 1);
copy(input, vec0);
copy(vec0, output);
bool status(output[3] == 3);
errorMessage(status);
return status;
}
{
cout << "Test of Kernel with double..." << flush;
{
using namespace elementOperators;
}
vector<cl_double> output0(10), output1(10);
bool status(output0[9]<10.1 && output1[2]>2-1e-4 && output1[3]<3+1e-4);
return status;
}
{
cout <<
"Test of KernelSIMD..." <<
flush;
vector<cl_float> input0(11, 3);
vector<cl_float> input1(11, 5);
vector<cl_float> output(11, 0);
vector<cl_float> expected({8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8});
{
using namespace elementOperators;
}
bool status(output == expected);
return status;
}
{
cout <<
"Test of KernelSIMDUA..." <<
flush;
vector<cl_float> input0(11, 3);
vector<cl_float> input1(11, 5);
vector<cl_float> output(11, 0);
vector<cl_float> expected({8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8});
{
using namespace elementOperators;
}
bool status(output == expected);
return status;
}
{
cout <<
"Test of kernel with PrivateVariable..." <<
flush;
vector<cl_float> input1(10, 3);
vector<cl_float> input2(10, 5);
vector<cl_float> output(10, 1);
{
using namespace elementOperators;
}
bool status(output[2] ==8.);
return status;
}
{
cout <<
"Test of kernel with PrivateArray..." <<
flush;
vector<cl_int> inputGaIn({0, 4, 5});
vector<cl_float> inputGaOut(3, 0);
vector<cl_float> inputPa({-9, 2, 0, 15, 1, 3});
vector<cl_float> output(3);
vector<cl_float> expected({-9, 1, 3});
{
using namespace elementOperators;
}
bool status(output == expected);
return status;
}
{
cout <<
"Test of Variable functionality..." <<
flush;
vector<cl_float> output(10, 1);
a->setValue(10.);
bool status(output[2] ==10.);
return status;
}
{
cout <<
"Test of VariableReference functionality..." <<
flush;
float v(1.);
vector<cl_float> output(10, 1);
v=10.;
bool status(output[2] ==10.);
return status;
}
{
cout <<
"Test of select function..." <<
flush;
vector<cl_double> input(10, 3.);
vector<cl_double> output(10, 1.);
{
using namespace elementOperators;
vec0*vec0,
vec0 > c0,
false))));
}
bool status(output[2] ==9.);
return status;
}
{
cout <<
"Test of Subvector..." <<
flush;
cl_float init[] = {16, 2, 77, 29, 23, 16, 2, 77, 29, 23};
vector<cl_float> input(init, init + sizeof(init) / sizeof(cl_float) );
vector<cl_float> output(2);
bool status(output[0]==16);
return status;
}
{
cout <<
"Test of Swap functionality..." <<
flush;
vector<cl_float> input0(10, 1);
vector<cl_float> input1(10, 2);
vector<cl_float> output(10, 10);
bool status(output[3] == 2);
return status;
}
{
cout <<
"Test of LocalArray and syncCopy with barrier()..." <<
flush;
unsigned int groupsNumber = 5;
unsigned int groupSize = 2;
vector<cl_float> input0(groupSize * groupsNumber, 3);
vector<cl_float> input1(groupSize * groupsNumber, 5);
vector<cl_float> output(groupSize * groupsNumber, 0);
vector<cl_float> expected({2, 2, 2, 2, 2, 2, 2, 2, 2, 2});
{
using namespace elementOperators;
}
bool status(output == expected);
return status;
}
{
bool allTestsPassed(true);
return allTestsPassed ? EXIT_SUCCESS : EXIT_FAILURE;
}
void addExpression(Element expression_)
ACL Kernel configuration class.
void setGroupsNumber(unsigned int n)
Element operatorAssignment(Element e1, Element e2)
Element operatorAssignmentSafe(Element e1, Element e2)
Element select(Element e1, Element e2, Element e3)
void errorMessage(cl_int status, const char *errorMessage)
Prints errorMessage and exits depending on the status.
Element convert(const TypeID tName, Element e1, bool strong=true)
Element syncCopy(Element source, Element destination, Element srcOffset, Element dstOffset, Element length)
Element barrier(std::string flags="CLK_LOCAL_MEM_FENCE")
Advanced Computational Language.
void copy(MemBlock &source, T *destination)
void swapBuffers(std::shared_ptr< Array< T > >a, std::shared_ptr< Array< T > > b)
std::shared_ptr< ElementBase > Element
bool testPrivateVariable()
bool testVariableReference()
const acl::KernelConfiguration & kConf(acl::KERNEL_BASIC)