28 #ifndef REMORA_KERNELS_CLBLAS_VECTOR_FOLD_HPP 29 #define REMORA_KERNELS_CLBLAS_VECTOR_FOLD_HPP 31 #include "../../expression_types.hpp" 32 #include "../../detail/traits.hpp" 33 #include <boost/compute/container/array.hpp> 34 #include <boost/compute/algorithm/reduce.hpp> 35 #include <boost/compute/algorithm/copy_n.hpp> 37 namespace remora{
namespace bindings{
39 template<
class F,
class V>
40 void vector_fold(vector_expression<V, gpu_tag>
const& v,
typename F::result_type& value, dense_tag) {
41 boost::compute::array<typename F::result_type,1> val;
42 boost::compute::copy_n(&value,1,val.begin(), v().queue());
43 boost::compute::reduce(v().begin(), v().end(), val.begin(), F(), v().queue());
44 boost::compute::copy_n(val.begin(),1,&value, v().queue());