Skip to content

Commit

Permalink
Get rid of fusion::vector_tie in implementation of generator::kernel
Browse files Browse the repository at this point in the history
Fixes #206
  • Loading branch information
ddemidov committed May 17, 2016
1 parent ede7c94 commit 23da8da
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
8 changes: 7 additions & 1 deletion examples/symbolic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

Expand All @@ -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 );
Expand Down
28 changes: 11 additions & 17 deletions vexcl/generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,10 +577,10 @@ class kernel {

#ifndef BOOST_NO_VARIADIC_TEMPLATES
/// Launches the kernel with the provided parameters.
template <class... Param>
void operator()(const Param&... param) {
boost::fusion::for_each(boost::fusion::vector_tie(param...), push_args(*this));
(*this)();
template <class Head, class... Tail>
void operator()(const Head &head, const Tail&... tail) {
push_arg(head);
(*this)(tail...);
}
#else

Expand All @@ -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 <class T>
void operator()(const T &v) const {
K.add_param(v);
}
};
template <class Head, class... Tail>
static void add_params(kernel &K, const Head &head, const Tail&... tail) {
K.add_param(head);
add_params(K, tail...);
}
private:
std::vector<backend::command_queue> queue;
std::string name;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 23da8da

Please sign in to comment.