ASL  0.1.7
Advanced Simulation Library
testPrivateVar.cc
/*
* Advanced Simulation Library <http://asl.org.il>
*
* Copyright 2015 Avtech Scientific <http://avtechscientific.com>
*
*
* This file is part of Advanced Simulation Library (ASL).
*
* ASL is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3 of the License.
*
* ASL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with ASL. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <acl/acl.h>
const unsigned int nLength(1000000);
const unsigned int nOperations(10);
const unsigned int nCycles(10000);
//const acl::KernelConfiguration & kConf(acl::KERNEL_SIMDUA);
{
cout << "Test of \"Simple kernel\" function..." << flush;
auto vec1(acl::generateVEData<float>(nLength,1u));
k << (res = acl::generateVEConstant(0.));
for(unsigned int i(0); i<nOperations; ++i)
{
k << (tempRes=acl::generateVEIndex() * i+5.*i*i+7./(i+1.));
k << (res+=tempRes*tempRes+rsqrt(.2*tempRes)+ 1./tempRes);
}
k << (vec1=res);
k.setup();
asl::Timer timer;
timer.start();
for(unsigned int i(0); i<nCycles; ++i)
k.compute();
timer.stop();
std::cout<<"Unoptimized: "<<timer.realTime()<<endl;
return true;
}
{
cout << "Test of \"Simple kernel\" function..." << flush;
auto vec1(acl::generateVEData<float>(nLength,1u));
k << (res = acl::generateVEConstant(0.));
vector<acl::VectorOfElements> tempRes(nOperations);
for(unsigned int i(0); i<nOperations; ++i)
{
k << (tempRes[i]=acl::generateVEIndex() * i+5.*i*i+7./(i+1.));
}
for(unsigned int i(0); i<nOperations; ++i)
k << (res+=tempRes[i]*tempRes[i]+rsqrt(.2*tempRes[i])+ 1./tempRes[i]);
k << (vec1=res);
k.setup();
asl::Timer timer;
timer.start();
for(unsigned int i(0); i<nCycles; ++i)
k.compute();
timer.stop();
std::cout<<"UnoptimizedPlus: "<<timer.realTime()<<endl;
return true;
}
{
cout << "Test of \"Simple kernel\" function..." << flush;
auto vec1(acl::generateVEData<float>(nLength,1u));
k << (res = acl::generateVEConstant(0.));
for(unsigned int i(0); i<nOperations; ++i)
{
k << (tempRes=acl::generateVEIndex() * i+5.*i*i+7./(i+1.));
k << (res+=tempRes*tempRes+rsqrt(.2*tempRes)+ 1./tempRes);
}
k << (vec1=res);
k.setup();
// cout<<k.getKernelSource()<<endl;
asl::Timer timer;
timer.start();
for(unsigned int i(0); i<nCycles; ++i)
k.compute();
timer.stop();
std::cout<<"Optimized: "<<timer.realTime()<<endl;
return true;
}
int main()
{
return 0;
}
acl::generateVEPrivateVariable
VectorOfElements generateVEPrivateVariable(unsigned int n)
Generates VectorOfElements with n Element of acl::PrivateVariable.
testKernelOptimized
bool testKernelOptimized()
Definition: testPrivateVar.cc:102
asl::Timer::stop
void stop()
Definition: aslTimer.h:44
aclGenerators.h
asl::Timer::start
void start()
Definition: aslTimer.h:43
asl::Timer
Definition: aslTimer.h:34
aclKernel.h
main
int main()
Definition: testPrivateVar.cc:133
testKernelUnoptimized
bool testKernelUnoptimized()
Definition: testPrivateVar.cc:42
kConf
const acl::KernelConfiguration & kConf(acl::KERNEL_BASIC)
acl::Kernel
OpenCl Kernel generator.
Definition: aclKernel.h:48
testKernelUnoptimizedPlus
bool testKernelUnoptimizedPlus()
Definition: testPrivateVar.cc:71
acl.h
aclVectorOfElements.h
acl::generateVEConstant
VectorOfElements generateVEConstant(T a)
Generates VectorOfElements with 1 Element acl::Constant with value a.
cl::flush
cl_int flush(void)
Definition: cl.hpp:7041
acl::KernelConfiguration
ACL Kernel configuration class.
Definition: aclKernelConfiguration.h:34
nOperations
const unsigned int nOperations(10)
nCycles
const unsigned int nCycles(10000)
aslUValue.h
acl::generateVEIndex
VectorOfElements generateVEIndex(unsigned int size=0)
acl::ComplexNumOfElements::copy
void copy(const ComplexNumOfElements &source, ComplexNumOfElements &destination)
function copies the ComplexNumOfElements class.
aslTimer.h
asl::Timer::realTime
const double realTime() const
Definition: aslTimer.h:45
acl::VectorOfElements::rsqrt
VectorOfElements rsqrt(const VectorOfElements &a)
acl::TYPE_FLOAT
Definition: aclTypes.h:42
nLength
const unsigned int nLength(1000000)
acl::KERNEL_BASIC
const KernelConfiguration KERNEL_BASIC
Definition: aclElementBase.h:45
aclKernelConfigurationTemplates.h