From d9267cc7ee6a0045c799857e30131952165a7586 Mon Sep 17 00:00:00 2001 From: Jayavanth Shenoy Date: Mon, 2 Dec 2013 12:50:42 +0530 Subject: [PATCH 1/5] New iterators and facade -Not working --- include/bolt/amp/iterator/constant_iterator.h | 223 +++++++++++++++++ include/bolt/amp/iterator/counting_iterator.h | 230 ++++++++++++++++++ include/bolt/amp/iterator/iterator_facade.h | 168 +++++++++++++ 3 files changed, 621 insertions(+) create mode 100644 include/bolt/amp/iterator/constant_iterator.h create mode 100644 include/bolt/amp/iterator/counting_iterator.h create mode 100644 include/bolt/amp/iterator/iterator_facade.h diff --git a/include/bolt/amp/iterator/constant_iterator.h b/include/bolt/amp/iterator/constant_iterator.h new file mode 100644 index 00000000..1633af6d --- /dev/null +++ b/include/bolt/amp/iterator/constant_iterator.h @@ -0,0 +1,223 @@ +/*************************************************************************** +* Copyright 2012 - 2013 Advanced Micro Devices, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + +***************************************************************************/ +#pragma once +#if !defined( BOLT_CL_CONSTANT_ITERATOR_H ) +#define BOLT_CL_CONSTANT_ITERATOR_H +#include "bolt/cl/bolt.h" +#include "bolt/cl/iterator/iterator_traits.h" +#include + +/*! \file bolt/cl/iterator/constant_iterator.h + \brief Return Same Value or Constant Value on dereferencing. +*/ + + +namespace bolt { +namespace cl { + + struct constant_iterator_tag + : public fancy_iterator_tag + { // identifying tag for random-access iterators + }; + + // This represents the host side definition of the constant_iterator template + //BOLT_TEMPLATE_FUNCTOR3( constant_iterator, int, float, double, + template< typename value_type > + class constant_iterator: public boost::iterator_facade< constant_iterator< value_type >, value_type, + constant_iterator_tag, value_type, int > + { + public: + typedef typename boost::iterator_facade< constant_iterator< value_type >, value_type, + constant_iterator_tag, value_type, int >::difference_type difference_type; + + + struct Payload + { + value_type m_Value; + }; + + // Basic constructor requires a reference to the container and a positional element + constant_iterator( value_type init, const control& ctl = control::getDefault( ) ): + m_constValue( init ), m_Index( 0 ) + { + const ::cl::CommandQueue& m_commQueue = ctl.getCommandQueue( ); + + // We want to use the context from the passed in commandqueue to initialize our buffer + cl_int l_Error = CL_SUCCESS; + ::cl::Context l_Context = m_commQueue.getInfo< CL_QUEUE_CONTEXT >( &l_Error ); + V_OPENCL( l_Error, "device_vector failed to query for the context of the ::cl::CommandQueue object" ); + + m_devMemory = ::cl::Buffer( l_Context, CL_MEM_READ_ONLY | CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR, + 1 * sizeof( value_type ),const_cast(&m_constValue) ); + } + + // This copy constructor allows an iterator to convert into a const_iterator, but not vica versa + template< typename OtherType > + constant_iterator( const constant_iterator< OtherType >& rhs ): m_devMemory( rhs.m_devMemory ), + m_Index( rhs.m_Index ), m_constValue( rhs.m_constValue ) + {} + + // This copy constructor allows an iterator to convert into a const_iterator, but not vica versa + constant_iterator< value_type >& operator= ( const constant_iterator< value_type >& rhs ) + { + if( this == &rhs ) + return *this; + + m_devMemory = rhs.m_devMemory; + m_constValue = rhs.m_constValue; + m_Index = rhs.m_Index; + return *this; + } + + constant_iterator< value_type >& operator+= ( const difference_type & n ) + { + advance( n ); + return *this; + } + + const constant_iterator< value_type > operator+ ( const difference_type & n ) const + { + constant_iterator< value_type > result( *this ); + result.advance( n ); + return result; + } + + const ::cl::Buffer& getBuffer( ) const + { + return m_devMemory; + } + + const constant_iterator< value_type > & getContainer( ) const + { + return *this; + } + + Payload gpuPayload( ) const + { + Payload payload = { m_constValue }; + return payload; + } + + const difference_type gpuPayloadSize( ) const + { + return sizeof( Payload ); + } + + difference_type distance_to( const constant_iterator< value_type >& rhs ) const + { + //return static_cast< typename iterator_facade::difference_type >( 1 ); + return rhs.m_Index - m_Index; + } + + // Public member variables + difference_type m_Index; + + private: + // Implementation detail of boost.iterator + friend class boost::iterator_core_access; + + // Used for templatized copy constructor and the templatized equal operator + template < typename > friend class constant_iterator; + + // For a constant_iterator, do nothing on an advance + void advance( difference_type n ) + { + m_Index += n; + } + + void increment( ) + { + advance( 1 ); + } + + void decrement( ) + { + advance( -1 ); + } + + template< typename OtherType > + bool equal( const constant_iterator< OtherType >& rhs ) const + { + bool sameIndex = (rhs.m_constValue == m_constValue) && (rhs.m_Index == m_Index); + + return sameIndex; + } + + typename boost::iterator_facade< constant_iterator< value_type >, value_type, + constant_iterator_tag, value_type, int >::reference dereference( ) const + { + return m_constValue; + } + + ::cl::Buffer m_devMemory; + value_type m_constValue; + }; + //) + + // This string represents the device side definition of the constant_iterator template + static std::string deviceConstantIterator = STRINGIFY_CODE( + namespace bolt { namespace cl { \n + template< typename T > \n + class constant_iterator \n + { \n + public: \n + typedef int iterator_category; // device code does not understand std:: tags \n + typedef T value_type; \n + typedef size_t difference_type; \n + typedef size_t size_type; \n + typedef T* pointer; \n + typedef T& reference; \n + + constant_iterator( value_type init ): m_constValue( init ), m_Ptr( 0 ) \n + { }; \n + + void init( global value_type* ptr ) \n + { }; \n + + value_type operator[]( size_type threadID ) const \n + { \n + return m_constValue; \n + } \n + + value_type operator*( ) const \n + { \n + return m_constValue; \n + } \n + + value_type m_constValue; \n + }; \n + } } \n + ); + + template< typename Type > + constant_iterator< Type > make_constant_iterator( Type constValue ) + { + constant_iterator< Type > tmp( constValue ); + return tmp; + } + +} +} + +BOLT_CREATE_TYPENAME( bolt::cl::constant_iterator< int > ); +BOLT_CREATE_CLCODE( bolt::cl::constant_iterator< int >, bolt::cl::deviceConstantIterator ); + +BOLT_TEMPLATE_REGISTER_NEW_TYPE( bolt::cl::constant_iterator, int, unsigned int ); +BOLT_TEMPLATE_REGISTER_NEW_TYPE( bolt::cl::constant_iterator, int, float ); +BOLT_TEMPLATE_REGISTER_NEW_TYPE( bolt::cl::constant_iterator, int, double ); + +#endif diff --git a/include/bolt/amp/iterator/counting_iterator.h b/include/bolt/amp/iterator/counting_iterator.h new file mode 100644 index 00000000..b7cc8da2 --- /dev/null +++ b/include/bolt/amp/iterator/counting_iterator.h @@ -0,0 +1,230 @@ +/*************************************************************************** +* Copyright 2012 - 2013 Advanced Micro Devices, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + +***************************************************************************/ +#pragma once +#if !defined( BOLT_CL_COUNTING_ITERATOR_H ) +#define BOLT_CL_COUNTING_ITERATOR_H +#include "bolt/cl/bolt.h" +#include "bolt/cl/iterator/iterator_traits.h" +#include + +/*! \file bolt/cl/iterator/counting_iterator.h + \brief Return Incremented Value on dereferencing. +*/ + +namespace bolt { +namespace cl { + + struct counting_iterator_tag + : public fancy_iterator_tag + { // identifying tag for random-access iterators + }; + + // This represents the host side definition of the counting_iterator template + //BOLT_TEMPLATE_FUNCTOR3( counting_iterator, int, float, double, + template< typename value_type > + class counting_iterator: public boost::iterator_facade< counting_iterator< value_type >, value_type, + counting_iterator_tag, value_type, int > + { + public: + + typedef typename boost::iterator_facade< counting_iterator< value_type >, value_type, + counting_iterator_tag, value_type, int >::difference_type difference_type; + + struct Payload + { + value_type m_Value; + }; + + // Basic constructor requires a reference to the container and a positional element + counting_iterator( value_type init, const control& ctl = control::getDefault( ) ): + m_initValue( init ), + m_Index( 0 ) + { + const ::cl::CommandQueue& m_commQueue = ctl.getCommandQueue( ); + + // We want to use the context from the passed in commandqueue to initialize our buffer + cl_int l_Error = CL_SUCCESS; + ::cl::Context l_Context = m_commQueue.getInfo< CL_QUEUE_CONTEXT >( &l_Error ); + V_OPENCL( l_Error, "device_vector failed to query for the context of the ::cl::CommandQueue object" ); + + m_devMemory = ::cl::Buffer( l_Context, CL_MEM_READ_ONLY | CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR, + 1 * sizeof( value_type ), &m_initValue ); + } + + // This copy constructor allows an iterator to convert into a const_iterator, but not vica versa + template< typename OtherType > + counting_iterator( const counting_iterator< OtherType >& rhs ): m_devMemory( rhs.m_devMemory ), + m_Index( rhs.m_Index ), m_initValue( rhs.m_initValue ) + { + } + + counting_iterator< value_type >& operator= ( const counting_iterator< value_type >& rhs ) + { + if( this == &rhs ) + return *this; + + m_devMemory = rhs.m_devMemory; + m_initValue = rhs.m_initValue; + m_Index = rhs.m_Index; + return *this; + } + + counting_iterator< value_type >& operator+= ( const difference_type & n ) + { + advance( n ); + return *this; + } + + const counting_iterator< value_type > operator+ ( const difference_type & n ) const + { + counting_iterator< value_type > result( *this ); + result.advance( n ); + return result; + } + + const ::cl::Buffer& getBuffer( ) const + { + return m_devMemory; + } + + const counting_iterator< value_type > & getContainer( ) const + { + return *this; + } + + Payload gpuPayload( ) const + { + Payload payload = { m_initValue }; + return payload; + } + + const difference_type gpuPayloadSize( ) const + { + return sizeof( Payload ); + } + + + difference_type distance_to( const counting_iterator< value_type >& rhs ) const + { + //return static_cast< typename iterator_facade::difference_type >( 1 ); + return rhs.m_Index - m_Index; + } + + // Public member variables + difference_type m_Index; + + private: + // Implementation detail of boost.iterator + friend class boost::iterator_core_access; + + // Used for templatized copy constructor and the templatized equal operator + template < typename > friend class counting_iterator; + + // For a counting_iterator, do nothing on an advance + void advance(difference_type n ) + { + m_Index += n; + } + + void increment( ) + { + advance( 1 ); + } + + void decrement( ) + { + advance( -1 ); + } + + template< typename OtherType > + bool equal( const counting_iterator< OtherType >& rhs ) const + { + bool sameIndex = (rhs.m_initValue == m_initValue) && (rhs.m_Index == m_Index); + + return sameIndex; + } + + typename boost::iterator_facade< counting_iterator< value_type >, value_type, + counting_iterator_tag, value_type, int >::reference dereference( ) const + { + return m_initValue + m_Index; + } + + ::cl::Buffer m_devMemory; + value_type m_initValue; + }; + //) + + // This string represents the device side definition of the counting_iterator template + static std::string deviceCountingIterator = STRINGIFY_CODE( + + namespace bolt { namespace cl { \n + template< typename T > \n + class counting_iterator \n + { \n + public: \n + typedef int iterator_category; // device code does not understand std:: tags \n + typedef T value_type; \n + typedef size_t difference_type; \n + typedef size_t size_type; \n + typedef T* pointer; \n + typedef T& reference; \n + + counting_iterator( value_type init ): m_StartIndex( init ), m_Ptr( 0 ) \n + {}; \n + + void init( global value_type* ptr ) \n + { \n + + //m_Ptr = ptr; \n + }; \n + + value_type operator[]( size_type threadID ) const \n + { \n + return m_StartIndex + threadID; \n + } \n + + value_type operator*( ) const \n + { \n + return m_StartIndex + threadID; \n + } \n + + value_type m_StartIndex; \n + }; \n + } } \n + ); + + + template< typename Type > + counting_iterator< Type > make_counting_iterator( Type constValue ) + { + counting_iterator< Type > tmp( constValue ); + return tmp; + } + +} +} + +BOLT_CREATE_TYPENAME( bolt::cl::counting_iterator< int > ); +BOLT_CREATE_CLCODE( bolt::cl::counting_iterator< int >, bolt::cl::deviceCountingIterator ); + +BOLT_TEMPLATE_REGISTER_NEW_TYPE( bolt::cl::counting_iterator, int, unsigned int ); +BOLT_TEMPLATE_REGISTER_NEW_TYPE( bolt::cl::counting_iterator, int, float ); +BOLT_TEMPLATE_REGISTER_NEW_TYPE( bolt::cl::counting_iterator, int, double ); +BOLT_TEMPLATE_REGISTER_NEW_TYPE( bolt::cl::counting_iterator, int, cl_long ); + +#endif diff --git a/include/bolt/amp/iterator/iterator_facade.h b/include/bolt/amp/iterator/iterator_facade.h new file mode 100644 index 00000000..b8183339 --- /dev/null +++ b/include/bolt/amp/iterator/iterator_facade.h @@ -0,0 +1,168 @@ +/*************************************************************************** +* Copyright 2012 - 2013 Advanced Micro Devices, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + +***************************************************************************/ + +#pragma once +#if !defined( BOLT_AMP_ITERATOR_FACADE_H ) +#define BOLT_AMP_ITERATOR_FACADE_H + +/*! \file bolt/amp/iterator/iterator_facade.h + \brief +*/ + +namespace bolt { +namespace amp { + + template < + class Derived // The derived iterator type being constructed + , class Value + , class CategoryOrTraversal + , class Reference = Value& + , class Difference = std::ptrdiff_t + > + class iterator_facade +# ifdef BOOST_ITERATOR_FACADE_NEEDS_ITERATOR_BASE + : public boost::detail::iterator_facade_types< + Value, CategoryOrTraversal, Reference, Difference + >::base +# undef BOOST_ITERATOR_FACADE_NEEDS_ITERATOR_BASE +# endif + { + private: + // + // Curiously Recurring Template interface. + // + Derived& derived() + { + return *static_cast(this); + } + + Derived const& derived() const + { + return *static_cast(this); + } + + typedef boost::detail::iterator_facade_types< + Value, CategoryOrTraversal, Reference, Difference + > associated_types; + + typedef boost::detail::operator_arrow_dispatch< + Reference + , typename associated_types::pointer + > operator_arrow_dispatch_; + + protected: + // For use by derived classes + typedef iterator_facade iterator_facade_; + + public: + + typedef typename associated_types::value_type value_type; + typedef Reference reference; + typedef Difference difference_type; + + typedef typename operator_arrow_dispatch_::result_type pointer; + + typedef typename associated_types::iterator_category iterator_category; + + reference operator*() const + { + return iterator_core_access::dereference(this->derived()); + } + + pointer operator->() const + { + return operator_arrow_dispatch_::apply(*this->derived()); + } + + typename boost::detail::operator_brackets_result::type + operator[](difference_type n) const + { + typedef boost::detail::use_operator_brackets_proxy use_proxy; + + return boost::detail::make_operator_brackets_result( + this->derived() + n + , use_proxy() + ); + } + + Derived& operator++() + { + iterator_core_access::increment(this->derived()); + return this->derived(); + } + +# if BOOST_WORKAROUND(BOOST_MSVC, < 1300) + typename boost::detail::postfix_increment_result::type + operator++(int) + { + typename boost::detail::postfix_increment_result::type + tmp(this->derived()); + ++*this; + return tmp; + } +# endif + + Derived& operator--() + { + iterator_core_access::decrement(this->derived()); + return this->derived(); + } + + Derived operator--(int) + { + Derived tmp(this->derived()); + --*this; + return tmp; + } + + Derived& operator+=(difference_type n) + { + iterator_core_access::advance(this->derived(), n); + return this->derived(); + } + + Derived& operator-=(difference_type n) + { + iterator_core_access::advance(this->derived(), -n); + return this->derived(); + } + + Derived operator-(difference_type x) const + { + Derived result(this->derived()); + return result -= x; + } + +# if BOOST_WORKAROUND(BOOST_MSVC, < 1300) + // There appears to be a bug which trashes the data of classes + // derived from iterator_facade when they are assigned unless we + // define this assignment operator. This bug is only revealed + // (so far) in STLPort debug mode, but it's clearly a codegen + // problem so we apply the workaround for all MSVC6. + iterator_facade& operator=(iterator_facade const&) + { + return *this; + } +# endif + }; + + + +} +}; + +#endif \ No newline at end of file From 3f30bb15ef6ac86da224a51459090c1f757bc7e4 Mon Sep 17 00:00:00 2001 From: Jayavanth Shenoy Date: Tue, 17 Dec 2013 12:10:33 +0530 Subject: [PATCH 2/5] AMP constant and counting iterator working. Need to remove boost --- include/bolt/amp/iterator/constant_iterator.h | 165 ++++++++++-------- include/bolt/amp/iterator/counting_iterator.h | 146 +++++----------- include/bolt/amp/iterator/iterator_facade.h | 39 ----- include/bolt/amp/iterator/iterator_traits.h | 4 + 4 files changed, 137 insertions(+), 217 deletions(-) diff --git a/include/bolt/amp/iterator/constant_iterator.h b/include/bolt/amp/iterator/constant_iterator.h index 1633af6d..3045d48a 100644 --- a/include/bolt/amp/iterator/constant_iterator.h +++ b/include/bolt/amp/iterator/constant_iterator.h @@ -17,8 +17,8 @@ #pragma once #if !defined( BOLT_CL_CONSTANT_ITERATOR_H ) #define BOLT_CL_CONSTANT_ITERATOR_H -#include "bolt/cl/bolt.h" -#include "bolt/cl/iterator/iterator_traits.h" +#include "bolt/amp/bolt.h" +#include "bolt/amp/iterator/iterator_traits.h" #include /*! \file bolt/cl/iterator/constant_iterator.h @@ -27,22 +27,23 @@ namespace bolt { -namespace cl { +namespace amp { struct constant_iterator_tag : public fancy_iterator_tag { // identifying tag for random-access iterators }; - // This represents the host side definition of the constant_iterator template - //BOLT_TEMPLATE_FUNCTOR3( constant_iterator, int, float, double, template< typename value_type > - class constant_iterator: public boost::iterator_facade< constant_iterator< value_type >, value_type, - constant_iterator_tag, value_type, int > + class constant_iterator: public boost::iterator_facade< constant_iterator< value_type >, value_type, + constant_iterator_tag, value_type, int > { public: typedef typename boost::iterator_facade< constant_iterator< value_type >, value_type, - constant_iterator_tag, value_type, int >::difference_type difference_type; + constant_iterator_tag, value_type, int >::difference_type difference_type; + typedef concurrency::array_view< value_type > arrayview_type; + + typedef constant_iterator const_iterator; struct Payload @@ -54,22 +55,18 @@ namespace cl { constant_iterator( value_type init, const control& ctl = control::getDefault( ) ): m_constValue( init ), m_Index( 0 ) { - const ::cl::CommandQueue& m_commQueue = ctl.getCommandQueue( ); - - // We want to use the context from the passed in commandqueue to initialize our buffer - cl_int l_Error = CL_SUCCESS; - ::cl::Context l_Context = m_commQueue.getInfo< CL_QUEUE_CONTEXT >( &l_Error ); - V_OPENCL( l_Error, "device_vector failed to query for the context of the ::cl::CommandQueue object" ); - - m_devMemory = ::cl::Buffer( l_Context, CL_MEM_READ_ONLY | CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR, - 1 * sizeof( value_type ),const_cast(&m_constValue) ); + //int m_Size = 1; + //std::vector temp(1, m_constValue); + //concurrency::extent<1> ext( static_cast< int >( m_Size ) ); + //m_devMemory = new concurrency::array(ext, temp.begin(), ctl.getAccelerator( ).default_view ); + } // This copy constructor allows an iterator to convert into a const_iterator, but not vica versa - template< typename OtherType > - constant_iterator( const constant_iterator< OtherType >& rhs ): m_devMemory( rhs.m_devMemory ), - m_Index( rhs.m_Index ), m_constValue( rhs.m_constValue ) - {} + template< typename OtherType > + constant_iterator( const constant_iterator< OtherType >& rhs ): m_devMemory( rhs.m_devMemory ), + m_Index( rhs.m_Index ), m_constValue( rhs.m_constValue ) + {} // This copy constructor allows an iterator to convert into a const_iterator, but not vica versa constant_iterator< value_type >& operator= ( const constant_iterator< value_type >& rhs ) @@ -77,7 +74,7 @@ namespace cl { if( this == &rhs ) return *this; - m_devMemory = rhs.m_devMemory; + //m_devMemory = rhs.m_devMemory; m_constValue = rhs.m_constValue; m_Index = rhs.m_Index; return *this; @@ -96,26 +93,61 @@ namespace cl { return result; } - const ::cl::Buffer& getBuffer( ) const + //value_type constant_iterator< value_type > operator[] (unsigned int &i) restrict(cpu, amp) + //{ + // return m_constValue; + //} + + arrayview_type getBuffer() const { - return m_devMemory; + // return m_devMemory; } - const constant_iterator< value_type > & getContainer( ) const + //arrayview_type getBuffer(const_iterator itr) const + //{ + // //difference_type offset = 1;//itr.getIndex(); + // //concurrency::extent<1> ext( static_cast< int >( 1 /*m_Size-offset*/ )); + // //return m_devMemory->section( Concurrency::index<1>((int)1), ext ); + // + + // ////return m_devMemory->reinterpret_as(); + // return m_constValue; + // + //} + + + + //int getBuffer(const_iterator itr) const + //{ + // //difference_type offset = 1;//itr.getIndex(); + // //concurrency::extent<1> ext( static_cast< int >( 1 /*m_Size-offset*/ )); + // //return m_devMemory->section( Concurrency::index<1>((int)1), ext ); + // + // return m_constValue; + // + //} + + const constant_iterator< value_type > & getBuffer( const_iterator itr ) const { return *this; } + - Payload gpuPayload( ) const + const constant_iterator< value_type > & getContainer( ) const { - Payload payload = { m_constValue }; - return payload; + return *this; } - const difference_type gpuPayloadSize( ) const - { - return sizeof( Payload ); - } + //Payload gpuPayload( ) const + //{ + // Payload payload = { m_constValue }; + // return payload; + //} + + //const difference_type gpuPayloadSize( ) const + //{ + // return sizeof( Payload ); + //} difference_type distance_to( const constant_iterator< value_type >& rhs ) const { @@ -126,7 +158,7 @@ namespace cl { // Public member variables difference_type m_Index; - private: + // private: // Implementation detail of boost.iterator friend class boost::iterator_core_access; @@ -149,6 +181,11 @@ namespace cl { advance( -1 ); } + difference_type getIndex() const + { + return m_Index; + } + template< typename OtherType > bool equal( const constant_iterator< OtherType >& rhs ) const { @@ -157,51 +194,35 @@ namespace cl { return sameIndex; } + + typename boost::iterator_facade< constant_iterator< value_type >, value_type, constant_iterator_tag, value_type, int >::reference dereference( ) const { - return m_constValue; + //value_type tmp = *(m_devMemory->data()); + //return tmp; + + //return *(m_devMemory->data()); + + return m_constValue; + + } + + + int operator[](int x) const restrict(cpu,amp) // Uncomment if using iterator in inl + { + int xy = m_constValue; + return xy; + //return *(m_Ptr->data()); } - ::cl::Buffer m_devMemory; + + //concurrency::array* m_devMemory; + //concurrency::array_view* m_Ptr; value_type m_constValue; }; //) - // This string represents the device side definition of the constant_iterator template - static std::string deviceConstantIterator = STRINGIFY_CODE( - namespace bolt { namespace cl { \n - template< typename T > \n - class constant_iterator \n - { \n - public: \n - typedef int iterator_category; // device code does not understand std:: tags \n - typedef T value_type; \n - typedef size_t difference_type; \n - typedef size_t size_type; \n - typedef T* pointer; \n - typedef T& reference; \n - - constant_iterator( value_type init ): m_constValue( init ), m_Ptr( 0 ) \n - { }; \n - - void init( global value_type* ptr ) \n - { }; \n - - value_type operator[]( size_type threadID ) const \n - { \n - return m_constValue; \n - } \n - - value_type operator*( ) const \n - { \n - return m_constValue; \n - } \n - - value_type m_constValue; \n - }; \n - } } \n - ); template< typename Type > constant_iterator< Type > make_constant_iterator( Type constValue ) @@ -213,11 +234,5 @@ namespace cl { } } -BOLT_CREATE_TYPENAME( bolt::cl::constant_iterator< int > ); -BOLT_CREATE_CLCODE( bolt::cl::constant_iterator< int >, bolt::cl::deviceConstantIterator ); - -BOLT_TEMPLATE_REGISTER_NEW_TYPE( bolt::cl::constant_iterator, int, unsigned int ); -BOLT_TEMPLATE_REGISTER_NEW_TYPE( bolt::cl::constant_iterator, int, float ); -BOLT_TEMPLATE_REGISTER_NEW_TYPE( bolt::cl::constant_iterator, int, double ); #endif diff --git a/include/bolt/amp/iterator/counting_iterator.h b/include/bolt/amp/iterator/counting_iterator.h index b7cc8da2..5669a7ea 100644 --- a/include/bolt/amp/iterator/counting_iterator.h +++ b/include/bolt/amp/iterator/counting_iterator.h @@ -17,73 +17,56 @@ #pragma once #if !defined( BOLT_CL_COUNTING_ITERATOR_H ) #define BOLT_CL_COUNTING_ITERATOR_H -#include "bolt/cl/bolt.h" -#include "bolt/cl/iterator/iterator_traits.h" +#include "bolt/amp/bolt.h" +#include "bolt/amp/iterator/iterator_traits.h" #include /*! \file bolt/cl/iterator/counting_iterator.h - \brief Return Incremented Value on dereferencing. + \brief Return Same Value or counting Value on dereferencing. */ + namespace bolt { -namespace cl { +namespace amp { struct counting_iterator_tag : public fancy_iterator_tag { // identifying tag for random-access iterators }; - // This represents the host side definition of the counting_iterator template - //BOLT_TEMPLATE_FUNCTOR3( counting_iterator, int, float, double, template< typename value_type > - class counting_iterator: public boost::iterator_facade< counting_iterator< value_type >, value_type, - counting_iterator_tag, value_type, int > + class counting_iterator: public boost::iterator_facade< counting_iterator< value_type >, value_type, + counting_iterator_tag, value_type, int > { public: + typedef typename boost::iterator_facade< counting_iterator< value_type >, value_type, + counting_iterator_tag, value_type, int >::difference_type difference_type; + typedef concurrency::array_view< value_type > arrayview_type; - typedef typename boost::iterator_facade< counting_iterator< value_type >, value_type, - counting_iterator_tag, value_type, int >::difference_type difference_type; - - struct Payload - { - value_type m_Value; - }; + typedef counting_iterator const_iterator; + // Basic constructor requires a reference to the container and a positional element counting_iterator( value_type init, const control& ctl = control::getDefault( ) ): - m_initValue( init ), - m_Index( 0 ) - { - const ::cl::CommandQueue& m_commQueue = ctl.getCommandQueue( ); - - // We want to use the context from the passed in commandqueue to initialize our buffer - cl_int l_Error = CL_SUCCESS; - ::cl::Context l_Context = m_commQueue.getInfo< CL_QUEUE_CONTEXT >( &l_Error ); - V_OPENCL( l_Error, "device_vector failed to query for the context of the ::cl::CommandQueue object" ); - - m_devMemory = ::cl::Buffer( l_Context, CL_MEM_READ_ONLY | CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR, - 1 * sizeof( value_type ), &m_initValue ); - } + m_initValue( init ), m_Index( 0 ) {} // This copy constructor allows an iterator to convert into a const_iterator, but not vica versa - template< typename OtherType > - counting_iterator( const counting_iterator< OtherType >& rhs ): m_devMemory( rhs.m_devMemory ), - m_Index( rhs.m_Index ), m_initValue( rhs.m_initValue ) - { - } + template< typename OtherType > + counting_iterator( const counting_iterator< OtherType >& rhs ):m_Index( rhs.m_Index ), + m_initstValue( rhs.m_initstValue ) {} + // This copy constructor allows an iterator to convert into a const_iterator, but not vica versa counting_iterator< value_type >& operator= ( const counting_iterator< value_type >& rhs ) { if( this == &rhs ) return *this; - m_devMemory = rhs.m_devMemory; - m_initValue = rhs.m_initValue; + m_initstValue = rhs.m_initstValue; m_Index = rhs.m_Index; return *this; } - counting_iterator< value_type >& operator+= ( const difference_type & n ) + counting_iterator< value_type >& operator+= ( const difference_type & n ) { advance( n ); return *this; @@ -96,38 +79,26 @@ namespace cl { return result; } - const ::cl::Buffer& getBuffer( ) const - { - return m_devMemory; - } - - const counting_iterator< value_type > & getContainer( ) const + const counting_iterator< value_type > & getBuffer( const_iterator itr ) const { return *this; } + - Payload gpuPayload( ) const - { - Payload payload = { m_initValue }; - return payload; - } - - const difference_type gpuPayloadSize( ) const + const counting_iterator< value_type > & getContainer( ) const { - return sizeof( Payload ); + return *this; } - difference_type distance_to( const counting_iterator< value_type >& rhs ) const { - //return static_cast< typename iterator_facade::difference_type >( 1 ); return rhs.m_Index - m_Index; } // Public member variables difference_type m_Index; - private: + // private: // Implementation detail of boost.iterator friend class boost::iterator_core_access; @@ -135,7 +106,7 @@ namespace cl { template < typename > friend class counting_iterator; // For a counting_iterator, do nothing on an advance - void advance(difference_type n ) + void advance( difference_type n ) { m_Index += n; } @@ -150,6 +121,11 @@ namespace cl { advance( -1 ); } + difference_type getIndex() const + { + return m_Index; + } + template< typename OtherType > bool equal( const counting_iterator< OtherType >& rhs ) const { @@ -158,55 +134,26 @@ namespace cl { return sameIndex; } - typename boost::iterator_facade< counting_iterator< value_type >, value_type, - counting_iterator_tag, value_type, int >::reference dereference( ) const - { - return m_initValue + m_Index; - } - - ::cl::Buffer m_devMemory; - value_type m_initValue; - }; - //) - - // This string represents the device side definition of the counting_iterator template - static std::string deviceCountingIterator = STRINGIFY_CODE( - namespace bolt { namespace cl { \n - template< typename T > \n - class counting_iterator \n - { \n - public: \n - typedef int iterator_category; // device code does not understand std:: tags \n - typedef T value_type; \n - typedef size_t difference_type; \n - typedef size_t size_type; \n - typedef T* pointer; \n - typedef T& reference; \n - counting_iterator( value_type init ): m_StartIndex( init ), m_Ptr( 0 ) \n - {}; \n + typename boost::iterator_facade< counting_iterator< value_type >, value_type, + counting_iterator_tag, value_type, int >::reference dereference( ) const + { + return m_initValue + m_Index; - void init( global value_type* ptr ) \n - { \n + } - //m_Ptr = ptr; \n - }; \n - value_type operator[]( size_type threadID ) const \n - { \n - return m_StartIndex + threadID; \n - } \n + int operator[](int x) const restrict(cpu,amp) // Uncomment if using iterator in inl + { + int temp = x + m_initValue; + return temp; + } - value_type operator*( ) const \n - { \n - return m_StartIndex + threadID; \n - } \n - value_type m_StartIndex; \n - }; \n - } } \n - ); + value_type m_initValue; + }; + //) template< typename Type > @@ -219,12 +166,5 @@ namespace cl { } } -BOLT_CREATE_TYPENAME( bolt::cl::counting_iterator< int > ); -BOLT_CREATE_CLCODE( bolt::cl::counting_iterator< int >, bolt::cl::deviceCountingIterator ); - -BOLT_TEMPLATE_REGISTER_NEW_TYPE( bolt::cl::counting_iterator, int, unsigned int ); -BOLT_TEMPLATE_REGISTER_NEW_TYPE( bolt::cl::counting_iterator, int, float ); -BOLT_TEMPLATE_REGISTER_NEW_TYPE( bolt::cl::counting_iterator, int, double ); -BOLT_TEMPLATE_REGISTER_NEW_TYPE( bolt::cl::counting_iterator, int, cl_long ); #endif diff --git a/include/bolt/amp/iterator/iterator_facade.h b/include/bolt/amp/iterator/iterator_facade.h index b8183339..3643c2cd 100644 --- a/include/bolt/amp/iterator/iterator_facade.h +++ b/include/bolt/amp/iterator/iterator_facade.h @@ -24,7 +24,6 @@ */ namespace bolt { -namespace amp { template < class Derived // The derived iterator type being constructed @@ -34,12 +33,6 @@ namespace amp { , class Difference = std::ptrdiff_t > class iterator_facade -# ifdef BOOST_ITERATOR_FACADE_NEEDS_ITERATOR_BASE - : public boost::detail::iterator_facade_types< - Value, CategoryOrTraversal, Reference, Difference - >::base -# undef BOOST_ITERATOR_FACADE_NEEDS_ITERATOR_BASE -# endif { private: // @@ -55,15 +48,6 @@ namespace amp { return *static_cast(this); } - typedef boost::detail::iterator_facade_types< - Value, CategoryOrTraversal, Reference, Difference - > associated_types; - - typedef boost::detail::operator_arrow_dispatch< - Reference - , typename associated_types::pointer - > operator_arrow_dispatch_; - protected: // For use by derived classes typedef iterator_facade iterator_facade_; @@ -105,17 +89,6 @@ namespace amp { return this->derived(); } -# if BOOST_WORKAROUND(BOOST_MSVC, < 1300) - typename boost::detail::postfix_increment_result::type - operator++(int) - { - typename boost::detail::postfix_increment_result::type - tmp(this->derived()); - ++*this; - return tmp; - } -# endif - Derived& operator--() { iterator_core_access::decrement(this->derived()); @@ -147,22 +120,10 @@ namespace amp { return result -= x; } -# if BOOST_WORKAROUND(BOOST_MSVC, < 1300) - // There appears to be a bug which trashes the data of classes - // derived from iterator_facade when they are assigned unless we - // define this assignment operator. This bug is only revealed - // (so far) in STLPort debug mode, but it's clearly a codegen - // problem so we apply the workaround for all MSVC6. - iterator_facade& operator=(iterator_facade const&) - { - return *this; - } -# endif }; -} }; #endif \ No newline at end of file diff --git a/include/bolt/amp/iterator/iterator_traits.h b/include/bolt/amp/iterator/iterator_traits.h index be05ffcb..17e66266 100644 --- a/include/bolt/amp/iterator/iterator_traits.h +++ b/include/bolt/amp/iterator/iterator_traits.h @@ -59,6 +59,10 @@ namespace amp { typedef const T& reference; }; + struct fancy_iterator_tag : public std::random_access_iterator_tag + { + }; + } }; From 5a64a39ca44e094e1fc551b205bb3b14243f7dd3 Mon Sep 17 00:00:00 2001 From: Jayavanth Shenoy Date: Tue, 17 Dec 2013 12:13:14 +0530 Subject: [PATCH 3/5] Necessary changes to inl for const and counting iterator --- include/bolt/amp/detail/transform.inl | 94 +- test/amp/TransformTest/TransformTest.cpp | 3383 +++++++++++----------- 2 files changed, 1723 insertions(+), 1754 deletions(-) diff --git a/include/bolt/amp/detail/transform.inl b/include/bolt/amp/detail/transform.inl index 6de22b47..3626996d 100644 --- a/include/bolt/amp/detail/transform.inl +++ b/include/bolt/amp/detail/transform.inl @@ -33,6 +33,7 @@ #include #include "bolt/amp/bolt.h" #include "bolt/amp/device_vector.h" +#include "bolt/amp/iterator/iterator_traits.h" #ifdef ENABLE_TBB #include "bolt/btbb/transform.h" @@ -61,34 +62,45 @@ namespace bolt typedef std::iterator_traits< DVInputIterator2 >::value_type iType2; typedef std::iterator_traits< DVOutputIterator >::value_type oType; + typedef std::iterator_traits< DVInputIterator1 >::pointer container_type; + + typedef concurrency::array_view array_view_type1; + typedef concurrency::array_view array_view_type2; + typedef bolt::amp::constant_iterator constant_iter_type1; + typedef bolt::amp::constant_iterator constant_iter_type2; + + const unsigned int arraySize = static_cast< unsigned int >( std::distance( first1, last1 ) ); unsigned int wavefrontMultiple = arraySize; const unsigned int lowerBits = ( arraySize & ( WAVEFRNT_SIZE -1 ) ); - int boundsCheck = 0; + int boundsCheck = 0; if( lowerBits ) { wavefrontMultiple &= ~lowerBits; wavefrontMultiple += WAVEFRNT_SIZE; - } - else - boundsCheck = 1; + } + else + { + boundsCheck = 1; + } - concurrency::array_view inputV1 (first1.getContainer().getBuffer(first1)); - concurrency::array_view inputV2 (first2.getContainer().getBuffer(first2)); - concurrency::array_view resultV(result.getContainer().getBuffer(result)); + auto inputV1 = first1.getContainer().getBuffer(first1); + auto inputV2 = first2.getContainer().getBuffer(first2); + auto resultV = result.getContainer().getBuffer(result); concurrency::extent< 1 > inputExtent( wavefrontMultiple ); concurrency::parallel_for_each(ctl.getAccelerator().default_view, inputExtent, [=](concurrency::index<1> idx) restrict(amp) { unsigned int globalId = idx[0]; - if(boundsCheck == 0) - { - if( globalId >= arraySize ) - return; - } + if(boundsCheck == 0) + { + if( globalId >= arraySize ) + return; + } resultV[idx[0]] = f(inputV1[globalId], inputV2[globalId]); + }); }; @@ -139,6 +151,51 @@ namespace bolt \detail This template is called by the non-detail versions of transform, it already assumes random access * iterators. This overload is called strictly for non-device_vector iterators */ + + template + void transform_pick_iterator(bolt::amp::control &ctl, + const InputIterator1& first1, + const InputIterator1& last1, + const InputIterator2& first2, + const OutputIterator& result, + const BinaryFunction& f, bolt::amp::fancy_iterator_tag) + { + typedef std::iterator_traits::value_type iType1; + typedef std::iterator_traits::value_type iType2; + typedef std::iterator_traits::value_type oType; + size_t sz = (last1 - first1); + if (sz == 0) + return; + // Use host pointers memory since these arrays are only read once - no benefit to copying. + const bolt::amp::control::e_RunMode runMode = ctl.getForceRunMode(); // could be dynamic choice some day. + if (runMode == bolt::amp::control::SerialCpu) + { + std::transform(first1, last1, first2, result, f); + return; + } + else if (runMode == bolt::amp::control::MultiCoreCpu) + { +#if defined( ENABLE_TBB ) + + bolt::btbb::transform(first1, last1, first2, result, f); +#else + throw std::exception("The MultiCoreCpu version of transform is not enabled to be built."); +#endif + return; + } + else + { + // Use host pointers memory since these arrays are only read once - no benefit to copying. + // Map the input iterator to a device_vector + device_vector< iType2, concurrency::array_view > dvInput2(first2, sz, false, ctl); + // Map the output iterator to a device_vector + device_vector< oType, concurrency::array_view > dvOutput(result, sz, true, ctl); + transform_enqueue(ctl, first1, last1, dvInput2.begin(), dvOutput.begin(), f); + // This should immediately map/unmap the buffer + dvOutput.data(); + } + } + template typename std::enable_if< !(std::is_base_of::value_type>::iterator,InputIterator1>::value && @@ -428,6 +485,19 @@ namespace bolt transform_pick_iterator( ctl, first1, last1, first2, result, f ); } + template + void transform_detect_random_access(bolt::amp::control& ctl, + const InputIterator1& first1, + const InputIterator1& last1, + const InputIterator2& first2, + const OutputIterator& result, + const BinaryFunction& f, + bolt::amp::fancy_iterator_tag, + std::random_access_iterator_tag) + { + transform_pick_iterator(ctl, first1, last1, first2, result, f, std::iterator_traits< InputIterator1 >::iterator_category()); + } + // Wrapper that uses default control class, iterator interface template void transform_unary_detect_random_access( bolt::amp::control& ctl, diff --git a/test/amp/TransformTest/TransformTest.cpp b/test/amp/TransformTest/TransformTest.cpp index 25d68f89..bd63d96b 100644 --- a/test/amp/TransformTest/TransformTest.cpp +++ b/test/amp/TransformTest/TransformTest.cpp @@ -22,1771 +22,1671 @@ #include #include #include "bolt/amp/functional.h" +#include "bolt/amp/iterator/constant_iterator.h" +#include "bolt/amp/iterator/counting_iterator.h" #include "common/test_common.h" #define TEST_DOUBLE 0 #define GTEST_TESTS 1 -#if !GTEST_TESTS +/////////////////////////////////////////////////////////////////////////////////////////////////////////// +//// Fixture classes are now defined to enable googletest to process type parameterized tests +// +//// This class creates a C++ 'TYPE' out of a size_t value +//template< size_t N > +//class TypeValue +//{ +//public: +// static const size_t value = N; +//}; +// +//// Explicit initialization of the C++ static const +//template< size_t N > +//const size_t TypeValue< N >::value; +// +//// Test fixture class, used for the Type-parameterized tests +//// Namely, the tests that use std::array and TYPED_TEST_P macros +//template< typename ArrayTuple > +//class TransformArrayTest: public ::testing::Test +//{ +//public: +// TransformArrayTest( ): m_Errors( 0 ) +// {} +// +// virtual void SetUp( ) +// { +// for( int i=0; i < ArraySize; i++ ) +// { +// stdInput[ i ] = 1; +// boltInput[ i ] = 1; +// } +// }; +// +// virtual void TearDown( ) +// {}; +// +// virtual ~TransformArrayTest( ) +// {} +// +////protected: +// +// typedef typename std::tuple_element< 0, ArrayTuple >::type ArrayType; +// static const size_t ArraySize = typename std::tuple_element< 1, ArrayTuple >::type::value; +// +// typename std::array< ArrayType, ArraySize > stdInput, boltInput; +// int m_Errors; +//}; +// +//template< typename ArrayTuple > +//class TransformBinaryArrayTest: public ::testing::Test +//{ +//public: +// TransformBinaryArrayTest( ): m_Errors( 0 ) +// {} +// +// virtual void SetUp( ) +// { +// for( int i=0; i < ArraySize; i++ ) +// { +// stdInput1[ i ] = 1; +// stdInput2[ i ] = 1; +// stdOutput[ i ] = 0; +// boltInput1[ i ] = 1; +// boltInput2[ i ] = 1; +// boltOutput[ i ] = 0; +// } +// }; +// +// virtual void TearDown( ) +// {}; +// +// virtual ~TransformBinaryArrayTest( ) +// {} +// +//protected: +// typedef typename std::tuple_element< 0, ArrayTuple >::type ArrayType; +// static const size_t ArraySize = typename std::tuple_element< 1, ArrayTuple >::type::value; +// +// typename std::array< ArrayType, ArraySize > stdInput1, stdInput2, stdOutput,boltInput1, boltInput2, boltOutput; +// int m_Errors; +//}; +// +//template< typename ArrayTuple > +//class TransformOutPlaceArrayTest: public ::testing::Test +//{ +//public: +// TransformOutPlaceArrayTest( ): m_Errors( 0 ) +// {} +// +// virtual void SetUp( ) +// { +// for( int i=0; i < ArraySize; i++ ) +// { +// stdInput[ i ] = 1; +// stdOutput[ i ] = 0; +// boltInput[ i ] = 1; +// boltOutput[ i ] = 0; +// } +// }; +// +// virtual void TearDown( ) +// {}; +// +// virtual ~TransformOutPlaceArrayTest( ) +// {} +// +//protected: +// typedef typename std::tuple_element< 0, ArrayTuple >::type ArrayType; +// static const size_t ArraySize = typename std::tuple_element< 1, ArrayTuple >::type::value; +// +// typename std::array< ArrayType, ArraySize > stdInput, stdOutput, boltInput, boltOutput; +// int m_Errors; +//}; +// +//// Explicit initialization of the C++ static const +//template< typename ArrayTuple > +//const size_t TransformArrayTest< ArrayTuple >::ArraySize; +// +//template< typename ArrayTuple > +//const size_t TransformBinaryArrayTest< ArrayTuple >::ArraySize; +// +//template< typename ArrayTuple > +//const size_t TransformOutPlaceArrayTest< ArrayTuple >::ArraySize; +// +// +//TYPED_TEST_CASE_P( TransformArrayTest ); +//TYPED_TEST_CASE_P( TransformBinaryArrayTest ); +//TYPED_TEST_CASE_P( TransformOutPlaceArrayTest ); +// +// +//TYPED_TEST_P( TransformArrayTest, InPlaceNegateTransform ) +//{ +// typedef std::array< ArrayType, ArraySize > ArrayCont; +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); +// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); +// +// ArrayCont::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end( ) ); +// ArrayCont::difference_type boltNumElements = std::distance( boltInput.begin( ), boltInput.end( ) ); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdInput, boltInput ); +//} +//TYPED_TEST_P( TransformArrayTest, SerialInPlaceNegateTransform ) +//{ +// typedef std::array< ArrayType, ArraySize > ArrayCont; +// +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::SerialCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ),bolt::amp::negate()); +// +// ArrayCont::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end( ) ); +// ArrayCont::difference_type boltNumElements = std::distance( boltInput.begin( ), boltInput.end( ) ); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdInput, boltInput ); +//} +//TYPED_TEST_P( TransformArrayTest, MulticoreInPlaceNegateTransform ) +//{ +// typedef std::array< ArrayType, ArraySize > ArrayCont; +// +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ),bolt::amp::negate()); +// +// ArrayCont::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end( ) ); +// ArrayCont::difference_type boltNumElements = std::distance( boltInput.begin( ), boltInput.end( ) ); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdInput, boltInput ); +//} +// +// +// +// +//TYPED_TEST_P( TransformBinaryArrayTest, BinaryPlusTransform ) +//{ +// typedef std::array< ArrayType, ArraySize > ArrayCont; +// +// // Calling the actual functions under test +// std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), +// std::plus< ArrayType >( ) ); +// bolt::amp::transform( boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), +// bolt::amp::plus< ArrayType >( ) ); +// +// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); +// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +//} +//TYPED_TEST_P( TransformBinaryArrayTest, SerialBinaryPlusTransform ) +//{ +// typedef std::array< ArrayType, ArraySize > ArrayCont; +// +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::SerialCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), +// std::plus< ArrayType >( ) ); +// bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), +// bolt::amp::plus< ArrayType >( ) ); +// +// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); +// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +//} +//TYPED_TEST_P( TransformBinaryArrayTest, MulticoreBinaryPlusTransform ) +//{ +// typedef std::array< ArrayType, ArraySize > ArrayCont; +// +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), +// std::plus< ArrayType >( ) ); +// bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), +// bolt::amp::plus< ArrayType >( ) ); +// +// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); +// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +//} +// +// +// +//TYPED_TEST_P( TransformBinaryArrayTest, BinaryMultipliesTransform ) +//{ +// typedef std::array< ArrayType, ArraySize > ArrayCont; +// +// // Calling the actual functions under test +// std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), +// std::multiplies< ArrayType >( ) ); +// bolt::amp::transform( boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), +// bolt::amp::multiplies< ArrayType >( ) ); +// +// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); +// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +//} +//TYPED_TEST_P( TransformBinaryArrayTest, SerialBinaryMultipliesTransform ) +//{ +// typedef std::array< ArrayType, ArraySize > ArrayCont; +// +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::SerialCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), +// std::multiplies< ArrayType >( ) ); +// bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), +// bolt::amp::multiplies< ArrayType >( ) ); +// +// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); +// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +//} +//TYPED_TEST_P( TransformBinaryArrayTest, MulticoreBinaryMultipliesTransform ) +//{ +// typedef std::array< ArrayType, ArraySize > ArrayCont; +// +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), +// std::multiplies< ArrayType >( ) ); +// bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), +// bolt::amp::multiplies< ArrayType >( ) ); +// +// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); +// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +//} +// +// +//TYPED_TEST_P( TransformBinaryArrayTest, BinaryMaxTransform ) +//{ +// typedef std::array< ArrayType, ArraySize > ArrayCont; +// +// // Calling the actual functions under test +// std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), [] (ArrayType lhs, +// ArrayType rhs) { return rhs > lhs ? rhs:lhs; } ); +// bolt::amp::transform( boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), +// bolt::amp::maximum< ArrayType >( ) ); +// +// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); +// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +//} +//TYPED_TEST_P( TransformBinaryArrayTest, SerialBinaryMaxTransform ) +//{ +// typedef std::array< ArrayType, ArraySize > ArrayCont; +// +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::SerialCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), [] (ArrayType lhs, +// ArrayType rhs) { return rhs > lhs ? rhs:lhs; } ); +// bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), +// bolt::amp::maximum< ArrayType >( ) ); +// +// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); +// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +//} +//TYPED_TEST_P( TransformBinaryArrayTest, MulticoreBinaryMaxTransform ) +//{ +// typedef std::array< ArrayType, ArraySize > ArrayCont; +// +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), [] (ArrayType lhs, +// ArrayType rhs) { return rhs > lhs ? rhs:lhs; } ); +// bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), +// bolt::amp::maximum< ArrayType >( ) ); +// +// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); +// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +//} +// +// +// +//TYPED_TEST_P( TransformOutPlaceArrayTest, OutPlaceSquareTransform ) +//{ +// typedef std::array< ArrayType, ArraySize > ArrayCont; +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdOutput.begin(), []( ArrayType x ) {return x*x;} ); +// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltOutput.begin(), bolt::amp::square< ArrayType >()); +// +// +// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin(), stdOutput.end() ); +// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin(), boltOutput.end() ); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +//} +//TYPED_TEST_P( TransformOutPlaceArrayTest, SerialOutPlaceSquareTransform ) +//{ +// typedef std::array< ArrayType, ArraySize > ArrayCont; +// +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::SerialCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdOutput.begin(), []( ArrayType x ) {return x*x;} ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltOutput.begin(), +// bolt::amp::square< ArrayType >( ) ); +// +// +// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin(), stdOutput.end() ); +// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin(), boltOutput.end() ); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +//} +//TYPED_TEST_P( TransformOutPlaceArrayTest, MulticoreOutPlaceSquareTransform ) +//{ +// typedef std::array< ArrayType, ArraySize > ArrayCont; +// +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdOutput.begin(), []( ArrayType x ) {return x*x;} ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltOutput.begin(), +// bolt::amp::square< ArrayType >( ) ); +// +// +// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin(), stdOutput.end() ); +// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin(), boltOutput.end() ); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +//} +// +// +//struct UDD +//{ +// int a; +// int b; +// +// bool operator() (const UDD& lhs, const UDD& rhs) const restrict(amp,cpu){ +// return ((lhs.a+lhs.b) > (rhs.a+rhs.b)); +// } +// bool operator < (const UDD& other) const restrict(amp,cpu){ +// return ((a+b) < (other.a+other.b)); +// } +// bool operator > (const UDD& other) const restrict(amp,cpu){ +// return ((a+b) > (other.a+other.b)); +// } +// bool operator == (const UDD& other) const restrict(amp,cpu) { +// return ((a+b) == (other.a+other.b)); +// } +// +// UDD operator + (const UDD &rhs) const restrict(amp,cpu) +// { +// UDD _result; +// _result.a = a + rhs.a; +// _result.b = b + rhs.b; +// return _result; +// } +// +// +// UDD() restrict(amp,cpu) +// : a(0),b(0) { } +// UDD(int _in) restrict(amp,cpu) +// : a(_in), b(_in +1) { } +//}; +// +// +// +//REGISTER_TYPED_TEST_CASE_P( TransformArrayTest, InPlaceNegateTransform, SerialInPlaceNegateTransform, +// MulticoreInPlaceNegateTransform ); +//REGISTER_TYPED_TEST_CASE_P( TransformOutPlaceArrayTest, OutPlaceSquareTransform, SerialOutPlaceSquareTransform, +// MulticoreOutPlaceSquareTransform ); +//REGISTER_TYPED_TEST_CASE_P( TransformBinaryArrayTest, BinaryPlusTransform, SerialBinaryPlusTransform, +// MulticoreBinaryPlusTransform, BinaryMultipliesTransform, +// SerialBinaryMultipliesTransform, MulticoreBinaryMultipliesTransform, +// BinaryMaxTransform, SerialBinaryMaxTransform, MulticoreBinaryMaxTransform); +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////////////// +//// Fixture classes are now defined to enable googletest to process value parameterized tests +// +//// ::testing::TestWithParam< int > means that GetParam( ) returns int values, which i use for array size +//class TransformIntegerVector: public ::testing::TestWithParam< int > +//{ +//public: +// // Create an std and a bolt vector of requested size, and initialize all the elements to 1 +// TransformIntegerVector( ): stdInput( GetParam( ), 1 ), boltInput( GetParam( ), 1 ) +// {} +// +//protected: +// std::vector< int > stdInput, boltInput; +//}; +// +//class TransformIntegerDeviceVector: public ::testing::TestWithParam< int > +//{ +//public: +// // Create an std and a bolt vector of requested size, and initialize all the elements to 1 +// TransformIntegerDeviceVector( ): stdInput( GetParam( ), 1 ), boltInput(static_cast(GetParam( )), 1 ) +// { +// std::generate(stdInput.begin(), stdInput.end(), rand); +// //boltInput = stdInput; +// //FIXME - The above should work but the below loop is used. +// for (int i=0; i< GetParam( ); i++) +// { +// boltInput[i] = stdInput[i]; +// +// } +// } +// +//protected: +// std::vector< int > stdInput; +// bolt::amp::device_vector< int > boltInput; +//}; +// +//// ::testing::TestWithParam< int > means that GetParam( ) returns int values, which i use for array size +//class TransformFloatVector: public ::testing::TestWithParam< int > +//{ +//public: +// // Create an std and a bolt vector of requested size, and initialize all the elements to 1 +// TransformFloatVector( ): stdInput( GetParam( ), 1.0f ), boltInput( GetParam( ), 1.0f ) +// {} +// +//protected: +// std::vector< float > stdInput, boltInput; +//}; +// +// +//class TransformFloatDeviceVector: public ::testing::TestWithParam< int > +//{ +//public: +// // Create an std and a bolt vector of requested size, and initialize all the elements to 1 +// TransformFloatDeviceVector( ): stdInput( GetParam( ), 1.0f ), boltInput( static_cast( GetParam( ) ), 1.0f ) +// { +// std::generate(stdInput.begin(), stdInput.end(), rand); +// //boltInput = stdInput; +// //FIXME - The above should work but the below loop is used. +// for (int i=0; i< GetParam( ); i++) +// { +// boltInput[i] = stdInput[i]; +// } +// +// } +// +//protected: +// std::vector< float > stdInput; +// bolt::amp::device_vector< float > boltInput; +//}; +//// ::testing::TestWithParam< int > means that GetParam( ) returns int values, which i use for array size +//class TransformDoubleVector: public ::testing::TestWithParam< int > +//{ +//public: +// // Create an std and a bolt vector of requested size, and initialize all the elements to 1 +// TransformDoubleVector( ): stdInput( GetParam( ), 1.0 ), boltInput( GetParam( ), 1.0 ) +// {} +// +//protected: +// std::vector< double > stdInput, boltInput; +//}; +// +// +//#if (TEST_DOUBLE == 1) +//// ::testing::TestWithParam< int > means that GetParam( ) returns int values, which i use for array size +//class TransformDoubleDeviceVector: public ::testing::TestWithParam< int > +//{ +//public: +// // Create an std and a bolt vector of requested size, and initialize all the elements to 1 +// TransformDoubleDeviceVector( ): stdInput( GetParam( ), 1.0 ), boltInput( static_cast( GetParam( ) ), 1.0 ) +// { +// std::generate(stdInput.begin(), stdInput.end(), rand); +// //boltInput = stdInput; +// //FIXME - The above should work but the below loop is used. +// for (int i=0; i< GetParam( ); i++) +// { +// boltInput[i] = stdInput[i]; +// } +// } +// +//protected: +// std::vector< double > stdInput; +// bolt::amp::device_vector< double > boltInput; +//}; +//#endif +// +// +//TEST( HostIntVector, OffsetTransform ) +//{ +// int length = 1024; +// +// std::vector stdInput( length ,1); +// std::vector boltInput(stdInput.begin(),stdInput.end()); +// +// int offset = 100; +// +// std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); +// bolt::amp::transform( boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); +// +// cmpArrays( stdInput, boltInput); +// +//} +// +//TEST( HostIntVector, SerialOffsetTransform ) +//{ +// int length = 1024; +// +// std::vector stdInput( length ,1); +// std::vector boltInput(stdInput.begin(),stdInput.end()); +// +// int offset = 100; +// +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::SerialCpu); +// +// std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); +// bolt::amp::transform(ctl, boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); +// +// cmpArrays( stdInput, boltInput); +// +//} +// +//TEST( HostIntVector, MulticoreOffsetTransform ) +//{ +// int length = 1024; +// +// std::vector stdInput( length ,1); +// std::vector boltInput(stdInput.begin(),stdInput.end()); +// +// int offset = 100; +// +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); +// +// std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); +// bolt::amp::transform(ctl, boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); +// +// cmpArrays( stdInput, boltInput); +// +//} +// +//TEST( DVIntVector, OffsetTransform ) +//{ +// int length = 1024; +// +// std::vector stdInput( length ,1); +// bolt::amp::device_vector boltInput(stdInput.begin(),stdInput.end()); +// +// int offset = 100; +// +// std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); +// bolt::amp::transform( boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); +// +// cmpArrays( stdInput, boltInput); +// +//} +// +//TEST( DVIntVector, SerialOffsetTransform ) +//{ +// int length = 1024; +// +// std::vector stdInput( length ,1); +// bolt::amp::device_vector boltInput(stdInput.begin(),stdInput.end()); +// +// int offset = 100; +// +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::SerialCpu); +// +// std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); +// bolt::amp::transform( ctl, boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); +// +// cmpArrays( stdInput, boltInput); +// +//} +// +//TEST( DVIntVector, MulticoreOffsetTransform ) +//{ +// int length = 1024; +// +// std::vector stdInput( length ,1); +// bolt::amp::device_vector boltInput(stdInput.begin(),stdInput.end()); +// +// int offset = 100; +// +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); +// +// std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); +// bolt::amp::transform( ctl, boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); +// +// cmpArrays( stdInput, boltInput); +// +//} +// +//TEST_P( TransformIntegerVector, InplaceTransform ) +//{ +// // Calling the actual functions under test +// std::transform( stdInput.begin(), stdInput.end(), stdInput.begin(), std::negate()); +// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); +// +// +// +// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); +// std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin( ),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +//TEST_P( TransformIntegerVector, SerialInplaceTransform ) +//{ +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::SerialCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin(), stdInput.end(), stdInput.begin(), std::negate()); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); +// +// +// +// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); +// std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin( ),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +//TEST_P( TransformIntegerVector, MulticoreInplaceTransform ) +//{ +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin(), stdInput.end(), stdInput.begin(), std::negate()); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); +// +// +// +// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); +// std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin( ),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +// +// +//TEST_P( TransformIntegerDeviceVector, InplaceTransform ) +//{ +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); +// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); +// +// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); +// std::vector< int >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +//TEST_P( TransformIntegerDeviceVector, SerialInplaceTransform ) +//{ +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::SerialCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); +// +// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); +// std::vector< int >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +//TEST_P( TransformIntegerDeviceVector, MulticoreInplaceTransform ) +//{ +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); +// +// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); +// std::vector< int >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +// +// +//TEST_P( TransformFloatVector, InplaceTransform ) +//{ +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); +// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); +// +// +// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); +// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +//TEST_P( TransformFloatVector, SerialInplaceTransform ) +//{ +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::SerialCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); +// +// +// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); +// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +//TEST_P( TransformFloatVector, MulticoreInplaceTransform ) +//{ +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); +// +// +// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); +// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +// +//TEST_P( TransformFloatDeviceVector, InplaceTransform ) +//{ +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); +// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); +// +// +// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); +// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +//TEST_P( TransformFloatDeviceVector, SerialInplaceTransform ) +//{ +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::SerialCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); +// +// +// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); +// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +//TEST_P( TransformFloatDeviceVector, MulticoreInplaceTransform ) +//{ +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); +// +// +// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); +// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +// +//TEST_P( TransformFloatVector, InplaceSquareTransform ) +//{ +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); +// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); +// +// +// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); +// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +//TEST_P( TransformFloatVector, SerialInplaceSquareTransform ) +//{ +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::SerialCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); +// +// +// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); +// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +//TEST_P( TransformFloatVector, MulticoreInplaceSquareTransform ) +//{ +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); +// +// +// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); +// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +// +//TEST_P( TransformFloatDeviceVector, InplaceSquareTransform ) +//{ +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); +// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); +// +// +// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); +// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +//TEST_P( TransformFloatDeviceVector, SerialInplaceSquareTransform ) +//{ +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::SerialCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); +// +// +// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); +// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +//TEST_P( TransformFloatDeviceVector, MulticoreInplaceSquareTransform ) +//{ +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); +// +// +// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); +// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +// +// +//TEST_P( TransformFloatVector, InplaceCubeTransform ) +//{ +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); +// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); +// +// +// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); +// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +//TEST_P( TransformFloatVector, SerialInplaceCubeTransform ) +//{ +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::SerialCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); +// +// +// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ),stdInput.end()); +// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +//TEST_P( TransformFloatVector, MulticoreInplaceCubeTransform ) +//{ +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); +// +// +// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); +// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +// +//TEST_P( TransformFloatDeviceVector, InplaceCubeTransform ) +//{ +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); +// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); +// +// +// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); +// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +//TEST_P( TransformFloatDeviceVector, SerialInplaceCubeTransform ) +//{ +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::SerialCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); +// +// +// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ),stdInput.end()); +// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +//TEST_P( TransformFloatDeviceVector, MulticoreInplaceCubeTransform ) +//{ +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); +// +// +// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); +// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +// +// +//#if(TEST_DOUBLE == 1) +//TEST_P( TransformDoubleVector, InplaceTransform ) +//{ +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); +// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); +// +// +// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); +// std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +//TEST_P( TransformDoubleVector, SerialInplaceTransform ) +//{ +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::SerialCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); +// +// +// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); +// std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +//TEST_P( TransformDoubleVector, MulticoreInplaceTransform ) +//{ +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate()); +// +// +// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); +// std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +// +// +//TEST_P( TransformDoubleDeviceVector, InplaceTransform ) +//{ +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); +// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); +// +// +// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); +// std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +//TEST_P( TransformDoubleDeviceVector, SerialInplaceTransform ) +//{ +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::SerialCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); +// +// +// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); +// std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +//TEST_P( TransformDoubleDeviceVector, MulticoreInplaceTransform ) +//{ +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); +// +// // Calling the actual functions under test +// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); +// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate()); +// +// +// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); +// std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); +// +// // Both collections should have the same number of elements +// EXPECT_EQ( stdNumElements, boltNumElements ); +// +// // Loop through the array and compare all the values with each other +// cmpArrays( stdInput, boltInput ); +//} +// +//#endif +// +//TEST( TransformDeviceVector, UDDOutOfPlaceTransform) +//{ +// int length = 1<<8; +// std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); +// std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); +// std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); +// std::fill( hVectorB.begin(), hVectorB.end(), 0 ); +// +// bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), +// dVectorB(hVectorB.begin(), hVectorB.end()), +// dVectorO(hVectorO.begin(), hVectorO.end()); +// +// std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< UDD >( ) ); +// bolt::amp::transform( dVectorA.begin(), +// dVectorA.end(), +// dVectorB.begin(), +// dVectorO.begin(), +// bolt::amp::plus< UDD >( ) ); +// +// cmpArrays(hVectorO, dVectorO); +// +//} +// +//TEST( TransformDeviceVector, SerialUDDOutOfPlaceTransform) +//{ +// int length = 1<<8; +// std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); +// std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); +// std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); +// std::fill( hVectorB.begin(), hVectorB.end(), 0 ); +// +// bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), +// dVectorB(hVectorB.begin(), hVectorB.end()), +// dVectorO(hVectorO.begin(), hVectorO.end()); +// +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::SerialCpu); +// +// std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< UDD >( ) ); +// bolt::amp::transform( ctl, dVectorA.begin(), +// dVectorA.end(), +// dVectorB.begin(), +// dVectorO.begin(), +// bolt::amp::plus< UDD >( ) ); +// +// cmpArrays(hVectorO, dVectorO); +// +//} +// +// +//TEST( TransformDeviceVector, MulticoreUDDOutOfPlaceTransform) +//{ +// int length = 1<<8; +// std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); +// std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); +// std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); +// std::fill( hVectorB.begin(), hVectorB.end(), 0 ); +// +// bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), +// dVectorB(hVectorB.begin(), hVectorB.end()), +// dVectorO(hVectorO.begin(), hVectorO.end()); +// +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); +// +// std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< UDD >( ) ); +// bolt::amp::transform( ctl, dVectorA.begin(), +// dVectorA.end(), +// dVectorB.begin(), +// dVectorO.begin(), +// bolt::amp::plus< UDD >( ) ); +// +// cmpArrays(hVectorO, dVectorO); +// +//} +// +// +//TEST( TransformDeviceVector, OutOfPlaceTransform) +//{ +// int length = 1<<8; +// std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); +// std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); +// std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); +// std::fill( hVectorB.begin(), hVectorB.end(), 0 ); +// +// bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), +// dVectorB(hVectorB.begin(), hVectorB.end()), +// dVectorO(hVectorO.begin(), hVectorO.end()); +// +// std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); +// bolt::amp::transform( dVectorA.begin(), +// dVectorA.end(), +// dVectorB.begin(), +// dVectorO.begin(), +// bolt::amp::plus< int >( ) ); +// +// cmpArrays(hVectorO, dVectorO); +// +//} +// +//TEST( TransformDeviceVector, SerialOutOfPlaceTransform) +//{ +// int length = 1<<8; +// std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); +// std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); +// std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); +// std::fill( hVectorB.begin(), hVectorB.end(), 0 ); +// +// bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), +// dVectorB(hVectorB.begin(), hVectorB.end()), +// dVectorO(hVectorO.begin(), hVectorO.end()); +// +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::SerialCpu); +// +// std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); +// bolt::amp::transform(ctl, dVectorA.begin(), +// dVectorA.end(), +// dVectorB.begin(), +// dVectorO.begin(), +// bolt::amp::plus< int >( ) ); +// +// cmpArrays(hVectorO, dVectorO); +// +// +// +//} +//TEST( TransformDeviceVector, MulticoreOutOfPlaceTransform) +//{ +// int length = 1<<8; +// std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); +// std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); +// std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); +// std::fill( hVectorB.begin(), hVectorB.end(), 0 ); +// +// bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), +// dVectorB(hVectorB.begin(), hVectorB.end()), +// dVectorO(hVectorO.begin(), hVectorO.end()); +// +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); +// +// std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); +// bolt::amp::transform(ctl, dVectorA.begin(), +// dVectorA.end(), +// dVectorB.begin(), +// dVectorO.begin(), +// bolt::amp::plus< int >( ) ); +// +// cmpArrays(hVectorO, dVectorO); +//} +// +//TEST( TransformStdVector, OutOfPlaceTransform) +//{ +// int length = 1<<8; +// std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); +// std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); +// std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); +// std::fill( hVectorB.begin(), hVectorB.end(), 0 ); +// +// std::vector SVectorA(hVectorA.begin(), hVectorA.end()), +// SVectorB(hVectorB.begin(), hVectorB.end()), +// SVectorO(hVectorO.begin(), hVectorO.end()); +// +// std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); +// bolt::amp::transform( SVectorA.begin(), +// SVectorA.end(), +// SVectorB.begin(), +// SVectorO.begin(), +// bolt::amp::plus< int >( ) ); +// +// cmpArrays(hVectorO, SVectorO); +// } +//TEST( TransformStdVector, SerialOutOfPlaceTransform) +//{ +// int length = 1<<8; +// std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); +// std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); +// std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); +// std::fill( hVectorB.begin(), hVectorB.end(), 0 ); +// +// std::vector SVectorA(hVectorA.begin(), hVectorA.end()), +// SVectorB(hVectorB.begin(), hVectorB.end()), +// SVectorO(hVectorO.begin(), hVectorO.end()); +// +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::SerialCpu); +// +// std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); +// bolt::amp::transform(ctl, SVectorA.begin(), +// SVectorA.end(), +// SVectorB.begin(), +// SVectorO.begin(), +// bolt::amp::plus< int >( ) ); +// +// cmpArrays(hVectorO, SVectorO); +// } +//TEST( TransformStdVector, MulticoreOutOfPlaceTransform) +//{ +// int length = 1<<8; +// std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); +// std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); +// std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); +// std::fill( hVectorB.begin(), hVectorB.end(), 0 ); +// +// std::vector SVectorA(hVectorA.begin(), hVectorA.end()), +// SVectorB(hVectorB.begin(), hVectorB.end()), +// SVectorO(hVectorO.begin(), hVectorO.end()); +// +// bolt::amp::control ctl = bolt::amp::control::getDefault( ); +// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); +// +// std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); +// bolt::amp::transform(ctl, SVectorA.begin(), +// SVectorA.end(), +// SVectorB.begin(), +// SVectorO.begin(), +// bolt::amp::plus< int >( ) ); +// +// cmpArrays(hVectorO, SVectorO); +// } +// +//TEST( DVIntVector, OffsetIntTest ) +//{ +// int length = 1024; +// +// std::vector stdInput( length ,1); +// bolt::amp::device_vector boltInput(stdInput.begin(),stdInput.end()); +// +// int offset = 100; +// +// std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); +// bolt::amp::transform( boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); +// +// cmpArrays( stdInput, boltInput); +// +//} +// +//TEST( DVIntVector, OffsetDoubleTest ) +//{ +// int length = 1024; +// +// std::vector stdInput( length ,4.0); +// bolt::amp::device_vector boltInput(stdInput.begin(),stdInput.end()); +// +// int offset = 100; +// +// std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); +// bolt::amp::transform( boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); +// +// cmpArrays( stdInput, boltInput); +// +//} +// +// +//// Test lots of consecutive numbers, but small range, suitable for integers because they overflow easier +//INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformIntegerVector, ::testing::Range( 0, 1024, 1 ) ); +//INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformIntegerDeviceVector, ::testing::Range( 0, 1024, 1 ) ); +// +//// Test a huge range, suitable for floating point as they are less prone to overflow (but floating point +//// loses granularity at large values) +//INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformFloatVector, ::testing::Range( 0, 1048576, 4096 ) ); +//INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformFloatDeviceVector, ::testing::Range( 0, 1048576, 4096 ) ); +// +//INSTANTIATE_TEST_CASE_P( InplaceSquareTransform, TransformFloatVector, ::testing::Range( 0, 1048576, 4096 ) ); +//INSTANTIATE_TEST_CASE_P( InplaceSquareTransform, TransformFloatDeviceVector, ::testing::Range( 0, 1048576, 4096 ) ); +// +//INSTANTIATE_TEST_CASE_P( InplaceCubeTransform, TransformFloatVector, ::testing::Range( 0, 1048576, 4096 ) ); +//INSTANTIATE_TEST_CASE_P( InplaceCubeTransform, TransformFloatDeviceVector, ::testing::Range( 0, 1048576, 4096 ) ); +// +//#if(TEST_DOUBLE == 1) +//INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformDoubleVector, ::testing::Range( 0, 1048576, 4096 ) ); +//INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformDoubleDeviceVector, ::testing::Range( 0, 1048576, 4096 ) ); +// +//INSTANTIATE_TEST_CASE_P( InplaceTransform, TransformDoubleVector, ::testing::Range( 0, 1048576, 4096 ) ); +//INSTANTIATE_TEST_CASE_P( InplaceTransform, TransformDoubleDeviceVector, ::testing::Range( 0, 1048576, 4096 ) ); +// +//#endif +//typedef ::testing::Types< +// std::tuple< int, TypeValue< 1 > >, +// std::tuple< int, TypeValue< 31 > >, +// std::tuple< int, TypeValue< 32 > >, +// std::tuple< int, TypeValue< 63 > >, +// std::tuple< int, TypeValue< 64 > >, +// std::tuple< int, TypeValue< 127 > >, +// std::tuple< int, TypeValue< 128 > >, +// std::tuple< int, TypeValue< 129 > >, +// std::tuple< int, TypeValue< 1000 > >, +// std::tuple< int, TypeValue< 1053 > >, +// std::tuple< int, TypeValue< 4096 > >, +// std::tuple< int, TypeValue< 4097 > >, +// std::tuple< int, TypeValue< 65535 > >, +// std::tuple< int, TypeValue< 65536 > > +//> IntegerTests; +// +//typedef ::testing::Types< +// std::tuple< float, TypeValue< 1 > >, +// std::tuple< float, TypeValue< 31 > >, +// std::tuple< float, TypeValue< 32 > >, +// std::tuple< float, TypeValue< 63 > >, +// std::tuple< float, TypeValue< 64 > >, +// std::tuple< float, TypeValue< 127 > >, +// std::tuple< float, TypeValue< 128 > >, +// std::tuple< float, TypeValue< 129 > >, +// std::tuple< float, TypeValue< 1000 > >, +// std::tuple< float, TypeValue< 1053 > >, +// std::tuple< float, TypeValue< 4096 > >, +// std::tuple< float, TypeValue< 4097 > >, +// std::tuple< float, TypeValue< 65535 > >, +// std::tuple< float, TypeValue< 65536 > > +//> FloatTests; +// +// +////typedef ::testing::Types< +//// std::tuple< UDD, TypeValue< 1 > >, +//// std::tuple< UDD, TypeValue< 31 > >, +//// std::tuple< UDD, TypeValue< 32 > >, +//// std::tuple< UDD, TypeValue< 63 > >, +//// std::tuple< UDD, TypeValue< 64 > >, +//// std::tuple< UDD, TypeValue< 127 > >, +//// std::tuple< UDD, TypeValue< 128 > >, +//// std::tuple< UDD, TypeValue< 129 > >, +//// std::tuple< UDD, TypeValue< 1000 > >, +//// std::tuple< UDD, TypeValue< 1053 > >, +//// std::tuple< UDD, TypeValue< 4096 > >, +//// std::tuple< UDD, TypeValue< 4097 > >, +//// std::tuple< UDD, TypeValue< 65535 > >, +//// std::tuple< UDD, TypeValue< 65536 > > +////> UDDTests; + + +TEST(TransformStdVector, ConstantIterator) +{ + int length = 1 << 8; + std::vector hVectorA(length), hVectorO(length), hVectorB(length); + bolt::amp::constant_iterator hB(100); + bolt::amp::constant_iterator hB2 = hB + length; + + std::fill(hVectorA.begin(), hVectorA.end(), 1024); + std::fill(hVectorB.begin(), hVectorB.end(), 100); + + std::vector SVectorA(hVectorA.begin(), hVectorA.end()), + SVectorO(hVectorO.begin(), hVectorO.end()); - template - static void printA2(const char * msg, const Container &a, const Container &b, int x_size) - { - std::wcout << msg << std::endl; - for (int i = 0; i < x_size; i++) - std::wcout << a[i] << "\t" << b[i] << std::endl; - }; - - static void printA(const char * msg, const int *a, int x_size) - { - std::wcout << msg << std::endl; - for (int i = 0; i < x_size; i++) - std::wcout << a[i] << std::endl; - }; - - - - /* - * Demonstrates: - * Use of bolt::transform function - * Bolt delivers same result as stl::transform - * Bolt syntax is similar to STL transform - * Works for both integer arrays and STL vectors - */ - void simpleTransform1() - { - const int aSize = 16; - int a[aSize] = {4,0,5,5,0,5,5,1,3,1,0,3,1,1,3,5}; - int b[aSize] = {1,9,0,8,6,1,7,7,1,0,1,3,5,7,9,8}; - int out[aSize]; - std::transform(a,a+aSize, out, std::negate()); - bolt::amp::transform(a, a+aSize, out, bolt::negate()); - printA2("Transform Neg - From Pointer", a, out, aSize); - - bolt::amp::transform(a, a+aSize, b, out, bolt::plus()); - printA("\nTransformVaddOut", out, aSize); - - static const int vSz=16; - std::vector vec(16); - std::generate(vec.begin(), vec.end(), rand); - std::vector outVec(16); - //std::transform(vec.begin(),vec.end(), outVec.begin(), std::negate()); - bolt::amp::transform(vec.begin(),vec.end(), outVec.begin(), bolt::negate()); - std::cout<<"Printing"; - for(unsigned int i=0; i < 16; i++) - std::cout< - void simpleTransform2(const int sz) - { - std::vector A(sz); - std::vector S(sz); - std::vector B(sz); - - for (int i=0; i < sz; i++) { - //A[i] = T(i); // sequential assignment - A[i] = T(rand())/137; // something a little more exciting. - }; - - std::transform (A.begin(), A.end(), S.begin(), std::negate()); // single-core CPU version - bolt::amp::transform(A.begin(), A.end(), B.begin(), bolt::negate()); // bolt version on GPU or mcore CPU. - - // Check result: - const int maxErrCount = 10; - int errCount = 0; - for (unsigned x=0; x< S.size(); x++) { - const T s = S[x]; - const T b = B[x]; - //std::cout << s << "," << b << std::endl; - if ((s != b) && (++errCount < maxErrCount)) { - std::cout << "ERROR#" << errCount << " " << s << "!=" << b << std::endl; - }; - }; - }; - - - //// Show use of Saxpy Functor object. - //struct SaxpyFunctor - //{ - // float _a; - // SaxpyFunctor(float a) : _a(a) {}; - - // float operator() (const float &xx, const float &yy) restrict(cpu,amp) - // { - // return _a * xx + yy; - // }; - - //}; - - - //void transformSaxpy(int aSize) - //{ - // std::string fName = __FUNCTION__ ; - // fName += ":"; - - // std::vector A(aSize), B(aSize), Z1(aSize), Z0(aSize); - - // for (int i=0; i(128); - simpleTransform2(1000); - simpleTransform2(100000); - - // transformSaxpy(256); - }; - - - int _tmain(int argc, _TCHAR* argv[]) - { - simpleTransform(); - return 0; - } - - -#else - -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// Fixture classes are now defined to enable googletest to process type parameterized tests - -// This class creates a C++ 'TYPE' out of a size_t value -template< size_t N > -class TypeValue -{ -public: - static const size_t value = N; -}; - -// Explicit initialization of the C++ static const -template< size_t N > -const size_t TypeValue< N >::value; - -// Test fixture class, used for the Type-parameterized tests -// Namely, the tests that use std::array and TYPED_TEST_P macros -template< typename ArrayTuple > -class TransformArrayTest: public ::testing::Test -{ -public: - TransformArrayTest( ): m_Errors( 0 ) - {} - - virtual void SetUp( ) - { - for( int i=0; i < ArraySize; i++ ) - { - stdInput[ i ] = 1; - boltInput[ i ] = 1; - } - }; - - virtual void TearDown( ) - {}; - - virtual ~TransformArrayTest( ) - {} - -//protected: - - typedef typename std::tuple_element< 0, ArrayTuple >::type ArrayType; - static const size_t ArraySize = typename std::tuple_element< 1, ArrayTuple >::type::value; - - typename std::array< ArrayType, ArraySize > stdInput, boltInput; - int m_Errors; -}; - -template< typename ArrayTuple > -class TransformBinaryArrayTest: public ::testing::Test -{ -public: - TransformBinaryArrayTest( ): m_Errors( 0 ) - {} - - virtual void SetUp( ) - { - for( int i=0; i < ArraySize; i++ ) - { - stdInput1[ i ] = 1; - stdInput2[ i ] = 1; - stdOutput[ i ] = 0; - boltInput1[ i ] = 1; - boltInput2[ i ] = 1; - boltOutput[ i ] = 0; - } - }; - - virtual void TearDown( ) - {}; - - virtual ~TransformBinaryArrayTest( ) - {} - -protected: - typedef typename std::tuple_element< 0, ArrayTuple >::type ArrayType; - static const size_t ArraySize = typename std::tuple_element< 1, ArrayTuple >::type::value; - - typename std::array< ArrayType, ArraySize > stdInput1, stdInput2, stdOutput,boltInput1, boltInput2, boltOutput; - int m_Errors; -}; - -template< typename ArrayTuple > -class TransformOutPlaceArrayTest: public ::testing::Test -{ -public: - TransformOutPlaceArrayTest( ): m_Errors( 0 ) - {} - - virtual void SetUp( ) - { - for( int i=0; i < ArraySize; i++ ) - { - stdInput[ i ] = 1; - stdOutput[ i ] = 0; - boltInput[ i ] = 1; - boltOutput[ i ] = 0; - } - }; - - virtual void TearDown( ) - {}; - - virtual ~TransformOutPlaceArrayTest( ) - {} - -protected: - typedef typename std::tuple_element< 0, ArrayTuple >::type ArrayType; - static const size_t ArraySize = typename std::tuple_element< 1, ArrayTuple >::type::value; - - typename std::array< ArrayType, ArraySize > stdInput, stdOutput, boltInput, boltOutput; - int m_Errors; -}; - -// Explicit initialization of the C++ static const -template< typename ArrayTuple > -const size_t TransformArrayTest< ArrayTuple >::ArraySize; - -template< typename ArrayTuple > -const size_t TransformBinaryArrayTest< ArrayTuple >::ArraySize; - -template< typename ArrayTuple > -const size_t TransformOutPlaceArrayTest< ArrayTuple >::ArraySize; - - -TYPED_TEST_CASE_P( TransformArrayTest ); -TYPED_TEST_CASE_P( TransformBinaryArrayTest ); -TYPED_TEST_CASE_P( TransformOutPlaceArrayTest ); - - -TYPED_TEST_P( TransformArrayTest, InPlaceNegateTransform ) -{ - typedef std::array< ArrayType, ArraySize > ArrayCont; - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); - bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); - - ArrayCont::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end( ) ); - ArrayCont::difference_type boltNumElements = std::distance( boltInput.begin( ), boltInput.end( ) ); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdInput, boltInput ); -} -TYPED_TEST_P( TransformArrayTest, SerialInPlaceNegateTransform ) -{ - typedef std::array< ArrayType, ArraySize > ArrayCont; - - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::SerialCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ),bolt::amp::negate()); - - ArrayCont::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end( ) ); - ArrayCont::difference_type boltNumElements = std::distance( boltInput.begin( ), boltInput.end( ) ); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdInput, boltInput ); -} -TYPED_TEST_P( TransformArrayTest, MulticoreInPlaceNegateTransform ) -{ - typedef std::array< ArrayType, ArraySize > ArrayCont; - - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ),bolt::amp::negate()); - - ArrayCont::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end( ) ); - ArrayCont::difference_type boltNumElements = std::distance( boltInput.begin( ), boltInput.end( ) ); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdInput, boltInput ); -} - - - - -TYPED_TEST_P( TransformBinaryArrayTest, BinaryPlusTransform ) -{ - typedef std::array< ArrayType, ArraySize > ArrayCont; - - // Calling the actual functions under test - std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), - std::plus< ArrayType >( ) ); - bolt::amp::transform( boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), - bolt::amp::plus< ArrayType >( ) ); - - ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); - ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -} -TYPED_TEST_P( TransformBinaryArrayTest, SerialBinaryPlusTransform ) -{ - typedef std::array< ArrayType, ArraySize > ArrayCont; - - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::SerialCpu); - - // Calling the actual functions under test - std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), - std::plus< ArrayType >( ) ); - bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), - bolt::amp::plus< ArrayType >( ) ); - - ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); - ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -} -TYPED_TEST_P( TransformBinaryArrayTest, MulticoreBinaryPlusTransform ) -{ - typedef std::array< ArrayType, ArraySize > ArrayCont; - - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); - - // Calling the actual functions under test - std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), - std::plus< ArrayType >( ) ); - bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), - bolt::amp::plus< ArrayType >( ) ); - - ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); - ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -} - - - -TYPED_TEST_P( TransformBinaryArrayTest, BinaryMultipliesTransform ) -{ - typedef std::array< ArrayType, ArraySize > ArrayCont; - - // Calling the actual functions under test - std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), - std::multiplies< ArrayType >( ) ); - bolt::amp::transform( boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), - bolt::amp::multiplies< ArrayType >( ) ); - - ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); - ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -} -TYPED_TEST_P( TransformBinaryArrayTest, SerialBinaryMultipliesTransform ) -{ - typedef std::array< ArrayType, ArraySize > ArrayCont; - - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::SerialCpu); - - // Calling the actual functions under test - std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), - std::multiplies< ArrayType >( ) ); - bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), - bolt::amp::multiplies< ArrayType >( ) ); - - ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); - ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -} -TYPED_TEST_P( TransformBinaryArrayTest, MulticoreBinaryMultipliesTransform ) -{ - typedef std::array< ArrayType, ArraySize > ArrayCont; - - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); - - // Calling the actual functions under test - std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), - std::multiplies< ArrayType >( ) ); - bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), - bolt::amp::multiplies< ArrayType >( ) ); - - ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); - ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -} - - -TYPED_TEST_P( TransformBinaryArrayTest, BinaryMaxTransform ) -{ - typedef std::array< ArrayType, ArraySize > ArrayCont; - - // Calling the actual functions under test - std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), [] (ArrayType lhs, - ArrayType rhs) { return rhs > lhs ? rhs:lhs; } ); - bolt::amp::transform( boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), - bolt::amp::maximum< ArrayType >( ) ); - - ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); - ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -} -TYPED_TEST_P( TransformBinaryArrayTest, SerialBinaryMaxTransform ) -{ - typedef std::array< ArrayType, ArraySize > ArrayCont; - - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::SerialCpu); - - // Calling the actual functions under test - std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), [] (ArrayType lhs, - ArrayType rhs) { return rhs > lhs ? rhs:lhs; } ); - bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), - bolt::amp::maximum< ArrayType >( ) ); - - ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); - ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -} -TYPED_TEST_P( TransformBinaryArrayTest, MulticoreBinaryMaxTransform ) -{ - typedef std::array< ArrayType, ArraySize > ArrayCont; - - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); - - // Calling the actual functions under test - std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), [] (ArrayType lhs, - ArrayType rhs) { return rhs > lhs ? rhs:lhs; } ); - bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), - bolt::amp::maximum< ArrayType >( ) ); - - ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); - ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -} - - - -TYPED_TEST_P( TransformOutPlaceArrayTest, OutPlaceSquareTransform ) -{ - typedef std::array< ArrayType, ArraySize > ArrayCont; - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdOutput.begin(), []( ArrayType x ) {return x*x;} ); - bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltOutput.begin(), bolt::amp::square< ArrayType >()); - - - ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin(), stdOutput.end() ); - ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin(), boltOutput.end() ); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -} -TYPED_TEST_P( TransformOutPlaceArrayTest, SerialOutPlaceSquareTransform ) -{ - typedef std::array< ArrayType, ArraySize > ArrayCont; - - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::SerialCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdOutput.begin(), []( ArrayType x ) {return x*x;} ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltOutput.begin(), - bolt::amp::square< ArrayType >( ) ); - - - ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin(), stdOutput.end() ); - ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin(), boltOutput.end() ); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -} -TYPED_TEST_P( TransformOutPlaceArrayTest, MulticoreOutPlaceSquareTransform ) -{ - typedef std::array< ArrayType, ArraySize > ArrayCont; - - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdOutput.begin(), []( ArrayType x ) {return x*x;} ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltOutput.begin(), - bolt::amp::square< ArrayType >( ) ); - - - ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin(), stdOutput.end() ); - ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin(), boltOutput.end() ); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -} - - -struct UDD -{ - int a; - int b; - - bool operator() (const UDD& lhs, const UDD& rhs) const restrict(amp,cpu){ - return ((lhs.a+lhs.b) > (rhs.a+rhs.b)); - } - bool operator < (const UDD& other) const restrict(amp,cpu){ - return ((a+b) < (other.a+other.b)); - } - bool operator > (const UDD& other) const restrict(amp,cpu){ - return ((a+b) > (other.a+other.b)); - } - bool operator == (const UDD& other) const restrict(amp,cpu) { - return ((a+b) == (other.a+other.b)); - } - - UDD operator + (const UDD &rhs) const restrict(amp,cpu) - { - UDD _result; - _result.a = a + rhs.a; - _result.b = b + rhs.b; - return _result; - } - - - UDD() restrict(amp,cpu) - : a(0),b(0) { } - UDD(int _in) restrict(amp,cpu) - : a(_in), b(_in +1) { } -}; - - - -REGISTER_TYPED_TEST_CASE_P( TransformArrayTest, InPlaceNegateTransform, SerialInPlaceNegateTransform, - MulticoreInPlaceNegateTransform ); -REGISTER_TYPED_TEST_CASE_P( TransformOutPlaceArrayTest, OutPlaceSquareTransform, SerialOutPlaceSquareTransform, - MulticoreOutPlaceSquareTransform ); -REGISTER_TYPED_TEST_CASE_P( TransformBinaryArrayTest, BinaryPlusTransform, SerialBinaryPlusTransform, - MulticoreBinaryPlusTransform, BinaryMultipliesTransform, - SerialBinaryMultipliesTransform, MulticoreBinaryMultipliesTransform, - BinaryMaxTransform, SerialBinaryMaxTransform, MulticoreBinaryMaxTransform); - - -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// Fixture classes are now defined to enable googletest to process value parameterized tests - -// ::testing::TestWithParam< int > means that GetParam( ) returns int values, which i use for array size -class TransformIntegerVector: public ::testing::TestWithParam< int > -{ -public: - // Create an std and a bolt vector of requested size, and initialize all the elements to 1 - TransformIntegerVector( ): stdInput( GetParam( ), 1 ), boltInput( GetParam( ), 1 ) - {} - -protected: - std::vector< int > stdInput, boltInput; -}; - -class TransformIntegerDeviceVector: public ::testing::TestWithParam< int > -{ -public: - // Create an std and a bolt vector of requested size, and initialize all the elements to 1 - TransformIntegerDeviceVector( ): stdInput( GetParam( ), 1 ), boltInput(static_cast(GetParam( )), 1 ) - { - std::generate(stdInput.begin(), stdInput.end(), rand); - //boltInput = stdInput; - //FIXME - The above should work but the below loop is used. - for (int i=0; i< GetParam( ); i++) - { - boltInput[i] = stdInput[i]; - - } - } - -protected: - std::vector< int > stdInput; - bolt::amp::device_vector< int > boltInput; -}; - -// ::testing::TestWithParam< int > means that GetParam( ) returns int values, which i use for array size -class TransformFloatVector: public ::testing::TestWithParam< int > -{ -public: - // Create an std and a bolt vector of requested size, and initialize all the elements to 1 - TransformFloatVector( ): stdInput( GetParam( ), 1.0f ), boltInput( GetParam( ), 1.0f ) - {} - -protected: - std::vector< float > stdInput, boltInput; -}; - - -class TransformFloatDeviceVector: public ::testing::TestWithParam< int > -{ -public: - // Create an std and a bolt vector of requested size, and initialize all the elements to 1 - TransformFloatDeviceVector( ): stdInput( GetParam( ), 1.0f ), boltInput( static_cast( GetParam( ) ), 1.0f ) - { - std::generate(stdInput.begin(), stdInput.end(), rand); - //boltInput = stdInput; - //FIXME - The above should work but the below loop is used. - for (int i=0; i< GetParam( ); i++) - { - boltInput[i] = stdInput[i]; - } - - } - -protected: - std::vector< float > stdInput; - bolt::amp::device_vector< float > boltInput; -}; -// ::testing::TestWithParam< int > means that GetParam( ) returns int values, which i use for array size -class TransformDoubleVector: public ::testing::TestWithParam< int > -{ -public: - // Create an std and a bolt vector of requested size, and initialize all the elements to 1 - TransformDoubleVector( ): stdInput( GetParam( ), 1.0 ), boltInput( GetParam( ), 1.0 ) - {} - -protected: - std::vector< double > stdInput, boltInput; -}; - - -#if (TEST_DOUBLE == 1) -// ::testing::TestWithParam< int > means that GetParam( ) returns int values, which i use for array size -class TransformDoubleDeviceVector: public ::testing::TestWithParam< int > -{ -public: - // Create an std and a bolt vector of requested size, and initialize all the elements to 1 - TransformDoubleDeviceVector( ): stdInput( GetParam( ), 1.0 ), boltInput( static_cast( GetParam( ) ), 1.0 ) - { - std::generate(stdInput.begin(), stdInput.end(), rand); - //boltInput = stdInput; - //FIXME - The above should work but the below loop is used. - for (int i=0; i< GetParam( ); i++) - { - boltInput[i] = stdInput[i]; - } - } - -protected: - std::vector< double > stdInput; - bolt::amp::device_vector< double > boltInput; -}; -#endif - - -TEST( HostIntVector, OffsetTransform ) -{ - int length = 1024; - - std::vector stdInput( length ,1); - std::vector boltInput(stdInput.begin(),stdInput.end()); - - int offset = 100; - - std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); - bolt::amp::transform( boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); - - cmpArrays( stdInput, boltInput); - -} - -TEST( HostIntVector, SerialOffsetTransform ) -{ - int length = 1024; - - std::vector stdInput( length ,1); - std::vector boltInput(stdInput.begin(),stdInput.end()); - - int offset = 100; - - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::SerialCpu); - - std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); - bolt::amp::transform(ctl, boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); - - cmpArrays( stdInput, boltInput); - -} - -TEST( HostIntVector, MulticoreOffsetTransform ) -{ - int length = 1024; - - std::vector stdInput( length ,1); - std::vector boltInput(stdInput.begin(),stdInput.end()); - - int offset = 100; - - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); - - std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); - bolt::amp::transform(ctl, boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); - - cmpArrays( stdInput, boltInput); - -} - -TEST( DVIntVector, OffsetTransform ) -{ - int length = 1024; - - std::vector stdInput( length ,1); - bolt::amp::device_vector boltInput(stdInput.begin(),stdInput.end()); - - int offset = 100; - - std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); - bolt::amp::transform( boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); - - cmpArrays( stdInput, boltInput); - -} - -TEST( DVIntVector, SerialOffsetTransform ) -{ - int length = 1024; - - std::vector stdInput( length ,1); - bolt::amp::device_vector boltInput(stdInput.begin(),stdInput.end()); - - int offset = 100; - - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::SerialCpu); - - std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); - bolt::amp::transform( ctl, boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); - - cmpArrays( stdInput, boltInput); - -} - -TEST( DVIntVector, MulticoreOffsetTransform ) -{ - int length = 1024; - - std::vector stdInput( length ,1); - bolt::amp::device_vector boltInput(stdInput.begin(),stdInput.end()); - - int offset = 100; - - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); - - std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); - bolt::amp::transform( ctl, boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); - - cmpArrays( stdInput, boltInput); - -} - -TEST_P( TransformIntegerVector, InplaceTransform ) -{ - // Calling the actual functions under test - std::transform( stdInput.begin(), stdInput.end(), stdInput.begin(), std::negate()); - bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); - - - - std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); - std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin( ),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} -TEST_P( TransformIntegerVector, SerialInplaceTransform ) -{ - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::SerialCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin(), stdInput.end(), stdInput.begin(), std::negate()); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); - - - - std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); - std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin( ),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} -TEST_P( TransformIntegerVector, MulticoreInplaceTransform ) -{ - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin(), stdInput.end(), stdInput.begin(), std::negate()); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); - - - - std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); - std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin( ),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} - - -TEST_P( TransformIntegerDeviceVector, InplaceTransform ) -{ - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); - bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); - - std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); - std::vector< int >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} -TEST_P( TransformIntegerDeviceVector, SerialInplaceTransform ) -{ - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::SerialCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); - - std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); - std::vector< int >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} -TEST_P( TransformIntegerDeviceVector, MulticoreInplaceTransform ) -{ - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); - - std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); - std::vector< int >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} - - -TEST_P( TransformFloatVector, InplaceTransform ) -{ - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); - bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); - - - std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); - std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} -TEST_P( TransformFloatVector, SerialInplaceTransform ) -{ - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::SerialCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); - - - std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); - std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} -TEST_P( TransformFloatVector, MulticoreInplaceTransform ) -{ - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); - - - std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); - std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} - -TEST_P( TransformFloatDeviceVector, InplaceTransform ) -{ - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); - bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); - - - std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); - std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} -TEST_P( TransformFloatDeviceVector, SerialInplaceTransform ) -{ - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::SerialCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); - - - std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); - std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} -TEST_P( TransformFloatDeviceVector, MulticoreInplaceTransform ) -{ - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); - - - std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); - std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} - -TEST_P( TransformFloatVector, InplaceSquareTransform ) -{ - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); - bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); - - - std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); - std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} -TEST_P( TransformFloatVector, SerialInplaceSquareTransform ) -{ - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::SerialCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); - - - std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); - std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} -TEST_P( TransformFloatVector, MulticoreInplaceSquareTransform ) -{ - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); - - - std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); - std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} - -TEST_P( TransformFloatDeviceVector, InplaceSquareTransform ) -{ - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); - bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); - - - std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); - std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} -TEST_P( TransformFloatDeviceVector, SerialInplaceSquareTransform ) -{ - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::SerialCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); - - - std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); - std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} -TEST_P( TransformFloatDeviceVector, MulticoreInplaceSquareTransform ) -{ - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); - - - std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); - std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} - - -TEST_P( TransformFloatVector, InplaceCubeTransform ) -{ - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); - bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); - - - std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); - std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} -TEST_P( TransformFloatVector, SerialInplaceCubeTransform ) -{ - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::SerialCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); - - - std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ),stdInput.end()); - std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} -TEST_P( TransformFloatVector, MulticoreInplaceCubeTransform ) -{ - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); - - - std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); - std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} - -TEST_P( TransformFloatDeviceVector, InplaceCubeTransform ) -{ - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); - bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); - - - std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); - std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} -TEST_P( TransformFloatDeviceVector, SerialInplaceCubeTransform ) -{ - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::SerialCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); - - - std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ),stdInput.end()); - std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} -TEST_P( TransformFloatDeviceVector, MulticoreInplaceCubeTransform ) -{ - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); - - - std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); - std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} - - -#if(TEST_DOUBLE == 1) -TEST_P( TransformDoubleVector, InplaceTransform ) -{ - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); - bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); - - - std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); - std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} -TEST_P( TransformDoubleVector, SerialInplaceTransform ) -{ - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::SerialCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); - - - std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); - std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} -TEST_P( TransformDoubleVector, MulticoreInplaceTransform ) -{ - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate()); - - - std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); - std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} - - -TEST_P( TransformDoubleDeviceVector, InplaceTransform ) -{ - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); - bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); - - - std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); - std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} -TEST_P( TransformDoubleDeviceVector, SerialInplaceTransform ) -{ - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::SerialCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); - - - std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); - std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} -TEST_P( TransformDoubleDeviceVector, MulticoreInplaceTransform ) -{ - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); - - // Calling the actual functions under test - std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); - bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate()); - - - std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); - std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); - - // Both collections should have the same number of elements - EXPECT_EQ( stdNumElements, boltNumElements ); - - // Loop through the array and compare all the values with each other - cmpArrays( stdInput, boltInput ); -} - -#endif - -TEST( TransformDeviceVector, UDDOutOfPlaceTransform) -{ - int length = 1<<8; - std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); - std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); - std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); - std::fill( hVectorB.begin(), hVectorB.end(), 0 ); - - bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), - dVectorB(hVectorB.begin(), hVectorB.end()), - dVectorO(hVectorO.begin(), hVectorO.end()); - - std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< UDD >( ) ); - bolt::amp::transform( dVectorA.begin(), - dVectorA.end(), - dVectorB.begin(), - dVectorO.begin(), - bolt::amp::plus< UDD >( ) ); - - cmpArrays(hVectorO, dVectorO); - -} - -TEST( TransformDeviceVector, SerialUDDOutOfPlaceTransform) -{ - int length = 1<<8; - std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); - std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); - std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); - std::fill( hVectorB.begin(), hVectorB.end(), 0 ); - - bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), - dVectorB(hVectorB.begin(), hVectorB.end()), - dVectorO(hVectorO.begin(), hVectorO.end()); - - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::SerialCpu); - - std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< UDD >( ) ); - bolt::amp::transform( ctl, dVectorA.begin(), - dVectorA.end(), - dVectorB.begin(), - dVectorO.begin(), - bolt::amp::plus< UDD >( ) ); - - cmpArrays(hVectorO, dVectorO); - -} - - -TEST( TransformDeviceVector, MulticoreUDDOutOfPlaceTransform) -{ - int length = 1<<8; - std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); - std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); - std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); - std::fill( hVectorB.begin(), hVectorB.end(), 0 ); - - bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), - dVectorB(hVectorB.begin(), hVectorB.end()), - dVectorO(hVectorO.begin(), hVectorO.end()); - - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); - - std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< UDD >( ) ); - bolt::amp::transform( ctl, dVectorA.begin(), - dVectorA.end(), - dVectorB.begin(), - dVectorO.begin(), - bolt::amp::plus< UDD >( ) ); - - cmpArrays(hVectorO, dVectorO); - -} - - -TEST( TransformDeviceVector, OutOfPlaceTransform) -{ - int length = 1<<8; - std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); - std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); - std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); - std::fill( hVectorB.begin(), hVectorB.end(), 0 ); - - bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), - dVectorB(hVectorB.begin(), hVectorB.end()), - dVectorO(hVectorO.begin(), hVectorO.end()); + //bolt::amp::device_vector hB(hVectorA.begin(), hVectorA.end()); - std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); - bolt::amp::transform( dVectorA.begin(), - dVectorA.end(), - dVectorB.begin(), - dVectorO.begin(), - bolt::amp::plus< int >( ) ); - - cmpArrays(hVectorO, dVectorO); + std::transform(hVectorB.begin(), hVectorB.end(), hVectorA.begin(), hVectorO.begin(), std::plus< int >()); + //std::transform(hB.begin(), hB.end(), hVectorA.begin(), hVectorO.begin(), std::plus()); + bolt::amp::transform(hB, + hB2, + SVectorA.begin(), + SVectorO.begin(), + bolt::amp::plus< int >()); + cmpArrays(hVectorO, SVectorO); } -TEST( TransformDeviceVector, SerialOutOfPlaceTransform) -{ - int length = 1<<8; - std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); - std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); - std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); - std::fill( hVectorB.begin(), hVectorB.end(), 0 ); - - bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), - dVectorB(hVectorB.begin(), hVectorB.end()), - dVectorO(hVectorO.begin(), hVectorO.end()); - - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::SerialCpu); - - std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); - bolt::amp::transform(ctl, dVectorA.begin(), - dVectorA.end(), - dVectorB.begin(), - dVectorO.begin(), - bolt::amp::plus< int >( ) ); - - cmpArrays(hVectorO, dVectorO); - -} -TEST( TransformDeviceVector, MulticoreOutOfPlaceTransform) +TEST(TransformStdVector, CountingIterator) { - int length = 1<<8; - std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); - std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); - std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); - std::fill( hVectorB.begin(), hVectorB.end(), 0 ); + int length = 1 << 8; + std::vector hVectorA(length), hVectorO(length), hVectorB(length); + bolt::amp::counting_iterator hB(100); + bolt::amp::counting_iterator hB2 = hB + length; - bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), - dVectorB(hVectorB.begin(), hVectorB.end()), - dVectorO(hVectorO.begin(), hVectorO.end()); + std::fill(hVectorA.begin(), hVectorA.end(), 1024); - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + for( int i = 0; i < length ; i++ ) + { + hVectorB[i] = 100 + i; + } - std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); - bolt::amp::transform(ctl, dVectorA.begin(), - dVectorA.end(), - dVectorB.begin(), - dVectorO.begin(), - bolt::amp::plus< int >( ) ); - - cmpArrays(hVectorO, dVectorO); -} - -TEST( TransformStdVector, OutOfPlaceTransform) -{ - int length = 1<<8; - std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); - std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); - std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); - std::fill( hVectorB.begin(), hVectorB.end(), 0 ); - - std::vector SVectorA(hVectorA.begin(), hVectorA.end()), - SVectorB(hVectorB.begin(), hVectorB.end()), + std::vector SVectorA(hVectorA.begin(), hVectorA.end()), SVectorO(hVectorO.begin(), hVectorO.end()); - std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); - bolt::amp::transform( SVectorA.begin(), - SVectorA.end(), - SVectorB.begin(), - SVectorO.begin(), - bolt::amp::plus< int >( ) ); - - cmpArrays(hVectorO, SVectorO); - } -TEST( TransformStdVector, SerialOutOfPlaceTransform) -{ - int length = 1<<8; - std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); - std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); - std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); - std::fill( hVectorB.begin(), hVectorB.end(), 0 ); - - std::vector SVectorA(hVectorA.begin(), hVectorA.end()), - SVectorB(hVectorB.begin(), hVectorB.end()), - SVectorO(hVectorO.begin(), hVectorO.end()); - - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::SerialCpu); - std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); - bolt::amp::transform(ctl, SVectorA.begin(), - SVectorA.end(), - SVectorB.begin(), - SVectorO.begin(), - bolt::amp::plus< int >( ) ); - - cmpArrays(hVectorO, SVectorO); - } -TEST( TransformStdVector, MulticoreOutOfPlaceTransform) -{ - int length = 1<<8; - std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); - std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); - std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); - std::fill( hVectorB.begin(), hVectorB.end(), 0 ); + std::transform(hVectorB.begin(), hVectorB.end(), hVectorA.begin(), hVectorO.begin(), std::plus< int >()); - std::vector SVectorA(hVectorA.begin(), hVectorA.end()), - SVectorB(hVectorB.begin(), hVectorB.end()), - SVectorO(hVectorO.begin(), hVectorO.end()); - - bolt::amp::control ctl = bolt::amp::control::getDefault( ); - ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + bolt::amp::transform(hB, + hB2, + SVectorA.begin(), + SVectorO.begin(), + bolt::amp::plus< int >()); - std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); - bolt::amp::transform(ctl, SVectorA.begin(), - SVectorA.end(), - SVectorB.begin(), - SVectorO.begin(), - bolt::amp::plus< int >( ) ); - cmpArrays(hVectorO, SVectorO); - } - -TEST( DVIntVector, OffsetIntTest ) -{ - int length = 1024; - - std::vector stdInput( length ,1); - bolt::amp::device_vector boltInput(stdInput.begin(),stdInput.end()); - - int offset = 100; - - std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); - bolt::amp::transform( boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); - - cmpArrays( stdInput, boltInput); - -} - -TEST( DVIntVector, OffsetDoubleTest ) -{ - int length = 1024; - - std::vector stdInput( length ,4.0); - bolt::amp::device_vector boltInput(stdInput.begin(),stdInput.end()); - - int offset = 100; - - std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); - bolt::amp::transform( boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); - - cmpArrays( stdInput, boltInput); - } -// Test lots of consecutive numbers, but small range, suitable for integers because they overflow easier -INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformIntegerVector, ::testing::Range( 0, 1024, 1 ) ); -INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformIntegerDeviceVector, ::testing::Range( 0, 1024, 1 ) ); -// Test a huge range, suitable for floating point as they are less prone to overflow (but floating point -// loses granularity at large values) -INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformFloatVector, ::testing::Range( 0, 1048576, 4096 ) ); -INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformFloatDeviceVector, ::testing::Range( 0, 1048576, 4096 ) ); - -INSTANTIATE_TEST_CASE_P( InplaceSquareTransform, TransformFloatVector, ::testing::Range( 0, 1048576, 4096 ) ); -INSTANTIATE_TEST_CASE_P( InplaceSquareTransform, TransformFloatDeviceVector, ::testing::Range( 0, 1048576, 4096 ) ); - -INSTANTIATE_TEST_CASE_P( InplaceCubeTransform, TransformFloatVector, ::testing::Range( 0, 1048576, 4096 ) ); -INSTANTIATE_TEST_CASE_P( InplaceCubeTransform, TransformFloatDeviceVector, ::testing::Range( 0, 1048576, 4096 ) ); - -#if(TEST_DOUBLE == 1) -INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformDoubleVector, ::testing::Range( 0, 1048576, 4096 ) ); -INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformDoubleDeviceVector, ::testing::Range( 0, 1048576, 4096 ) ); - -INSTANTIATE_TEST_CASE_P( InplaceTransform, TransformDoubleVector, ::testing::Range( 0, 1048576, 4096 ) ); -INSTANTIATE_TEST_CASE_P( InplaceTransform, TransformDoubleDeviceVector, ::testing::Range( 0, 1048576, 4096 ) ); - -#endif -typedef ::testing::Types< - std::tuple< int, TypeValue< 1 > >, - std::tuple< int, TypeValue< 31 > >, - std::tuple< int, TypeValue< 32 > >, - std::tuple< int, TypeValue< 63 > >, - std::tuple< int, TypeValue< 64 > >, - std::tuple< int, TypeValue< 127 > >, - std::tuple< int, TypeValue< 128 > >, - std::tuple< int, TypeValue< 129 > >, - std::tuple< int, TypeValue< 1000 > >, - std::tuple< int, TypeValue< 1053 > >, - std::tuple< int, TypeValue< 4096 > >, - std::tuple< int, TypeValue< 4097 > >, - std::tuple< int, TypeValue< 65535 > >, - std::tuple< int, TypeValue< 65536 > > -> IntegerTests; - -typedef ::testing::Types< - std::tuple< float, TypeValue< 1 > >, - std::tuple< float, TypeValue< 31 > >, - std::tuple< float, TypeValue< 32 > >, - std::tuple< float, TypeValue< 63 > >, - std::tuple< float, TypeValue< 64 > >, - std::tuple< float, TypeValue< 127 > >, - std::tuple< float, TypeValue< 128 > >, - std::tuple< float, TypeValue< 129 > >, - std::tuple< float, TypeValue< 1000 > >, - std::tuple< float, TypeValue< 1053 > >, - std::tuple< float, TypeValue< 4096 > >, - std::tuple< float, TypeValue< 4097 > >, - std::tuple< float, TypeValue< 65535 > >, - std::tuple< float, TypeValue< 65536 > > -> FloatTests; - - -//typedef ::testing::Types< -// std::tuple< UDD, TypeValue< 1 > >, -// std::tuple< UDD, TypeValue< 31 > >, -// std::tuple< UDD, TypeValue< 32 > >, -// std::tuple< UDD, TypeValue< 63 > >, -// std::tuple< UDD, TypeValue< 64 > >, -// std::tuple< UDD, TypeValue< 127 > >, -// std::tuple< UDD, TypeValue< 128 > >, -// std::tuple< UDD, TypeValue< 129 > >, -// std::tuple< UDD, TypeValue< 1000 > >, -// std::tuple< UDD, TypeValue< 1053 > >, -// std::tuple< UDD, TypeValue< 4096 > >, -// std::tuple< UDD, TypeValue< 4097 > >, -// std::tuple< UDD, TypeValue< 65535 > >, -// std::tuple< UDD, TypeValue< 65536 > > -//> UDDTests; - - - -INSTANTIATE_TYPED_TEST_CASE_P( Integer, TransformArrayTest, IntegerTests ); -INSTANTIATE_TYPED_TEST_CASE_P( Float, TransformArrayTest, FloatTests ); -INSTANTIATE_TYPED_TEST_CASE_P( Integer, TransformBinaryArrayTest, IntegerTests ); -INSTANTIATE_TYPED_TEST_CASE_P( Float, TransformBinaryArrayTest, FloatTests ); -INSTANTIATE_TYPED_TEST_CASE_P( Integer, TransformOutPlaceArrayTest, IntegerTests ); -INSTANTIATE_TYPED_TEST_CASE_P( Float, TransformOutPlaceArrayTest, FloatTests ); - - -//INSTANTIATE_TYPED_TEST_CASE_P( UDDTest, TransformArrayTest, UDDTests ); int main(int argc, char* argv[]) { @@ -1839,5 +1739,4 @@ int main(int argc, char* argv[]) return retVal; -} -#endif \ No newline at end of file +} \ No newline at end of file From 9273722eebc0008cd74bc039863368490672d5d9 Mon Sep 17 00:00:00 2001 From: Jayavanth Shenoy Date: Tue, 17 Dec 2013 12:14:04 +0530 Subject: [PATCH 4/5] fixed for unary --- include/bolt/amp/detail/transform.inl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/bolt/amp/detail/transform.inl b/include/bolt/amp/detail/transform.inl index 3626996d..f3c91010 100644 --- a/include/bolt/amp/detail/transform.inl +++ b/include/bolt/amp/detail/transform.inl @@ -129,8 +129,8 @@ namespace bolt else boundsCheck = 1; - concurrency::array_view inputV (first.getContainer().getBuffer(first)); - concurrency::array_view resultV(result.getContainer().getBuffer(result)); + auto inputV = first.getContainer().getBuffer(first); + auto resultV = result.getContainer().getBuffer(result); concurrency::extent< 1 > inputExtent( wavefrontMultiple ); concurrency::parallel_for_each(ctl.getAccelerator().default_view, inputExtent, [=](concurrency::index<1> idx) restrict(amp) From fb51057bd15de9e99a2ca7383687c1fcceeb1008 Mon Sep 17 00:00:00 2001 From: Jayavanth Shenoy Date: Thu, 19 Dec 2013 12:48:51 +0530 Subject: [PATCH 5/5] Const and counting iterator support for transform --- include/bolt/amp/detail/transform.inl | 68 +- include/bolt/amp/iterator/constant_iterator.h | 90 +- include/bolt/amp/iterator/counting_iterator.h | 42 +- test/amp/TransformTest/TransformTest.cpp | 3185 +++++++++-------- 4 files changed, 1735 insertions(+), 1650 deletions(-) diff --git a/include/bolt/amp/detail/transform.inl b/include/bolt/amp/detail/transform.inl index f3c91010..d9742f5e 100644 --- a/include/bolt/amp/detail/transform.inl +++ b/include/bolt/amp/detail/transform.inl @@ -207,7 +207,8 @@ namespace bolt const InputIterator1& last1, const InputIterator2& first2, const OutputIterator& result, - const BinaryFunction& f) + const BinaryFunction& f, + std::random_access_iterator_tag) { typedef std::iterator_traits::value_type iType1; typedef std::iterator_traits::value_type iType2; @@ -262,7 +263,8 @@ namespace bolt const DVInputIterator1& last1, const DVInputIterator2& first2, const DVOutputIterator& result, - const BinaryFunction& f ) + const BinaryFunction& f, + bolt::amp::device_vector_tag) { typedef std::iterator_traits< DVInputIterator1 >::value_type iType1; typedef std::iterator_traits< DVInputIterator2 >::value_type iType2; @@ -322,7 +324,8 @@ namespace bolt const InputIterator& first, const InputIterator& last, const OutputIterator& result, - const UnaryFunction& f) + const UnaryFunction& f, + std::random_access_iterator_tag) { typedef std::iterator_traits::value_type iType; typedef std::iterator_traits::value_type oType; @@ -376,7 +379,8 @@ namespace bolt const DVInputIterator& first, const DVInputIterator& last, const DVOutputIterator& result, - const UnaryFunction& f ) + const UnaryFunction& f, + bolt::amp::device_vector_tag) { typedef std::iterator_traits< DVInputIterator >::value_type iType; @@ -422,6 +426,47 @@ namespace bolt } }; + template + void transform_unary_pick_iterator( bolt::amp::control &ctl, + const DVInputIterator& first, + const DVInputIterator& last, + const DVOutputIterator& result, + const UnaryFunction& f, + bolt::amp::fancy_iterator_tag) + { + + typedef std::iterator_traits< DVInputIterator >::value_type iType; + typedef std::iterator_traits< DVOutputIterator >::value_type oType; + + size_t sz = std::distance( first, last ); + if( sz == 0 ) + return; + + const bolt::amp::control::e_RunMode runMode = ctl.getForceRunMode(); // could be dynamic choice some day. + + // TBB does not have an equivalent for two input iterator std::transform + if( (runMode == bolt::amp::control::SerialCpu) ) + { + std::transform( first, last, result, f ); + return; + } + else if( (runMode == bolt::amp::control::MultiCoreCpu) ) + { + +#if defined( ENABLE_TBB ) + + bolt::btbb::transform( first, last, result, f); +#else + throw std::exception( "The MultiCoreCpu version of transform is not enabled to be built." ); +#endif + return; + } + else + { + transform_unary_enqueue( ctl, first, last, result, f); + } + }; + // Wrapper that uses default control class, iterator interface template @@ -482,7 +527,7 @@ namespace bolt std::random_access_iterator_tag, std::random_access_iterator_tag) { - transform_pick_iterator( ctl, first1, last1, first2, result, f ); + transform_pick_iterator( ctl, first1, last1, first2, result, f, std::iterator_traits< InputIterator1 >::iterator_category() ); } template @@ -520,7 +565,18 @@ namespace bolt const UnaryFunction& f, std::random_access_iterator_tag ) { - transform_unary_pick_iterator( ctl, first1, last1, result, f ); + transform_unary_pick_iterator( ctl, first1, last1, result, f, std::iterator_traits< InputIterator >::iterator_category() ); + } + + template + void transform_unary_detect_random_access( bolt::amp::control& ctl, + const InputIterator& first1, + const InputIterator& last1, + const OutputIterator& result, + const UnaryFunction& f, + bolt::amp::fancy_iterator_tag ) + { + transform_unary_pick_iterator( ctl, first1, last1, result, f, std::iterator_traits< InputIterator >::iterator_category() ); } diff --git a/include/bolt/amp/iterator/constant_iterator.h b/include/bolt/amp/iterator/constant_iterator.h index 3045d48a..cce2ff9a 100644 --- a/include/bolt/amp/iterator/constant_iterator.h +++ b/include/bolt/amp/iterator/constant_iterator.h @@ -35,15 +35,16 @@ namespace amp { }; template< typename value_type > - class constant_iterator: public boost::iterator_facade< constant_iterator< value_type >, value_type, - constant_iterator_tag, value_type, int > + class constant_iterator: public std::iterator< constant_iterator_tag, typename value_type, int> { public: - typedef typename boost::iterator_facade< constant_iterator< value_type >, value_type, - constant_iterator_tag, value_type, int >::difference_type difference_type; - typedef concurrency::array_view< value_type > arrayview_type; + //typedef typename std::iterator< constant_iterator< value_type >, value_type, + //constant_iterator_tag, value_type, int >::difference_type difference_type; + typedef int difference_type; + typedef concurrency::array_view< value_type > arrayview_type; typedef constant_iterator const_iterator; + typedef struct Payload @@ -53,20 +54,12 @@ namespace amp { // Basic constructor requires a reference to the container and a positional element constant_iterator( value_type init, const control& ctl = control::getDefault( ) ): - m_constValue( init ), m_Index( 0 ) - { - //int m_Size = 1; - //std::vector temp(1, m_constValue); - //concurrency::extent<1> ext( static_cast< int >( m_Size ) ); - //m_devMemory = new concurrency::array(ext, temp.begin(), ctl.getAccelerator( ).default_view ); - - } + m_constValue( init ), m_Index( 0 ){} // This copy constructor allows an iterator to convert into a const_iterator, but not vica versa template< typename OtherType > constant_iterator( const constant_iterator< OtherType >& rhs ): m_devMemory( rhs.m_devMemory ), - m_Index( rhs.m_Index ), m_constValue( rhs.m_constValue ) - {} + m_Index( rhs.m_Index ), m_constValue( rhs.m_constValue ){} // This copy constructor allows an iterator to convert into a const_iterator, but not vica versa constant_iterator< value_type >& operator= ( const constant_iterator< value_type >& rhs ) @@ -74,7 +67,6 @@ namespace amp { if( this == &rhs ) return *this; - //m_devMemory = rhs.m_devMemory; m_constValue = rhs.m_constValue; m_Index = rhs.m_Index; return *this; @@ -93,14 +85,8 @@ namespace amp { return result; } - //value_type constant_iterator< value_type > operator[] (unsigned int &i) restrict(cpu, amp) - //{ - // return m_constValue; - //} - arrayview_type getBuffer() const { - // return m_devMemory; } //arrayview_type getBuffer(const_iterator itr) const @@ -149,18 +135,16 @@ namespace amp { // return sizeof( Payload ); //} - difference_type distance_to( const constant_iterator< value_type >& rhs ) const + difference_type operator- ( const constant_iterator< value_type >& rhs ) const { //return static_cast< typename iterator_facade::difference_type >( 1 ); - return rhs.m_Index - m_Index; + return m_Index - rhs.m_Index; } // Public member variables difference_type m_Index; - // private: - // Implementation detail of boost.iterator - friend class boost::iterator_core_access; + //private: // Used for templatized copy constructor and the templatized equal operator template < typename > friend class constant_iterator; @@ -171,12 +155,12 @@ namespace amp { m_Index += n; } - void increment( ) + void operator++( ) { advance( 1 ); } - void decrement( ) + void operator--( ) { advance( -1 ); } @@ -186,30 +170,62 @@ namespace amp { return m_Index; } + //template< typename OtherType > + //bool equal( const constant_iterator< OtherType >& rhs ) const + //{ + // bool sameIndex = (rhs.m_constValue == m_constValue) && (rhs.m_Index == m_Index); + + // return sameIndex; + //} + template< typename OtherType > - bool equal( const constant_iterator< OtherType >& rhs ) const + bool operator== ( const constant_iterator< OtherType >& rhs ) const { bool sameIndex = (rhs.m_constValue == m_constValue) && (rhs.m_Index == m_Index); return sameIndex; } + template< typename OtherType > + bool operator!= ( const constant_iterator< OtherType >& rhs ) const + { + bool sameIndex = (rhs.m_constValue != m_constValue) || (rhs.m_Index != m_Index); + return sameIndex; + } - typename boost::iterator_facade< constant_iterator< value_type >, value_type, - constant_iterator_tag, value_type, int >::reference dereference( ) const + // Do we need this? Debug error + template< typename OtherType > + bool operator< ( const constant_iterator< OtherType >& rhs ) const { - //value_type tmp = *(m_devMemory->data()); - //return tmp; + bool sameIndex = (rhs.m_Index < m_Index); + + return sameIndex; + } - //return *(m_devMemory->data()); - return m_constValue; + //typename boost::iterator_facade< constant_iterator< value_type >, value_type, + //constant_iterator_tag, value_type, int >::reference dereference( ) const + //{ + // //value_type tmp = *(m_devMemory->data()); + // //return tmp; + // + // //return *(m_devMemory->data()); + // + // return m_constValue; + // + //} + + int operator*() const restrict(cpu,amp) + { + int xy = m_constValue; + return xy; + //return *(m_Ptr->data()); } - int operator[](int x) const restrict(cpu,amp) // Uncomment if using iterator in inl + int operator[](int x) const restrict(cpu,amp) { int xy = m_constValue; return xy; diff --git a/include/bolt/amp/iterator/counting_iterator.h b/include/bolt/amp/iterator/counting_iterator.h index 5669a7ea..cae4592b 100644 --- a/include/bolt/amp/iterator/counting_iterator.h +++ b/include/bolt/amp/iterator/counting_iterator.h @@ -35,14 +35,13 @@ namespace amp { }; template< typename value_type > - class counting_iterator: public boost::iterator_facade< counting_iterator< value_type >, value_type, - counting_iterator_tag, value_type, int > + class counting_iterator: public std::iterator< counting_iterator_tag, typename value_type, int> { public: typedef typename boost::iterator_facade< counting_iterator< value_type >, value_type, counting_iterator_tag, value_type, int >::difference_type difference_type; - typedef concurrency::array_view< value_type > arrayview_type; + typedef concurrency::array_view< value_type > arrayview_type; typedef counting_iterator const_iterator; @@ -90,17 +89,15 @@ namespace amp { return *this; } - difference_type distance_to( const counting_iterator< value_type >& rhs ) const + difference_type operator- ( const counting_iterator< value_type >& rhs ) const { - return rhs.m_Index - m_Index; + return m_Index - rhs.m_Index; } // Public member variables difference_type m_Index; - // private: - // Implementation detail of boost.iterator - friend class boost::iterator_core_access; + //private: // Used for templatized copy constructor and the templatized equal operator template < typename > friend class counting_iterator; @@ -111,12 +108,12 @@ namespace amp { m_Index += n; } - void increment( ) + void operator++( ) { advance( 1 ); } - void decrement( ) + void operator--( ) { advance( -1 ); } @@ -127,24 +124,39 @@ namespace amp { } template< typename OtherType > - bool equal( const counting_iterator< OtherType >& rhs ) const + bool operator== ( const counting_iterator< OtherType >& rhs ) const { bool sameIndex = (rhs.m_initValue == m_initValue) && (rhs.m_Index == m_Index); return sameIndex; } + template< typename OtherType > + bool operator!= ( const counting_iterator< OtherType >& rhs ) const + { + bool sameIndex = (rhs.m_initValue != m_initValue) || (rhs.m_Index != m_Index); + return sameIndex; + } - typename boost::iterator_facade< counting_iterator< value_type >, value_type, - counting_iterator_tag, value_type, int >::reference dereference( ) const + // Do we need this? Debug error + template< typename OtherType > + bool operator< ( const counting_iterator< OtherType >& rhs ) const { - return m_initValue + m_Index; + bool sameIndex = (rhs.m_Index < m_Index); + return sameIndex; + } + + // Dereference operators + int operator*() const restrict(cpu,amp) + { + int xy = m_initValue; + return xy; } - int operator[](int x) const restrict(cpu,amp) // Uncomment if using iterator in inl + int operator[](int x) const restrict(cpu,amp) { int temp = x + m_initValue; return temp; diff --git a/test/amp/TransformTest/TransformTest.cpp b/test/amp/TransformTest/TransformTest.cpp index bd63d96b..cb7d0eed 100644 --- a/test/amp/TransformTest/TransformTest.cpp +++ b/test/amp/TransformTest/TransformTest.cpp @@ -32,1600 +32,1601 @@ //// Fixture classes are now defined to enable googletest to process type parameterized tests // //// This class creates a C++ 'TYPE' out of a size_t value -//template< size_t N > -//class TypeValue -//{ -//public: -// static const size_t value = N; -//}; -// -//// Explicit initialization of the C++ static const -//template< size_t N > -//const size_t TypeValue< N >::value; -// -//// Test fixture class, used for the Type-parameterized tests -//// Namely, the tests that use std::array and TYPED_TEST_P macros -//template< typename ArrayTuple > -//class TransformArrayTest: public ::testing::Test -//{ -//public: -// TransformArrayTest( ): m_Errors( 0 ) -// {} -// -// virtual void SetUp( ) -// { -// for( int i=0; i < ArraySize; i++ ) -// { -// stdInput[ i ] = 1; -// boltInput[ i ] = 1; -// } -// }; -// -// virtual void TearDown( ) -// {}; -// -// virtual ~TransformArrayTest( ) -// {} -// -////protected: -// -// typedef typename std::tuple_element< 0, ArrayTuple >::type ArrayType; -// static const size_t ArraySize = typename std::tuple_element< 1, ArrayTuple >::type::value; -// -// typename std::array< ArrayType, ArraySize > stdInput, boltInput; -// int m_Errors; -//}; -// -//template< typename ArrayTuple > -//class TransformBinaryArrayTest: public ::testing::Test -//{ -//public: -// TransformBinaryArrayTest( ): m_Errors( 0 ) -// {} -// -// virtual void SetUp( ) -// { -// for( int i=0; i < ArraySize; i++ ) -// { -// stdInput1[ i ] = 1; -// stdInput2[ i ] = 1; -// stdOutput[ i ] = 0; -// boltInput1[ i ] = 1; -// boltInput2[ i ] = 1; -// boltOutput[ i ] = 0; -// } -// }; -// -// virtual void TearDown( ) -// {}; -// -// virtual ~TransformBinaryArrayTest( ) -// {} -// -//protected: -// typedef typename std::tuple_element< 0, ArrayTuple >::type ArrayType; -// static const size_t ArraySize = typename std::tuple_element< 1, ArrayTuple >::type::value; -// -// typename std::array< ArrayType, ArraySize > stdInput1, stdInput2, stdOutput,boltInput1, boltInput2, boltOutput; -// int m_Errors; -//}; -// -//template< typename ArrayTuple > -//class TransformOutPlaceArrayTest: public ::testing::Test -//{ -//public: -// TransformOutPlaceArrayTest( ): m_Errors( 0 ) -// {} -// -// virtual void SetUp( ) -// { -// for( int i=0; i < ArraySize; i++ ) -// { -// stdInput[ i ] = 1; -// stdOutput[ i ] = 0; -// boltInput[ i ] = 1; -// boltOutput[ i ] = 0; -// } -// }; -// -// virtual void TearDown( ) -// {}; -// -// virtual ~TransformOutPlaceArrayTest( ) -// {} -// +template< size_t N > +class TypeValue +{ +public: + static const size_t value = N; +}; + +// Explicit initialization of the C++ static const +template< size_t N > +const size_t TypeValue< N >::value; + +// Test fixture class, used for the Type-parameterized tests +// Namely, the tests that use std::array and TYPED_TEST_P macros +template< typename ArrayTuple > +class TransformArrayTest: public ::testing::Test +{ +public: + TransformArrayTest( ): m_Errors( 0 ) + {} + + virtual void SetUp( ) + { + for( int i=0; i < ArraySize; i++ ) + { + stdInput[ i ] = 1; + boltInput[ i ] = 1; + } + }; + + virtual void TearDown( ) + {}; + + virtual ~TransformArrayTest( ) + {} + //protected: -// typedef typename std::tuple_element< 0, ArrayTuple >::type ArrayType; -// static const size_t ArraySize = typename std::tuple_element< 1, ArrayTuple >::type::value; -// -// typename std::array< ArrayType, ArraySize > stdInput, stdOutput, boltInput, boltOutput; -// int m_Errors; -//}; -// + + typedef typename std::tuple_element< 0, ArrayTuple >::type ArrayType; + static const size_t ArraySize = typename std::tuple_element< 1, ArrayTuple >::type::value; + + typename std::array< ArrayType, ArraySize > stdInput, boltInput; + int m_Errors; +}; + +template< typename ArrayTuple > +class TransformBinaryArrayTest: public ::testing::Test +{ +public: + TransformBinaryArrayTest( ): m_Errors( 0 ) + {} + + virtual void SetUp( ) + { + for( int i=0; i < ArraySize; i++ ) + { + stdInput1[ i ] = 1; + stdInput2[ i ] = 1; + stdOutput[ i ] = 0; + boltInput1[ i ] = 1; + boltInput2[ i ] = 1; + boltOutput[ i ] = 0; + } + }; + + virtual void TearDown( ) + {}; + + virtual ~TransformBinaryArrayTest( ) + {} + +protected: + typedef typename std::tuple_element< 0, ArrayTuple >::type ArrayType; + static const size_t ArraySize = typename std::tuple_element< 1, ArrayTuple >::type::value; + + typename std::array< ArrayType, ArraySize > stdInput1, stdInput2, stdOutput,boltInput1, boltInput2, boltOutput; + int m_Errors; +}; + +template< typename ArrayTuple > +class TransformOutPlaceArrayTest: public ::testing::Test +{ +public: + TransformOutPlaceArrayTest( ): m_Errors( 0 ) + {} + + virtual void SetUp( ) + { + for( int i=0; i < ArraySize; i++ ) + { + stdInput[ i ] = 1; + stdOutput[ i ] = 0; + boltInput[ i ] = 1; + boltOutput[ i ] = 0; + } + }; + + virtual void TearDown( ) + {}; + + virtual ~TransformOutPlaceArrayTest( ) + {} + +protected: + typedef typename std::tuple_element< 0, ArrayTuple >::type ArrayType; + static const size_t ArraySize = typename std::tuple_element< 1, ArrayTuple >::type::value; + + typename std::array< ArrayType, ArraySize > stdInput, stdOutput, boltInput, boltOutput; + int m_Errors; +}; + //// Explicit initialization of the C++ static const -//template< typename ArrayTuple > -//const size_t TransformArrayTest< ArrayTuple >::ArraySize; -// -//template< typename ArrayTuple > -//const size_t TransformBinaryArrayTest< ArrayTuple >::ArraySize; -// -//template< typename ArrayTuple > -//const size_t TransformOutPlaceArrayTest< ArrayTuple >::ArraySize; -// -// -//TYPED_TEST_CASE_P( TransformArrayTest ); -//TYPED_TEST_CASE_P( TransformBinaryArrayTest ); -//TYPED_TEST_CASE_P( TransformOutPlaceArrayTest ); -// -// -//TYPED_TEST_P( TransformArrayTest, InPlaceNegateTransform ) -//{ -// typedef std::array< ArrayType, ArraySize > ArrayCont; -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); -// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); -// -// ArrayCont::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end( ) ); -// ArrayCont::difference_type boltNumElements = std::distance( boltInput.begin( ), boltInput.end( ) ); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdInput, boltInput ); -//} -//TYPED_TEST_P( TransformArrayTest, SerialInPlaceNegateTransform ) -//{ -// typedef std::array< ArrayType, ArraySize > ArrayCont; -// -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::SerialCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ),bolt::amp::negate()); -// -// ArrayCont::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end( ) ); -// ArrayCont::difference_type boltNumElements = std::distance( boltInput.begin( ), boltInput.end( ) ); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdInput, boltInput ); -//} -//TYPED_TEST_P( TransformArrayTest, MulticoreInPlaceNegateTransform ) -//{ -// typedef std::array< ArrayType, ArraySize > ArrayCont; -// -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ),bolt::amp::negate()); -// -// ArrayCont::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end( ) ); -// ArrayCont::difference_type boltNumElements = std::distance( boltInput.begin( ), boltInput.end( ) ); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdInput, boltInput ); -//} -// -// -// -// -//TYPED_TEST_P( TransformBinaryArrayTest, BinaryPlusTransform ) -//{ -// typedef std::array< ArrayType, ArraySize > ArrayCont; -// -// // Calling the actual functions under test -// std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), -// std::plus< ArrayType >( ) ); -// bolt::amp::transform( boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), -// bolt::amp::plus< ArrayType >( ) ); -// -// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); -// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -//} -//TYPED_TEST_P( TransformBinaryArrayTest, SerialBinaryPlusTransform ) -//{ -// typedef std::array< ArrayType, ArraySize > ArrayCont; -// -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::SerialCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), -// std::plus< ArrayType >( ) ); -// bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), -// bolt::amp::plus< ArrayType >( ) ); -// -// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); -// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -//} -//TYPED_TEST_P( TransformBinaryArrayTest, MulticoreBinaryPlusTransform ) -//{ -// typedef std::array< ArrayType, ArraySize > ArrayCont; -// -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), -// std::plus< ArrayType >( ) ); -// bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), -// bolt::amp::plus< ArrayType >( ) ); -// -// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); -// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -//} -// -// -// -//TYPED_TEST_P( TransformBinaryArrayTest, BinaryMultipliesTransform ) -//{ -// typedef std::array< ArrayType, ArraySize > ArrayCont; -// -// // Calling the actual functions under test -// std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), -// std::multiplies< ArrayType >( ) ); -// bolt::amp::transform( boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), -// bolt::amp::multiplies< ArrayType >( ) ); -// -// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); -// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -//} -//TYPED_TEST_P( TransformBinaryArrayTest, SerialBinaryMultipliesTransform ) -//{ -// typedef std::array< ArrayType, ArraySize > ArrayCont; -// -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::SerialCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), -// std::multiplies< ArrayType >( ) ); -// bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), -// bolt::amp::multiplies< ArrayType >( ) ); -// -// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); -// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -//} -//TYPED_TEST_P( TransformBinaryArrayTest, MulticoreBinaryMultipliesTransform ) -//{ -// typedef std::array< ArrayType, ArraySize > ArrayCont; -// -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), -// std::multiplies< ArrayType >( ) ); -// bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), -// bolt::amp::multiplies< ArrayType >( ) ); -// -// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); -// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -//} -// -// -//TYPED_TEST_P( TransformBinaryArrayTest, BinaryMaxTransform ) -//{ -// typedef std::array< ArrayType, ArraySize > ArrayCont; -// -// // Calling the actual functions under test -// std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), [] (ArrayType lhs, -// ArrayType rhs) { return rhs > lhs ? rhs:lhs; } ); -// bolt::amp::transform( boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), -// bolt::amp::maximum< ArrayType >( ) ); -// -// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); -// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -//} -//TYPED_TEST_P( TransformBinaryArrayTest, SerialBinaryMaxTransform ) -//{ -// typedef std::array< ArrayType, ArraySize > ArrayCont; -// -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::SerialCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), [] (ArrayType lhs, -// ArrayType rhs) { return rhs > lhs ? rhs:lhs; } ); -// bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), -// bolt::amp::maximum< ArrayType >( ) ); -// -// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); -// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -//} -//TYPED_TEST_P( TransformBinaryArrayTest, MulticoreBinaryMaxTransform ) -//{ -// typedef std::array< ArrayType, ArraySize > ArrayCont; -// -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), [] (ArrayType lhs, -// ArrayType rhs) { return rhs > lhs ? rhs:lhs; } ); -// bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), -// bolt::amp::maximum< ArrayType >( ) ); -// -// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); -// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -//} -// -// -// -//TYPED_TEST_P( TransformOutPlaceArrayTest, OutPlaceSquareTransform ) -//{ -// typedef std::array< ArrayType, ArraySize > ArrayCont; -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdOutput.begin(), []( ArrayType x ) {return x*x;} ); -// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltOutput.begin(), bolt::amp::square< ArrayType >()); -// -// -// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin(), stdOutput.end() ); -// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin(), boltOutput.end() ); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -//} -//TYPED_TEST_P( TransformOutPlaceArrayTest, SerialOutPlaceSquareTransform ) -//{ -// typedef std::array< ArrayType, ArraySize > ArrayCont; -// -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::SerialCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdOutput.begin(), []( ArrayType x ) {return x*x;} ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltOutput.begin(), -// bolt::amp::square< ArrayType >( ) ); -// -// -// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin(), stdOutput.end() ); -// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin(), boltOutput.end() ); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -//} -//TYPED_TEST_P( TransformOutPlaceArrayTest, MulticoreOutPlaceSquareTransform ) -//{ -// typedef std::array< ArrayType, ArraySize > ArrayCont; -// -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdOutput.begin(), []( ArrayType x ) {return x*x;} ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltOutput.begin(), -// bolt::amp::square< ArrayType >( ) ); -// -// -// ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin(), stdOutput.end() ); -// ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin(), boltOutput.end() ); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); -//} -// -// -//struct UDD -//{ -// int a; -// int b; -// -// bool operator() (const UDD& lhs, const UDD& rhs) const restrict(amp,cpu){ -// return ((lhs.a+lhs.b) > (rhs.a+rhs.b)); -// } -// bool operator < (const UDD& other) const restrict(amp,cpu){ -// return ((a+b) < (other.a+other.b)); -// } -// bool operator > (const UDD& other) const restrict(amp,cpu){ -// return ((a+b) > (other.a+other.b)); -// } -// bool operator == (const UDD& other) const restrict(amp,cpu) { -// return ((a+b) == (other.a+other.b)); -// } -// -// UDD operator + (const UDD &rhs) const restrict(amp,cpu) -// { -// UDD _result; -// _result.a = a + rhs.a; -// _result.b = b + rhs.b; -// return _result; -// } -// -// -// UDD() restrict(amp,cpu) -// : a(0),b(0) { } -// UDD(int _in) restrict(amp,cpu) -// : a(_in), b(_in +1) { } -//}; -// -// -// -//REGISTER_TYPED_TEST_CASE_P( TransformArrayTest, InPlaceNegateTransform, SerialInPlaceNegateTransform, -// MulticoreInPlaceNegateTransform ); -//REGISTER_TYPED_TEST_CASE_P( TransformOutPlaceArrayTest, OutPlaceSquareTransform, SerialOutPlaceSquareTransform, -// MulticoreOutPlaceSquareTransform ); -//REGISTER_TYPED_TEST_CASE_P( TransformBinaryArrayTest, BinaryPlusTransform, SerialBinaryPlusTransform, -// MulticoreBinaryPlusTransform, BinaryMultipliesTransform, -// SerialBinaryMultipliesTransform, MulticoreBinaryMultipliesTransform, -// BinaryMaxTransform, SerialBinaryMaxTransform, MulticoreBinaryMaxTransform); -// -// -/////////////////////////////////////////////////////////////////////////////////////////////////////////// -//// Fixture classes are now defined to enable googletest to process value parameterized tests -// -//// ::testing::TestWithParam< int > means that GetParam( ) returns int values, which i use for array size -//class TransformIntegerVector: public ::testing::TestWithParam< int > -//{ -//public: -// // Create an std and a bolt vector of requested size, and initialize all the elements to 1 -// TransformIntegerVector( ): stdInput( GetParam( ), 1 ), boltInput( GetParam( ), 1 ) -// {} -// -//protected: -// std::vector< int > stdInput, boltInput; -//}; -// -//class TransformIntegerDeviceVector: public ::testing::TestWithParam< int > -//{ -//public: -// // Create an std and a bolt vector of requested size, and initialize all the elements to 1 -// TransformIntegerDeviceVector( ): stdInput( GetParam( ), 1 ), boltInput(static_cast(GetParam( )), 1 ) -// { -// std::generate(stdInput.begin(), stdInput.end(), rand); -// //boltInput = stdInput; -// //FIXME - The above should work but the below loop is used. -// for (int i=0; i< GetParam( ); i++) -// { -// boltInput[i] = stdInput[i]; -// -// } -// } -// -//protected: -// std::vector< int > stdInput; -// bolt::amp::device_vector< int > boltInput; -//}; -// -//// ::testing::TestWithParam< int > means that GetParam( ) returns int values, which i use for array size -//class TransformFloatVector: public ::testing::TestWithParam< int > -//{ -//public: -// // Create an std and a bolt vector of requested size, and initialize all the elements to 1 -// TransformFloatVector( ): stdInput( GetParam( ), 1.0f ), boltInput( GetParam( ), 1.0f ) -// {} -// -//protected: -// std::vector< float > stdInput, boltInput; -//}; -// -// -//class TransformFloatDeviceVector: public ::testing::TestWithParam< int > -//{ -//public: -// // Create an std and a bolt vector of requested size, and initialize all the elements to 1 -// TransformFloatDeviceVector( ): stdInput( GetParam( ), 1.0f ), boltInput( static_cast( GetParam( ) ), 1.0f ) -// { -// std::generate(stdInput.begin(), stdInput.end(), rand); -// //boltInput = stdInput; -// //FIXME - The above should work but the below loop is used. -// for (int i=0; i< GetParam( ); i++) -// { -// boltInput[i] = stdInput[i]; -// } -// -// } -// -//protected: -// std::vector< float > stdInput; -// bolt::amp::device_vector< float > boltInput; -//}; -//// ::testing::TestWithParam< int > means that GetParam( ) returns int values, which i use for array size -//class TransformDoubleVector: public ::testing::TestWithParam< int > -//{ -//public: -// // Create an std and a bolt vector of requested size, and initialize all the elements to 1 -// TransformDoubleVector( ): stdInput( GetParam( ), 1.0 ), boltInput( GetParam( ), 1.0 ) -// {} -// -//protected: -// std::vector< double > stdInput, boltInput; -//}; -// -// -//#if (TEST_DOUBLE == 1) -//// ::testing::TestWithParam< int > means that GetParam( ) returns int values, which i use for array size -//class TransformDoubleDeviceVector: public ::testing::TestWithParam< int > -//{ -//public: -// // Create an std and a bolt vector of requested size, and initialize all the elements to 1 -// TransformDoubleDeviceVector( ): stdInput( GetParam( ), 1.0 ), boltInput( static_cast( GetParam( ) ), 1.0 ) -// { -// std::generate(stdInput.begin(), stdInput.end(), rand); -// //boltInput = stdInput; -// //FIXME - The above should work but the below loop is used. -// for (int i=0; i< GetParam( ); i++) -// { -// boltInput[i] = stdInput[i]; -// } -// } -// -//protected: -// std::vector< double > stdInput; -// bolt::amp::device_vector< double > boltInput; -//}; -//#endif -// -// -//TEST( HostIntVector, OffsetTransform ) -//{ -// int length = 1024; -// -// std::vector stdInput( length ,1); -// std::vector boltInput(stdInput.begin(),stdInput.end()); -// -// int offset = 100; -// -// std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); -// bolt::amp::transform( boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); -// -// cmpArrays( stdInput, boltInput); -// -//} -// -//TEST( HostIntVector, SerialOffsetTransform ) -//{ -// int length = 1024; -// -// std::vector stdInput( length ,1); -// std::vector boltInput(stdInput.begin(),stdInput.end()); -// -// int offset = 100; -// -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::SerialCpu); -// -// std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); -// bolt::amp::transform(ctl, boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); -// -// cmpArrays( stdInput, boltInput); -// -//} -// -//TEST( HostIntVector, MulticoreOffsetTransform ) -//{ -// int length = 1024; -// -// std::vector stdInput( length ,1); -// std::vector boltInput(stdInput.begin(),stdInput.end()); -// -// int offset = 100; -// -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); -// -// std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); -// bolt::amp::transform(ctl, boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); -// -// cmpArrays( stdInput, boltInput); -// -//} -// -//TEST( DVIntVector, OffsetTransform ) -//{ -// int length = 1024; -// -// std::vector stdInput( length ,1); -// bolt::amp::device_vector boltInput(stdInput.begin(),stdInput.end()); -// -// int offset = 100; -// -// std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); -// bolt::amp::transform( boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); -// -// cmpArrays( stdInput, boltInput); -// -//} -// -//TEST( DVIntVector, SerialOffsetTransform ) -//{ -// int length = 1024; -// -// std::vector stdInput( length ,1); -// bolt::amp::device_vector boltInput(stdInput.begin(),stdInput.end()); -// -// int offset = 100; -// -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::SerialCpu); -// -// std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); -// bolt::amp::transform( ctl, boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); -// -// cmpArrays( stdInput, boltInput); -// -//} -// -//TEST( DVIntVector, MulticoreOffsetTransform ) -//{ -// int length = 1024; -// -// std::vector stdInput( length ,1); -// bolt::amp::device_vector boltInput(stdInput.begin(),stdInput.end()); -// -// int offset = 100; -// -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); -// -// std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); -// bolt::amp::transform( ctl, boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); -// -// cmpArrays( stdInput, boltInput); -// -//} -// -//TEST_P( TransformIntegerVector, InplaceTransform ) -//{ -// // Calling the actual functions under test -// std::transform( stdInput.begin(), stdInput.end(), stdInput.begin(), std::negate()); -// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); -// -// -// -// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); -// std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin( ),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -//TEST_P( TransformIntegerVector, SerialInplaceTransform ) -//{ -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::SerialCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin(), stdInput.end(), stdInput.begin(), std::negate()); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); -// -// -// -// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); -// std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin( ),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -//TEST_P( TransformIntegerVector, MulticoreInplaceTransform ) -//{ -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin(), stdInput.end(), stdInput.begin(), std::negate()); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); -// -// -// -// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); -// std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin( ),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -// -// -//TEST_P( TransformIntegerDeviceVector, InplaceTransform ) -//{ -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); -// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); -// -// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); -// std::vector< int >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -//TEST_P( TransformIntegerDeviceVector, SerialInplaceTransform ) -//{ -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::SerialCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); -// -// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); -// std::vector< int >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -//TEST_P( TransformIntegerDeviceVector, MulticoreInplaceTransform ) -//{ -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); -// -// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); -// std::vector< int >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -// -// -//TEST_P( TransformFloatVector, InplaceTransform ) -//{ -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); -// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); -// -// -// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); -// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -//TEST_P( TransformFloatVector, SerialInplaceTransform ) -//{ -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::SerialCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); -// -// -// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); -// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -//TEST_P( TransformFloatVector, MulticoreInplaceTransform ) -//{ -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); -// -// -// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); -// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -// -//TEST_P( TransformFloatDeviceVector, InplaceTransform ) -//{ -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); -// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); -// -// -// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); -// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -//TEST_P( TransformFloatDeviceVector, SerialInplaceTransform ) -//{ -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::SerialCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); -// -// -// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); -// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -//TEST_P( TransformFloatDeviceVector, MulticoreInplaceTransform ) -//{ -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); -// -// -// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); -// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -// -//TEST_P( TransformFloatVector, InplaceSquareTransform ) -//{ -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); -// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); -// -// -// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); -// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -//TEST_P( TransformFloatVector, SerialInplaceSquareTransform ) -//{ -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::SerialCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); -// -// -// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); -// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -//TEST_P( TransformFloatVector, MulticoreInplaceSquareTransform ) -//{ -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); -// -// -// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); -// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -// -//TEST_P( TransformFloatDeviceVector, InplaceSquareTransform ) -//{ -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); -// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); -// -// -// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); -// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -//TEST_P( TransformFloatDeviceVector, SerialInplaceSquareTransform ) -//{ -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::SerialCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); -// -// -// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); -// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -//TEST_P( TransformFloatDeviceVector, MulticoreInplaceSquareTransform ) -//{ -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); -// -// -// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); -// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -// -// -//TEST_P( TransformFloatVector, InplaceCubeTransform ) -//{ -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); -// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); -// -// -// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); -// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -//TEST_P( TransformFloatVector, SerialInplaceCubeTransform ) -//{ -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::SerialCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); -// -// -// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ),stdInput.end()); -// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -//TEST_P( TransformFloatVector, MulticoreInplaceCubeTransform ) -//{ -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); -// -// -// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); -// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -// -//TEST_P( TransformFloatDeviceVector, InplaceCubeTransform ) -//{ -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); -// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); -// -// -// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); -// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -//TEST_P( TransformFloatDeviceVector, SerialInplaceCubeTransform ) -//{ -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::SerialCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); -// -// -// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ),stdInput.end()); -// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -//TEST_P( TransformFloatDeviceVector, MulticoreInplaceCubeTransform ) -//{ -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); -// -// -// std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); -// std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -// -// -//#if(TEST_DOUBLE == 1) -//TEST_P( TransformDoubleVector, InplaceTransform ) -//{ -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); -// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); -// -// -// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); -// std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -//TEST_P( TransformDoubleVector, SerialInplaceTransform ) -//{ -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::SerialCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); -// -// -// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); -// std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -//TEST_P( TransformDoubleVector, MulticoreInplaceTransform ) -//{ -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate()); -// -// -// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); -// std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -// -// -//TEST_P( TransformDoubleDeviceVector, InplaceTransform ) -//{ -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); -// bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); -// -// -// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); -// std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -//TEST_P( TransformDoubleDeviceVector, SerialInplaceTransform ) -//{ -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::SerialCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); -// -// -// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); -// std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -//TEST_P( TransformDoubleDeviceVector, MulticoreInplaceTransform ) -//{ -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); -// -// // Calling the actual functions under test -// std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); -// bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate()); -// -// -// std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); -// std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); -// -// // Both collections should have the same number of elements -// EXPECT_EQ( stdNumElements, boltNumElements ); -// -// // Loop through the array and compare all the values with each other -// cmpArrays( stdInput, boltInput ); -//} -// -//#endif -// -//TEST( TransformDeviceVector, UDDOutOfPlaceTransform) -//{ -// int length = 1<<8; -// std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); -// std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); -// std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); -// std::fill( hVectorB.begin(), hVectorB.end(), 0 ); -// -// bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), -// dVectorB(hVectorB.begin(), hVectorB.end()), -// dVectorO(hVectorO.begin(), hVectorO.end()); -// -// std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< UDD >( ) ); -// bolt::amp::transform( dVectorA.begin(), -// dVectorA.end(), -// dVectorB.begin(), -// dVectorO.begin(), -// bolt::amp::plus< UDD >( ) ); -// -// cmpArrays(hVectorO, dVectorO); -// -//} -// -//TEST( TransformDeviceVector, SerialUDDOutOfPlaceTransform) -//{ -// int length = 1<<8; -// std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); -// std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); -// std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); -// std::fill( hVectorB.begin(), hVectorB.end(), 0 ); -// -// bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), -// dVectorB(hVectorB.begin(), hVectorB.end()), -// dVectorO(hVectorO.begin(), hVectorO.end()); -// -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::SerialCpu); -// -// std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< UDD >( ) ); -// bolt::amp::transform( ctl, dVectorA.begin(), -// dVectorA.end(), -// dVectorB.begin(), -// dVectorO.begin(), -// bolt::amp::plus< UDD >( ) ); -// -// cmpArrays(hVectorO, dVectorO); -// -//} -// -// -//TEST( TransformDeviceVector, MulticoreUDDOutOfPlaceTransform) -//{ -// int length = 1<<8; -// std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); -// std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); -// std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); -// std::fill( hVectorB.begin(), hVectorB.end(), 0 ); -// -// bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), -// dVectorB(hVectorB.begin(), hVectorB.end()), -// dVectorO(hVectorO.begin(), hVectorO.end()); -// -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); -// -// std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< UDD >( ) ); -// bolt::amp::transform( ctl, dVectorA.begin(), -// dVectorA.end(), -// dVectorB.begin(), -// dVectorO.begin(), -// bolt::amp::plus< UDD >( ) ); -// -// cmpArrays(hVectorO, dVectorO); -// -//} -// -// -//TEST( TransformDeviceVector, OutOfPlaceTransform) -//{ -// int length = 1<<8; -// std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); -// std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); -// std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); -// std::fill( hVectorB.begin(), hVectorB.end(), 0 ); -// -// bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), -// dVectorB(hVectorB.begin(), hVectorB.end()), -// dVectorO(hVectorO.begin(), hVectorO.end()); -// -// std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); -// bolt::amp::transform( dVectorA.begin(), -// dVectorA.end(), -// dVectorB.begin(), -// dVectorO.begin(), -// bolt::amp::plus< int >( ) ); -// -// cmpArrays(hVectorO, dVectorO); -// -//} -// -//TEST( TransformDeviceVector, SerialOutOfPlaceTransform) -//{ -// int length = 1<<8; -// std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); -// std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); -// std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); -// std::fill( hVectorB.begin(), hVectorB.end(), 0 ); -// -// bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), -// dVectorB(hVectorB.begin(), hVectorB.end()), -// dVectorO(hVectorO.begin(), hVectorO.end()); -// -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::SerialCpu); -// -// std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); -// bolt::amp::transform(ctl, dVectorA.begin(), -// dVectorA.end(), -// dVectorB.begin(), -// dVectorO.begin(), -// bolt::amp::plus< int >( ) ); -// -// cmpArrays(hVectorO, dVectorO); -// -// -// -//} -//TEST( TransformDeviceVector, MulticoreOutOfPlaceTransform) -//{ -// int length = 1<<8; -// std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); -// std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); -// std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); -// std::fill( hVectorB.begin(), hVectorB.end(), 0 ); -// -// bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), -// dVectorB(hVectorB.begin(), hVectorB.end()), -// dVectorO(hVectorO.begin(), hVectorO.end()); -// -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); -// -// std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); -// bolt::amp::transform(ctl, dVectorA.begin(), -// dVectorA.end(), -// dVectorB.begin(), -// dVectorO.begin(), -// bolt::amp::plus< int >( ) ); -// -// cmpArrays(hVectorO, dVectorO); -//} -// -//TEST( TransformStdVector, OutOfPlaceTransform) -//{ -// int length = 1<<8; -// std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); -// std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); -// std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); -// std::fill( hVectorB.begin(), hVectorB.end(), 0 ); -// -// std::vector SVectorA(hVectorA.begin(), hVectorA.end()), -// SVectorB(hVectorB.begin(), hVectorB.end()), -// SVectorO(hVectorO.begin(), hVectorO.end()); -// -// std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); -// bolt::amp::transform( SVectorA.begin(), -// SVectorA.end(), -// SVectorB.begin(), -// SVectorO.begin(), -// bolt::amp::plus< int >( ) ); -// -// cmpArrays(hVectorO, SVectorO); -// } -//TEST( TransformStdVector, SerialOutOfPlaceTransform) -//{ -// int length = 1<<8; -// std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); -// std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); -// std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); -// std::fill( hVectorB.begin(), hVectorB.end(), 0 ); -// -// std::vector SVectorA(hVectorA.begin(), hVectorA.end()), -// SVectorB(hVectorB.begin(), hVectorB.end()), -// SVectorO(hVectorO.begin(), hVectorO.end()); -// -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::SerialCpu); -// -// std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); -// bolt::amp::transform(ctl, SVectorA.begin(), -// SVectorA.end(), -// SVectorB.begin(), -// SVectorO.begin(), -// bolt::amp::plus< int >( ) ); -// -// cmpArrays(hVectorO, SVectorO); -// } -//TEST( TransformStdVector, MulticoreOutOfPlaceTransform) -//{ -// int length = 1<<8; -// std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); -// std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); -// std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); -// std::fill( hVectorB.begin(), hVectorB.end(), 0 ); -// -// std::vector SVectorA(hVectorA.begin(), hVectorA.end()), -// SVectorB(hVectorB.begin(), hVectorB.end()), -// SVectorO(hVectorO.begin(), hVectorO.end()); -// -// bolt::amp::control ctl = bolt::amp::control::getDefault( ); -// ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); -// -// std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); -// bolt::amp::transform(ctl, SVectorA.begin(), -// SVectorA.end(), -// SVectorB.begin(), -// SVectorO.begin(), -// bolt::amp::plus< int >( ) ); -// -// cmpArrays(hVectorO, SVectorO); -// } -// -//TEST( DVIntVector, OffsetIntTest ) -//{ -// int length = 1024; -// -// std::vector stdInput( length ,1); -// bolt::amp::device_vector boltInput(stdInput.begin(),stdInput.end()); -// -// int offset = 100; -// -// std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); -// bolt::amp::transform( boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); -// -// cmpArrays( stdInput, boltInput); -// -//} -// -//TEST( DVIntVector, OffsetDoubleTest ) -//{ -// int length = 1024; -// -// std::vector stdInput( length ,4.0); -// bolt::amp::device_vector boltInput(stdInput.begin(),stdInput.end()); -// -// int offset = 100; -// -// std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); -// bolt::amp::transform( boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); -// -// cmpArrays( stdInput, boltInput); -// -//} -// -// -//// Test lots of consecutive numbers, but small range, suitable for integers because they overflow easier -//INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformIntegerVector, ::testing::Range( 0, 1024, 1 ) ); -//INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformIntegerDeviceVector, ::testing::Range( 0, 1024, 1 ) ); -// -//// Test a huge range, suitable for floating point as they are less prone to overflow (but floating point -//// loses granularity at large values) -//INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformFloatVector, ::testing::Range( 0, 1048576, 4096 ) ); -//INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformFloatDeviceVector, ::testing::Range( 0, 1048576, 4096 ) ); -// -//INSTANTIATE_TEST_CASE_P( InplaceSquareTransform, TransformFloatVector, ::testing::Range( 0, 1048576, 4096 ) ); -//INSTANTIATE_TEST_CASE_P( InplaceSquareTransform, TransformFloatDeviceVector, ::testing::Range( 0, 1048576, 4096 ) ); -// -//INSTANTIATE_TEST_CASE_P( InplaceCubeTransform, TransformFloatVector, ::testing::Range( 0, 1048576, 4096 ) ); -//INSTANTIATE_TEST_CASE_P( InplaceCubeTransform, TransformFloatDeviceVector, ::testing::Range( 0, 1048576, 4096 ) ); -// -//#if(TEST_DOUBLE == 1) -//INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformDoubleVector, ::testing::Range( 0, 1048576, 4096 ) ); -//INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformDoubleDeviceVector, ::testing::Range( 0, 1048576, 4096 ) ); -// -//INSTANTIATE_TEST_CASE_P( InplaceTransform, TransformDoubleVector, ::testing::Range( 0, 1048576, 4096 ) ); -//INSTANTIATE_TEST_CASE_P( InplaceTransform, TransformDoubleDeviceVector, ::testing::Range( 0, 1048576, 4096 ) ); -// -//#endif -//typedef ::testing::Types< -// std::tuple< int, TypeValue< 1 > >, -// std::tuple< int, TypeValue< 31 > >, -// std::tuple< int, TypeValue< 32 > >, -// std::tuple< int, TypeValue< 63 > >, -// std::tuple< int, TypeValue< 64 > >, -// std::tuple< int, TypeValue< 127 > >, -// std::tuple< int, TypeValue< 128 > >, -// std::tuple< int, TypeValue< 129 > >, -// std::tuple< int, TypeValue< 1000 > >, -// std::tuple< int, TypeValue< 1053 > >, -// std::tuple< int, TypeValue< 4096 > >, -// std::tuple< int, TypeValue< 4097 > >, -// std::tuple< int, TypeValue< 65535 > >, -// std::tuple< int, TypeValue< 65536 > > -//> IntegerTests; -// +template< typename ArrayTuple > +const size_t TransformArrayTest< ArrayTuple >::ArraySize; + +template< typename ArrayTuple > +const size_t TransformBinaryArrayTest< ArrayTuple >::ArraySize; + +template< typename ArrayTuple > +const size_t TransformOutPlaceArrayTest< ArrayTuple >::ArraySize; + + +TYPED_TEST_CASE_P( TransformArrayTest ); +TYPED_TEST_CASE_P( TransformBinaryArrayTest ); +TYPED_TEST_CASE_P( TransformOutPlaceArrayTest ); + + +TYPED_TEST_P( TransformArrayTest, InPlaceNegateTransform ) +{ + typedef std::array< ArrayType, ArraySize > ArrayCont; + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); + bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); + + ArrayCont::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end( ) ); + ArrayCont::difference_type boltNumElements = std::distance( boltInput.begin( ), boltInput.end( ) ); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdInput, boltInput ); +} +TYPED_TEST_P( TransformArrayTest, SerialInPlaceNegateTransform ) +{ + typedef std::array< ArrayType, ArraySize > ArrayCont; + + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::SerialCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ),bolt::amp::negate()); + + ArrayCont::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end( ) ); + ArrayCont::difference_type boltNumElements = std::distance( boltInput.begin( ), boltInput.end( ) ); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdInput, boltInput ); +} +TYPED_TEST_P( TransformArrayTest, MulticoreInPlaceNegateTransform ) +{ + typedef std::array< ArrayType, ArraySize > ArrayCont; + + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ),bolt::amp::negate()); + + ArrayCont::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end( ) ); + ArrayCont::difference_type boltNumElements = std::distance( boltInput.begin( ), boltInput.end( ) ); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdInput, boltInput ); +} + + + + +TYPED_TEST_P( TransformBinaryArrayTest, BinaryPlusTransform ) +{ + typedef std::array< ArrayType, ArraySize > ArrayCont; + + // Calling the actual functions under test + std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), + std::plus< ArrayType >( ) ); + bolt::amp::transform( boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), + bolt::amp::plus< ArrayType >( ) ); + + ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); + ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +} +TYPED_TEST_P( TransformBinaryArrayTest, SerialBinaryPlusTransform ) +{ + typedef std::array< ArrayType, ArraySize > ArrayCont; + + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::SerialCpu); + + // Calling the actual functions under test + std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), + std::plus< ArrayType >( ) ); + bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), + bolt::amp::plus< ArrayType >( ) ); + + ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); + ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +} +TYPED_TEST_P( TransformBinaryArrayTest, MulticoreBinaryPlusTransform ) +{ + typedef std::array< ArrayType, ArraySize > ArrayCont; + + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + + // Calling the actual functions under test + std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), + std::plus< ArrayType >( ) ); + bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), + bolt::amp::plus< ArrayType >( ) ); + + ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); + ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +} + + + +TYPED_TEST_P( TransformBinaryArrayTest, BinaryMultipliesTransform ) +{ + typedef std::array< ArrayType, ArraySize > ArrayCont; + + // Calling the actual functions under test + std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), + std::multiplies< ArrayType >( ) ); + bolt::amp::transform( boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), + bolt::amp::multiplies< ArrayType >( ) ); + + ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); + ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +} +TYPED_TEST_P( TransformBinaryArrayTest, SerialBinaryMultipliesTransform ) +{ + typedef std::array< ArrayType, ArraySize > ArrayCont; + + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::SerialCpu); + + // Calling the actual functions under test + std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), + std::multiplies< ArrayType >( ) ); + bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), + bolt::amp::multiplies< ArrayType >( ) ); + + ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); + ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +} +TYPED_TEST_P( TransformBinaryArrayTest, MulticoreBinaryMultipliesTransform ) +{ + typedef std::array< ArrayType, ArraySize > ArrayCont; + + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + + // Calling the actual functions under test + std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), + std::multiplies< ArrayType >( ) ); + bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), + bolt::amp::multiplies< ArrayType >( ) ); + + ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); + ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +} + + +TYPED_TEST_P( TransformBinaryArrayTest, BinaryMaxTransform ) +{ + typedef std::array< ArrayType, ArraySize > ArrayCont; + + // Calling the actual functions under test + std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), [] (ArrayType lhs, + ArrayType rhs) { return rhs > lhs ? rhs:lhs; } ); + bolt::amp::transform( boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), + bolt::amp::maximum< ArrayType >( ) ); + + ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); + ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +} +TYPED_TEST_P( TransformBinaryArrayTest, SerialBinaryMaxTransform ) +{ + typedef std::array< ArrayType, ArraySize > ArrayCont; + + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::SerialCpu); + + // Calling the actual functions under test + std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), [] (ArrayType lhs, + ArrayType rhs) { return rhs > lhs ? rhs:lhs; } ); + bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), + bolt::amp::maximum< ArrayType >( ) ); + + ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); + ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +} +TYPED_TEST_P( TransformBinaryArrayTest, MulticoreBinaryMaxTransform ) +{ + typedef std::array< ArrayType, ArraySize > ArrayCont; + + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + + // Calling the actual functions under test + std::transform( stdInput1.begin( ), stdInput1.end( ), stdInput2.begin( ), stdOutput.begin(), [] (ArrayType lhs, + ArrayType rhs) { return rhs > lhs ? rhs:lhs; } ); + bolt::amp::transform(ctl, boltInput1.begin( ), boltInput1.end( ), boltInput2.begin( ), boltOutput.begin(), + bolt::amp::maximum< ArrayType >( ) ); + + ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin( ), stdOutput.end() ); + ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin( ), boltOutput.end() ); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +} + + + +TYPED_TEST_P( TransformOutPlaceArrayTest, OutPlaceSquareTransform ) +{ + typedef std::array< ArrayType, ArraySize > ArrayCont; + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdOutput.begin(), []( ArrayType x ) {return x*x;} ); + bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltOutput.begin(), bolt::amp::square< ArrayType >()); + + + ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin(), stdOutput.end() ); + ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin(), boltOutput.end() ); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +} +TYPED_TEST_P( TransformOutPlaceArrayTest, SerialOutPlaceSquareTransform ) +{ + typedef std::array< ArrayType, ArraySize > ArrayCont; + + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::SerialCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdOutput.begin(), []( ArrayType x ) {return x*x;} ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltOutput.begin(), + bolt::amp::square< ArrayType >( ) ); + + + ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin(), stdOutput.end() ); + ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin(), boltOutput.end() ); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +} +TYPED_TEST_P( TransformOutPlaceArrayTest, MulticoreOutPlaceSquareTransform ) +{ + typedef std::array< ArrayType, ArraySize > ArrayCont; + + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdOutput.begin(), []( ArrayType x ) {return x*x;} ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltOutput.begin(), + bolt::amp::square< ArrayType >( ) ); + + + ArrayCont::difference_type stdNumElements = std::distance( stdOutput.begin(), stdOutput.end() ); + ArrayCont::difference_type boltNumElements = std::distance( boltOutput.begin(), boltOutput.end() ); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpStdArray< ArrayType, ArraySize >::cmpArrays( stdOutput, boltOutput ); +} + + +struct UDD +{ + int a; + int b; + + bool operator() (const UDD& lhs, const UDD& rhs) const restrict(amp,cpu){ + return ((lhs.a+lhs.b) > (rhs.a+rhs.b)); + } + bool operator < (const UDD& other) const restrict(amp,cpu){ + return ((a+b) < (other.a+other.b)); + } + bool operator > (const UDD& other) const restrict(amp,cpu){ + return ((a+b) > (other.a+other.b)); + } + bool operator == (const UDD& other) const restrict(amp,cpu) { + return ((a+b) == (other.a+other.b)); + } + + UDD operator + (const UDD &rhs) const restrict(amp,cpu) + { + UDD _result; + _result.a = a + rhs.a; + _result.b = b + rhs.b; + return _result; + } + + + UDD() restrict(amp,cpu) + : a(0),b(0) { } + UDD(int _in) restrict(amp,cpu) + : a(_in), b(_in +1) { } +}; + + + +REGISTER_TYPED_TEST_CASE_P( TransformArrayTest, InPlaceNegateTransform, SerialInPlaceNegateTransform, + MulticoreInPlaceNegateTransform ); +REGISTER_TYPED_TEST_CASE_P( TransformOutPlaceArrayTest, OutPlaceSquareTransform, SerialOutPlaceSquareTransform, + MulticoreOutPlaceSquareTransform ); +REGISTER_TYPED_TEST_CASE_P( TransformBinaryArrayTest, BinaryPlusTransform, SerialBinaryPlusTransform, + MulticoreBinaryPlusTransform, BinaryMultipliesTransform, + SerialBinaryMultipliesTransform, MulticoreBinaryMultipliesTransform, + BinaryMaxTransform, SerialBinaryMaxTransform, MulticoreBinaryMaxTransform); + + +///////////////////////////////////////////////////////////////////////////////////////////////////////// +// Fixture classes are now defined to enable googletest to process value parameterized tests + +// ::testing::TestWithParam< int > means that GetParam( ) returns int values, which i use for array size +class TransformIntegerVector: public ::testing::TestWithParam< int > +{ +public: + // Create an std and a bolt vector of requested size, and initialize all the elements to 1 + TransformIntegerVector( ): stdInput( GetParam( ), 1 ), boltInput( GetParam( ), 1 ) + {} + +protected: + std::vector< int > stdInput, boltInput; +}; + +class TransformIntegerDeviceVector: public ::testing::TestWithParam< int > +{ +public: + // Create an std and a bolt vector of requested size, and initialize all the elements to 1 + TransformIntegerDeviceVector( ): stdInput( GetParam( ), 1 ), boltInput(static_cast(GetParam( )), 1 ) + { + std::generate(stdInput.begin(), stdInput.end(), rand); + //boltInput = stdInput; + //FIXME - The above should work but the below loop is used. + for (int i=0; i< GetParam( ); i++) + { + boltInput[i] = stdInput[i]; + + } + } + +protected: + std::vector< int > stdInput; + bolt::amp::device_vector< int > boltInput; +}; + +// ::testing::TestWithParam< int > means that GetParam( ) returns int values, which i use for array size +class TransformFloatVector: public ::testing::TestWithParam< int > +{ +public: + // Create an std and a bolt vector of requested size, and initialize all the elements to 1 + TransformFloatVector( ): stdInput( GetParam( ), 1.0f ), boltInput( GetParam( ), 1.0f ) + {} + +protected: + std::vector< float > stdInput, boltInput; +}; + + +class TransformFloatDeviceVector: public ::testing::TestWithParam< int > +{ +public: + // Create an std and a bolt vector of requested size, and initialize all the elements to 1 + TransformFloatDeviceVector( ): stdInput( GetParam( ), 1.0f ), boltInput( static_cast( GetParam( ) ), 1.0f ) + { + std::generate(stdInput.begin(), stdInput.end(), rand); + //boltInput = stdInput; + //FIXME - The above should work but the below loop is used. + for (int i=0; i< GetParam( ); i++) + { + boltInput[i] = stdInput[i]; + } + + } + +protected: + std::vector< float > stdInput; + bolt::amp::device_vector< float > boltInput; +}; +// ::testing::TestWithParam< int > means that GetParam( ) returns int values, which i use for array size +class TransformDoubleVector: public ::testing::TestWithParam< int > +{ +public: + // Create an std and a bolt vector of requested size, and initialize all the elements to 1 + TransformDoubleVector( ): stdInput( GetParam( ), 1.0 ), boltInput( GetParam( ), 1.0 ) + {} + +protected: + std::vector< double > stdInput, boltInput; +}; + + +#if (TEST_DOUBLE == 1) +// ::testing::TestWithParam< int > means that GetParam( ) returns int values, which i use for array size +class TransformDoubleDeviceVector: public ::testing::TestWithParam< int > +{ +public: + // Create an std and a bolt vector of requested size, and initialize all the elements to 1 + TransformDoubleDeviceVector( ): stdInput( GetParam( ), 1.0 ), boltInput( static_cast( GetParam( ) ), 1.0 ) + { + std::generate(stdInput.begin(), stdInput.end(), rand); + //boltInput = stdInput; + //FIXME - The above should work but the below loop is used. + for (int i=0; i< GetParam( ); i++) + { + boltInput[i] = stdInput[i]; + } + } + +protected: + std::vector< double > stdInput; + bolt::amp::device_vector< double > boltInput; +}; +#endif + + +TEST( HostIntVector, OffsetTransform ) +{ + int length = 1024; + + std::vector stdInput( length ,1); + std::vector boltInput(stdInput.begin(),stdInput.end()); + + int offset = 100; + + std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); + bolt::amp::transform( boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); + + cmpArrays( stdInput, boltInput); + +} + +TEST( HostIntVector, SerialOffsetTransform ) +{ + int length = 1024; + + std::vector stdInput( length ,1); + std::vector boltInput(stdInput.begin(),stdInput.end()); + + int offset = 100; + + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::SerialCpu); + + std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); + bolt::amp::transform(ctl, boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); + + cmpArrays( stdInput, boltInput); + +} + +TEST( HostIntVector, MulticoreOffsetTransform ) +{ + int length = 1024; + + std::vector stdInput( length ,1); + std::vector boltInput(stdInput.begin(),stdInput.end()); + + int offset = 100; + + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + + std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); + bolt::amp::transform(ctl, boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); + + cmpArrays( stdInput, boltInput); + +} + +TEST( DVIntVector, OffsetTransform ) +{ + int length = 1024; + + std::vector stdInput( length ,1); + bolt::amp::device_vector boltInput(stdInput.begin(),stdInput.end()); + + int offset = 100; + + std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); + bolt::amp::transform( boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); + + cmpArrays( stdInput, boltInput); + +} + +TEST( DVIntVector, SerialOffsetTransform ) +{ + int length = 1024; + + std::vector stdInput( length ,1); + bolt::amp::device_vector boltInput(stdInput.begin(),stdInput.end()); + + int offset = 100; + + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::SerialCpu); + + std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); + bolt::amp::transform( ctl, boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); + + cmpArrays( stdInput, boltInput); + +} + +TEST( DVIntVector, MulticoreOffsetTransform ) +{ + int length = 1024; + + std::vector stdInput( length ,1); + bolt::amp::device_vector boltInput(stdInput.begin(),stdInput.end()); + + int offset = 100; + + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + + std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); + bolt::amp::transform( ctl, boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); + + cmpArrays( stdInput, boltInput); + +} + +TEST_P( TransformIntegerVector, InplaceTransform ) +{ + // Calling the actual functions under test + std::transform( stdInput.begin(), stdInput.end(), stdInput.begin(), std::negate()); + bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); + + + + std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); + std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin( ),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} +TEST_P( TransformIntegerVector, SerialInplaceTransform ) +{ + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::SerialCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin(), stdInput.end(), stdInput.begin(), std::negate()); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); + + + + std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); + std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin( ),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} +TEST_P( TransformIntegerVector, MulticoreInplaceTransform ) +{ + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin(), stdInput.end(), stdInput.begin(), std::negate()); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); + + + + std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); + std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin( ),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} + + +TEST_P( TransformIntegerDeviceVector, InplaceTransform ) +{ + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); + bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); + + std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); + std::vector< int >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} +TEST_P( TransformIntegerDeviceVector, SerialInplaceTransform ) +{ + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::SerialCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); + + std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); + std::vector< int >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} +TEST_P( TransformIntegerDeviceVector, MulticoreInplaceTransform ) +{ + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); + + std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); + std::vector< int >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} + + +TEST_P( TransformFloatVector, InplaceTransform ) +{ + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); + bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); + + + std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); + std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} +TEST_P( TransformFloatVector, SerialInplaceTransform ) +{ + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::SerialCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); + + + std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); + std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} +TEST_P( TransformFloatVector, MulticoreInplaceTransform ) +{ + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); + + + std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); + std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} + +TEST_P( TransformFloatDeviceVector, InplaceTransform ) +{ + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); + bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); + + + std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); + std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} +TEST_P( TransformFloatDeviceVector, SerialInplaceTransform ) +{ + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::SerialCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); + + + std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); + std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} +TEST_P( TransformFloatDeviceVector, MulticoreInplaceTransform ) +{ + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); + + + std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); + std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} + +TEST_P( TransformFloatVector, InplaceSquareTransform ) +{ + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); + bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); + + + std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); + std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} +TEST_P( TransformFloatVector, SerialInplaceSquareTransform ) +{ + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::SerialCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); + + + std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); + std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} +TEST_P( TransformFloatVector, MulticoreInplaceSquareTransform ) +{ + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); + + + std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); + std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} + +TEST_P( TransformFloatDeviceVector, InplaceSquareTransform ) +{ + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); + bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); + + + std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); + std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} +TEST_P( TransformFloatDeviceVector, SerialInplaceSquareTransform ) +{ + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::SerialCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); + + + std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); + std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} +TEST_P( TransformFloatDeviceVector, MulticoreInplaceSquareTransform ) +{ + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x;} ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::square() ); + + + std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); + std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} + + +TEST_P( TransformFloatVector, InplaceCubeTransform ) +{ + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); + bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); + + + std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); + std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} +TEST_P( TransformFloatVector, SerialInplaceCubeTransform ) +{ + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::SerialCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); + + + std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ),stdInput.end()); + std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} +TEST_P( TransformFloatVector, MulticoreInplaceCubeTransform ) +{ + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); + + + std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); + std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} + +TEST_P( TransformFloatDeviceVector, InplaceCubeTransform ) +{ + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); + bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); + + + std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); + std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} +TEST_P( TransformFloatDeviceVector, SerialInplaceCubeTransform ) +{ + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::SerialCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); + + + std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ),stdInput.end()); + std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} +TEST_P( TransformFloatDeviceVector, MulticoreInplaceCubeTransform ) +{ + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), [](float x){return x*x*x;} ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::cube() ); + + + std::vector< float >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end()); + std::vector< float >::iterator::difference_type boltNumElements = std::distance(boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} + + +#if(TEST_DOUBLE == 1) +TEST_P( TransformDoubleVector, InplaceTransform ) +{ + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); + bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); + + + std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); + std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} +TEST_P( TransformDoubleVector, SerialInplaceTransform ) +{ + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::SerialCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); + + + std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); + std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} +TEST_P( TransformDoubleVector, MulticoreInplaceTransform ) +{ + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate()); + + + std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); + std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} + + +TEST_P( TransformDoubleDeviceVector, InplaceTransform ) +{ + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); + bolt::amp::transform( boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); + + + std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); + std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} +TEST_P( TransformDoubleDeviceVector, SerialInplaceTransform ) +{ + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::SerialCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate() ); + + + std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); + std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} +TEST_P( TransformDoubleDeviceVector, MulticoreInplaceTransform ) +{ + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + + // Calling the actual functions under test + std::transform( stdInput.begin( ), stdInput.end( ), stdInput.begin( ), std::negate() ); + bolt::amp::transform(ctl, boltInput.begin( ), boltInput.end( ), boltInput.begin( ), bolt::amp::negate()); + + + std::vector< int >::iterator::difference_type stdNumElements = std::distance( stdInput.begin( ), stdInput.end() ); + std::vector< int >::iterator::difference_type boltNumElements = std::distance( boltInput.begin(),boltInput.end()); + + // Both collections should have the same number of elements + EXPECT_EQ( stdNumElements, boltNumElements ); + + // Loop through the array and compare all the values with each other + cmpArrays( stdInput, boltInput ); +} + +#endif + +TEST( TransformDeviceVector, UDDOutOfPlaceTransform) +{ + int length = 1<<8; + std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); + std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); + std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); + std::fill( hVectorB.begin(), hVectorB.end(), 0 ); + + bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), + dVectorB(hVectorB.begin(), hVectorB.end()), + dVectorO(hVectorO.begin(), hVectorO.end()); + + std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< UDD >( ) ); + bolt::amp::transform( dVectorA.begin(), + dVectorA.end(), + dVectorB.begin(), + dVectorO.begin(), + bolt::amp::plus< UDD >( ) ); + + cmpArrays(hVectorO, dVectorO); + +} + +TEST( TransformDeviceVector, SerialUDDOutOfPlaceTransform) +{ + int length = 1<<8; + std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); + std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); + std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); + std::fill( hVectorB.begin(), hVectorB.end(), 0 ); + + bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), + dVectorB(hVectorB.begin(), hVectorB.end()), + dVectorO(hVectorO.begin(), hVectorO.end()); + + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::SerialCpu); + + std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< UDD >( ) ); + bolt::amp::transform( ctl, dVectorA.begin(), + dVectorA.end(), + dVectorB.begin(), + dVectorO.begin(), + bolt::amp::plus< UDD >( ) ); + + cmpArrays(hVectorO, dVectorO); + +} + + +TEST( TransformDeviceVector, MulticoreUDDOutOfPlaceTransform) +{ + int length = 1<<8; + std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); + std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); + std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); + std::fill( hVectorB.begin(), hVectorB.end(), 0 ); + + bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), + dVectorB(hVectorB.begin(), hVectorB.end()), + dVectorO(hVectorO.begin(), hVectorO.end()); + + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + + std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< UDD >( ) ); + bolt::amp::transform( ctl, dVectorA.begin(), + dVectorA.end(), + dVectorB.begin(), + dVectorO.begin(), + bolt::amp::plus< UDD >( ) ); + + cmpArrays(hVectorO, dVectorO); + +} + + +TEST( TransformDeviceVector, OutOfPlaceTransform) +{ + int length = 1<<8; + std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); + std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); + std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); + std::fill( hVectorB.begin(), hVectorB.end(), 0 ); + + bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), + dVectorB(hVectorB.begin(), hVectorB.end()), + dVectorO(hVectorO.begin(), hVectorO.end()); + + std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); + bolt::amp::transform( dVectorA.begin(), + dVectorA.end(), + dVectorB.begin(), + dVectorO.begin(), + bolt::amp::plus< int >( ) ); + + cmpArrays(hVectorO, dVectorO); + +} + +TEST( TransformDeviceVector, SerialOutOfPlaceTransform) +{ + int length = 1<<8; + std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); + std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); + std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); + std::fill( hVectorB.begin(), hVectorB.end(), 0 ); + + bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), + dVectorB(hVectorB.begin(), hVectorB.end()), + dVectorO(hVectorO.begin(), hVectorO.end()); + + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::SerialCpu); + + std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); + bolt::amp::transform(ctl, dVectorA.begin(), + dVectorA.end(), + dVectorB.begin(), + dVectorO.begin(), + bolt::amp::plus< int >( ) ); + + cmpArrays(hVectorO, dVectorO); + + + +} +TEST( TransformDeviceVector, MulticoreOutOfPlaceTransform) +{ + int length = 1<<8; + std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); + std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); + std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); + std::fill( hVectorB.begin(), hVectorB.end(), 0 ); + + bolt::amp::device_vector dVectorA(hVectorA.begin(), hVectorA.end()), + dVectorB(hVectorB.begin(), hVectorB.end()), + dVectorO(hVectorO.begin(), hVectorO.end()); + + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + + std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); + bolt::amp::transform(ctl, dVectorA.begin(), + dVectorA.end(), + dVectorB.begin(), + dVectorO.begin(), + bolt::amp::plus< int >( ) ); + + cmpArrays(hVectorO, dVectorO); +} + +TEST( TransformStdVector, OutOfPlaceTransform) +{ + int length = 1<<8; + std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); + std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); + std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); + std::fill( hVectorB.begin(), hVectorB.end(), 0 ); + + std::vector SVectorA(hVectorA.begin(), hVectorA.end()), + SVectorB(hVectorB.begin(), hVectorB.end()), + SVectorO(hVectorO.begin(), hVectorO.end()); + + std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); + bolt::amp::transform( SVectorA.begin(), + SVectorA.end(), + SVectorB.begin(), + SVectorO.begin(), + bolt::amp::plus< int >( ) ); + + cmpArrays(hVectorO, SVectorO); + } +TEST( TransformStdVector, SerialOutOfPlaceTransform) +{ + int length = 1<<8; + std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); + std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); + std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); + std::fill( hVectorB.begin(), hVectorB.end(), 0 ); + + std::vector SVectorA(hVectorA.begin(), hVectorA.end()), + SVectorB(hVectorB.begin(), hVectorB.end()), + SVectorO(hVectorO.begin(), hVectorO.end()); + + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::SerialCpu); + + std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); + bolt::amp::transform(ctl, SVectorA.begin(), + SVectorA.end(), + SVectorB.begin(), + SVectorO.begin(), + bolt::amp::plus< int >( ) ); + + cmpArrays(hVectorO, SVectorO); + } + +TEST( TransformStdVector, MulticoreOutOfPlaceTransform) +{ + int length = 1<<8; + std::vector hVectorA( length ), hVectorB( length ), hVectorO( length ); + std::fill( hVectorA.begin(), hVectorA.end(), 1024 ); + std::fill( hVectorB.begin(), hVectorB.end(), 1024 ); + std::fill( hVectorB.begin(), hVectorB.end(), 0 ); + + std::vector SVectorA(hVectorA.begin(), hVectorA.end()), + SVectorB(hVectorB.begin(), hVectorB.end()), + SVectorO(hVectorO.begin(), hVectorO.end()); + + bolt::amp::control ctl = bolt::amp::control::getDefault( ); + ctl.setForceRunMode(bolt::amp::control::MultiCoreCpu); + + std::transform( hVectorA.begin(), hVectorA.end(), hVectorB.begin(), hVectorO.begin(), std::plus< int >( ) ); + bolt::amp::transform(ctl, SVectorA.begin(), + SVectorA.end(), + SVectorB.begin(), + SVectorO.begin(), + bolt::amp::plus< int >( ) ); + + cmpArrays(hVectorO, SVectorO); + } + +TEST( DVIntVector, OffsetIntTest ) +{ + int length = 1024; + + std::vector stdInput( length ,1); + bolt::amp::device_vector boltInput(stdInput.begin(),stdInput.end()); + + int offset = 100; + + std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); + bolt::amp::transform( boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); + + cmpArrays( stdInput, boltInput); + +} + +TEST( DVIntVector, OffsetDoubleTest ) +{ + int length = 1024; + + std::vector stdInput( length ,4.0); + bolt::amp::device_vector boltInput(stdInput.begin(),stdInput.end()); + + int offset = 100; + + std::transform( stdInput.begin( ) + offset, stdInput.end( ), stdInput.begin() + offset, std::negate() ); + bolt::amp::transform( boltInput.begin( ) + offset, boltInput.end( ), boltInput.begin( ) + offset, bolt::amp::negate() ); + + cmpArrays( stdInput, boltInput); + +} + + +// Test lots of consecutive numbers, but small range, suitable for integers because they overflow easier +INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformIntegerVector, ::testing::Range( 0, 1024, 1 ) ); +INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformIntegerDeviceVector, ::testing::Range( 0, 1024, 1 ) ); + +// Test a huge range, suitable for floating point as they are less prone to overflow (but floating point +// loses granularity at large values) +INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformFloatVector, ::testing::Range( 0, 1048576, 4096 ) ); +INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformFloatDeviceVector, ::testing::Range( 0, 1048576, 4096 ) ); + +INSTANTIATE_TEST_CASE_P( InplaceSquareTransform, TransformFloatVector, ::testing::Range( 0, 1048576, 4096 ) ); +INSTANTIATE_TEST_CASE_P( InplaceSquareTransform, TransformFloatDeviceVector, ::testing::Range( 0, 1048576, 4096 ) ); + +INSTANTIATE_TEST_CASE_P( InplaceCubeTransform, TransformFloatVector, ::testing::Range( 0, 1048576, 4096 ) ); +INSTANTIATE_TEST_CASE_P( InplaceCubeTransform, TransformFloatDeviceVector, ::testing::Range( 0, 1048576, 4096 ) ); + +#if(TEST_DOUBLE == 1) +INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformDoubleVector, ::testing::Range( 0, 1048576, 4096 ) ); +INSTANTIATE_TEST_CASE_P( TransformInPlace, TransformDoubleDeviceVector, ::testing::Range( 0, 1048576, 4096 ) ); + +INSTANTIATE_TEST_CASE_P( InplaceTransform, TransformDoubleVector, ::testing::Range( 0, 1048576, 4096 ) ); +INSTANTIATE_TEST_CASE_P( InplaceTransform, TransformDoubleDeviceVector, ::testing::Range( 0, 1048576, 4096 ) ); + +#endif +typedef ::testing::Types< + std::tuple< int, TypeValue< 1 > >, + std::tuple< int, TypeValue< 31 > >, + std::tuple< int, TypeValue< 32 > >, + std::tuple< int, TypeValue< 63 > >, + std::tuple< int, TypeValue< 64 > >, + std::tuple< int, TypeValue< 127 > >, + std::tuple< int, TypeValue< 128 > >, + std::tuple< int, TypeValue< 129 > >, + std::tuple< int, TypeValue< 1000 > >, + std::tuple< int, TypeValue< 1053 > >, + std::tuple< int, TypeValue< 4096 > >, + std::tuple< int, TypeValue< 4097 > >, + std::tuple< int, TypeValue< 65535 > >, + std::tuple< int, TypeValue< 65536 > > +> IntegerTests; + +typedef ::testing::Types< + std::tuple< float, TypeValue< 1 > >, + std::tuple< float, TypeValue< 31 > >, + std::tuple< float, TypeValue< 32 > >, + std::tuple< float, TypeValue< 63 > >, + std::tuple< float, TypeValue< 64 > >, + std::tuple< float, TypeValue< 127 > >, + std::tuple< float, TypeValue< 128 > >, + std::tuple< float, TypeValue< 129 > >, + std::tuple< float, TypeValue< 1000 > >, + std::tuple< float, TypeValue< 1053 > >, + std::tuple< float, TypeValue< 4096 > >, + std::tuple< float, TypeValue< 4097 > >, + std::tuple< float, TypeValue< 65535 > >, + std::tuple< float, TypeValue< 65536 > > +> FloatTests; + + //typedef ::testing::Types< -// std::tuple< float, TypeValue< 1 > >, -// std::tuple< float, TypeValue< 31 > >, -// std::tuple< float, TypeValue< 32 > >, -// std::tuple< float, TypeValue< 63 > >, -// std::tuple< float, TypeValue< 64 > >, -// std::tuple< float, TypeValue< 127 > >, -// std::tuple< float, TypeValue< 128 > >, -// std::tuple< float, TypeValue< 129 > >, -// std::tuple< float, TypeValue< 1000 > >, -// std::tuple< float, TypeValue< 1053 > >, -// std::tuple< float, TypeValue< 4096 > >, -// std::tuple< float, TypeValue< 4097 > >, -// std::tuple< float, TypeValue< 65535 > >, -// std::tuple< float, TypeValue< 65536 > > -//> FloatTests; -// -// -////typedef ::testing::Types< -//// std::tuple< UDD, TypeValue< 1 > >, -//// std::tuple< UDD, TypeValue< 31 > >, -//// std::tuple< UDD, TypeValue< 32 > >, -//// std::tuple< UDD, TypeValue< 63 > >, -//// std::tuple< UDD, TypeValue< 64 > >, -//// std::tuple< UDD, TypeValue< 127 > >, -//// std::tuple< UDD, TypeValue< 128 > >, -//// std::tuple< UDD, TypeValue< 129 > >, -//// std::tuple< UDD, TypeValue< 1000 > >, -//// std::tuple< UDD, TypeValue< 1053 > >, -//// std::tuple< UDD, TypeValue< 4096 > >, -//// std::tuple< UDD, TypeValue< 4097 > >, -//// std::tuple< UDD, TypeValue< 65535 > >, -//// std::tuple< UDD, TypeValue< 65536 > > -////> UDDTests; +// std::tuple< UDD, TypeValue< 1 > >, +// std::tuple< UDD, TypeValue< 31 > >, +// std::tuple< UDD, TypeValue< 32 > >, +// std::tuple< UDD, TypeValue< 63 > >, +// std::tuple< UDD, TypeValue< 64 > >, +// std::tuple< UDD, TypeValue< 127 > >, +// std::tuple< UDD, TypeValue< 128 > >, +// std::tuple< UDD, TypeValue< 129 > >, +// std::tuple< UDD, TypeValue< 1000 > >, +// std::tuple< UDD, TypeValue< 1053 > >, +// std::tuple< UDD, TypeValue< 4096 > >, +// std::tuple< UDD, TypeValue< 4097 > >, +// std::tuple< UDD, TypeValue< 65535 > >, +// std::tuple< UDD, TypeValue< 65536 > > +//> UDDTests; TEST(TransformStdVector, ConstantIterator) @@ -1644,7 +1645,7 @@ TEST(TransformStdVector, ConstantIterator) //bolt::amp::device_vector hB(hVectorA.begin(), hVectorA.end()); std::transform(hVectorB.begin(), hVectorB.end(), hVectorA.begin(), hVectorO.begin(), std::plus< int >()); - //std::transform(hB.begin(), hB.end(), hVectorA.begin(), hVectorO.begin(), std::plus()); +// std::transform(hB.begin(), hB.end(), hVectorA.begin(), hVectorO.begin(), std::plus()); bolt::amp::transform(hB, hB2, SVectorA.begin(),