From 23da8daa7408ca7c59781b9e7b93d07e2382bb39 Mon Sep 17 00:00:00 2001 From: Denis Demidov Date: Tue, 17 May 2016 11:37:46 +0300 Subject: [PATCH] Get rid of fusion::vector_tie in implementation of generator::kernel Fixes #206 --- examples/symbolic.cpp | 8 +++++++- vexcl/generator.hpp | 28 +++++++++++----------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/examples/symbolic.cpp b/examples/symbolic.cpp index 9c1130715..758a9d368 100644 --- a/examples/symbolic.cpp +++ b/examples/symbolic.cpp @@ -89,6 +89,8 @@ int main( int argc , char **argv ) sym_stepper.do_step(std::ref(sys), sym_S, 0, dt); auto kernel = vex::generator::build_kernel(ctx, "lorenz", body.str(), + sym_S[0], sym_S[1], sym_S[2], sym_R, + sym_S[0], sym_S[1], sym_S[2], sym_R, sym_S[0], sym_S[1], sym_S[2], sym_R ); @@ -109,7 +111,11 @@ int main( int argc , char **argv ) // Integration loop: for(value_type t = 0; t < t_max; t += dt) - kernel(X, Y, Z, R); + kernel( + X, Y, Z, R, + X, Y, Z, R, + X, Y, Z, R + ); std::vector< value_type > result( n ); vex::copy( X , result ); diff --git a/vexcl/generator.hpp b/vexcl/generator.hpp index 48e51b715..14a948173 100644 --- a/vexcl/generator.hpp +++ b/vexcl/generator.hpp @@ -577,10 +577,10 @@ class kernel { #ifndef BOOST_NO_VARIADIC_TEMPLATES /// Launches the kernel with the provided parameters. - template - void operator()(const Param&... param) { - boost::fusion::for_each(boost::fusion::vector_tie(param...), push_args(*this)); - (*this)(); + template + void operator()(const Head &head, const Tail&... tail) { + push_arg(head); + (*this)(tail...); } #else @@ -600,16 +600,13 @@ BOOST_PP_REPEAT_FROM_TO(1, VEXCL_MAX_ARITY, VEXCL_FUNCALL_OPERATOR, ~) #endif - struct add_params { - kernel &K; - - add_params(kernel &K) : K(K) {} + static void add_params(kernel &K) {} - template - void operator()(const T &v) const { - K.add_param(v); - } - }; + template + static void add_params(kernel &K, const Head &head, const Tail&... tail) { + K.add_param(head); + add_params(K, tail...); + } private: std::vector queue; std::string name; @@ -674,10 +671,7 @@ kernel build_kernel( ) { kernel K(queue, name); - boost::fusion::for_each( - boost::fusion::vector_tie(args...), - kernel::add_params(K) - ); + kernel::add_params(K, args...); K.build(body); return K; }