Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BOOST_COMPUTE_CLOSURE triggers run-time compiling every time the closure value changes #865

Open
ozpavel opened this issue Jun 24, 2021 · 0 comments

Comments

@ozpavel
Copy link

ozpavel commented Jun 24, 2021

Just wondering if this is a bug or a user error. The below is a snippet showing the issue. Trying to pass different run-time value to closure, that triggers the run-time compiling every time the transform() is called.

If this is user error or not supported, is there a workaround for supplying run-time values to algorithms?

boost::compute::device gpu =
boost::compute::system::default_device();

boost::compute::context context(gpu);

boost::compute::command_queue queue(context, gpu);

size_t size = 10000;
boost::compute::vector va(size, 1, queue);
boost::compute::vector vb(size, 2, queue);
boost::compute::vector vc(size, context);

size_t N = 100;
for (size_t i = 0; i < N-1; ++i)
{
int e = static_cast(i); // changing the 'e' here causing the transform() to compile every time is invoked

BOOST_COMPUTE_CLOSURE(int, calc, (int a, int b), (e),
{
    return a + b + e;
});

boost::compute::transform(
      va.begin(),
      va.end(),
      vb.begin(),
      vc.begin(),
      calc,
      queue);

}

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant