2

Is it possible to set which function arguments have 'global' or 'const' modifiers? Or how at least to inspect the code of generated function on a per function basis (to insert it manually)?

Closest thing I saw was BOOST_COMPUTE_STRINGIZE_SOURCE where you write all kernel code by hand, save it into string, compile manually, call using set_arg(argId, wrapedItems) and queue.enqueue_nd_range_kernel that looks so much more complicated than:

    BOOST_COMPUTE_CLOSURE(ftype, kick, (ftype beam), (__const voltage), {
        return beam * sin(beam + voltage);
    });

one would hope for.

KindDragon
  • 6,558
  • 4
  • 47
  • 75
DuckQueen
  • 772
  • 10
  • 62
  • 134
  • Did you mean "Is it possible to se*e*"? Did you mean "which *method* has a const modifier'? What do you mean by 'global modifier', maybe `static`? – Adrian Colomitchi Aug 27 '16 at 05:44
  • I think he meant https://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/global.html – Giovanni Funchal Aug 27 '16 at 05:51
  • @GiovanniFunchal Ah, thanks. If so, they aren't standard C or C++, they are specific extensions to deal with GPU stuff, right? – Adrian Colomitchi Aug 27 '16 at 05:58
  • Yes, I think the original question is confusing. boost::compute wraps around `__global` and `__constant` extensions from OpenCL in a better C++ api, I'm not sure it makes sense to mix them. – Giovanni Funchal Aug 27 '16 at 06:09
  • @GiovanniFunchal: my problem is that when I define `BOOST_COMPUTE_CLOSURE` and pass arguments I can not set `__const` or `__local` for CLOSURE variables and it is not clear with which argument is passed fo the function. – DuckQueen Aug 27 '16 at 22:04

1 Answers1

1

BOOST_COMPUTE_CLOSURE() constructs a function that can be passed to Boost.Compute functions like transform() or sort(). Compared to the BOOST_COMPUTE_FUNCTION(), it allows capturing of in-scope C++ variables. It does not construct a OpenCL kernel object, so there is not really a need to specify an address space qualifier because it never operates on pointers, only on values.

However, if have your own kernel and want to pass a __constant buffer as an argument to it, then use a constant_buffer_iterator.

haahh
  • 321
  • 1
  • 2