#include "acl/acl.h"
#include "acl/aclGenerators.h"
#include "acl/DataTypes/aclGroupID.h"
#include "acl/DataTypes/aclConstant.h"
#include "aslGenerators.h"
#include "aslUtilities.h"
#include "acl/Kernels/aclKernel.h"
#include "data/aslDataUtilities.h"
#include <acl/aclMath/aclVectorOfElements.h>
#include <data/aslDataWithGhostNodes.h>
using namespace std;
{
auto a(generateDataContainerACL_SP<double>(bl,1,1));
auto b(generateDataContainerACL_SP<double>(bl,1,1));
Kernel k;
k<<(a->getEContainer()=acl::generateVEConstant<double>(0));
k<<(b->getEContainer()=acl::generateVEConstant<double>(0));
k.setup();
cout<<k.getKernelSource ()<<endl;
return true;
}
{
auto a(generateDataContainerACL_SP<double>(bl, 1, 1));
initData(a->getEContainer(),acl::generateVEConstant<double>(0));
return true;
}
{
cout <<
"Test of UploadToLocalMem()..." <<
flush;
unsigned int componentsNum = 2;
unsigned int groupSize = 27;
Element c0(
new Constant<cl_uint>(0));
auto source(asl::generateDataContainerACL_SP<float>(block,
componentsNum,
0u));
13));
auto destination(asl::generateDataContainerACL_SP<float>(block,
componentsNum,
0u));
27));
unsigned int groupsNumber = totalSize / portionSize;
Element cPortionSize(
new Constant<cl_uint>(portionSize));
kernel.setGroupsNumber(groupsNumber);
VectorOfElements localSource(componentsNum);
using namespace elementOperators;
kernel.addExpression(
barrier(
"CLK_LOCAL_MEM_FENCE | CLK_GLOBAL_MEM_FENCE"));
for (unsigned int i = 0; i < componentsNum; ++i)
kernel.addExpression(
syncCopy(localSource[i], destination->getEContainer()[i],
c0, cPortionSize * groupID, cPortionSize));
kernel.setup();
kernel.compute();
bool status(true);
vector<cl_float> src(totalSize);
vector<cl_float> dst(totalSize);
for (unsigned int i = 0; i < componentsNum; ++i)
{
copy(source->getEContainer()[i], src);
copy(destination->getEContainer()[i], dst);
cout << src << endl << endl << dst << endl;
status &= (src == dst);
}
return status;
}
{
bool allTestsPassed(true);
return allTestsPassed ? EXIT_SUCCESS : EXIT_FAILURE;
}
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)
Element syncCopy(Element source, Element destination, Element srcOffset, Element dstOffset, Element length)
Element barrier(std::string flags="CLK_LOCAL_MEM_FENCE")
VectorOfElements generateVEConstantN(unsigned int n, T a)
Generates VectorOfElements with n Elements acl::Constant with values a.
Advanced Computational Language.
void copy(MemBlock &source, T *destination)
std::shared_ptr< ElementBase > Element
Advanced Simulation Library.
T productOfElements(const AVec< T > &a)
bool testUploadToLocalMem()
const acl::KernelConfiguration & kConf(acl::KERNEL_BASIC)