Warnning when using cgh.require()

I have a placeholder accessor in my codes and when I use cgh.require() to link it with a buffer. The compiler emit following warning:

cgh.require(buf, acc); /*Deprecated Codeplay extension function: Bind the null accessor first, then call require() [-Wdeprecated-declarations]*/

Is there a bind function for buffer and accessor?

Hi @Ryan_xjh,

You can try instead overwriting the accessor when you need to bind it to a buffer. For that you’ll need to have a reference to the original accessor. Example code you could use (you don’t need a function, though):

template <...>
void bind_acc(accessor<...>& acc, const buffer<...>& buf) {
  acc = accessor<...>(buf);
}

You would then bind the accessor to the buffer at some point, preferably before command group submission, and then just call cgh.require(acc).

We decided to deprecate this function because the behavior of cgh.require(acc) and cgh.require(buf, acc) is very different. Registering an accessor (without the buffer) just registers it for that command group, while binding it to a buffer is a modifying operation that affects future use of the accessor.

1 Like

Thanks @peterzuzek! It works. Appreciate it!