Open ProGTX opened 4 years ago
That looks good.
A minor point I see is that before by default an accessor
constructor without a CGH was a host accessor
. Now it is no longer the case, since it might be a default placeholder accessor
to be used in a kernel instead.
A minor point I see is that before by default an
accessor
constructor without a CGH was a hostaccessor
. Now it is no longer the case, since it might be a default placeholderaccessor
to be used in a kernel instead.
@keryell You're right that the default when constructing an accessor will now be a placeholder instead of a host accessor, but this is only really important for CTAD, otherwise you'd still need to specify target::host_buffer
. Allowing CTAD to determine either a device accessor or a host accessor based on whether the handler was provided seems dangerous to us - it is already a common mistake to call get_access
without a handler, which gives you a host accessor in a command group, which is UB. At least with a placeholder you still have the option of calling require
(which is valid for placeholders and non-placeholders according to this proposal), which gets rid of the UB.
There is even some interest in making host accessors a separate type, as an extension of the work here and in https://github.com/codeplaysoftware/standards-proposals/pull/100.
Allowing CTAD to determine either a device accessor or a host accessor based on whether the handler was provided seems dangerous to us - it is already a common mistake to call
get_access
without a handler, which gives you a host accessor in a command group, which is UB.
The compiler should warn about it at least. But this is what I do in all the example I show because it is shorter...
The compiler should warn about it at least. But this is what I do in all the example I show because it is shorter...
I think that calling buf.get_access<mode>()
is still fine, I'm just saying that sometimes this happens because the user forgets to pass the handler - they wanted a device accessor, but got a host one instead, so with new proposals I'm keen on making more of a distinction between host and device accessors. I'm not sure if the compiler has enough information to warn on this.
access::placeholder
handler::require
is_null
has_handler