It would have been nice to include some description in the blog post as to why you would use work_group_reserve_read_pipe rather than just letting each work item do a read_pipe() without a reservation id. Performance?
Thanks for your suggestion. I've already forwarded to concern person.
I want to highlight few important points of reservation mechanism as follows:
As per OpenCL Spec:
"NOTE: The read_pipe and write_pipe functions that take a reservation ID as an argument can be used to read from or write to a packet index. These built-ins can be used to read from or write to a packet index one or multiple times. If a packet index that is reserved for writing is not written to using the write_pipe function, the contents of that packet in the pipe are undefined. commit_read_pipe and work_group_commit_read_pipe remove the entries reserved for reading from the pipe. commit_write_pipe and work_group_commit_write_pipe ensures that the entries reserved for writing are all added in-order as one contiguous set of packets to the pipe.”
- If multiple work-items in a work group need to access a pipe item multiple times, this procedure is clearly beneficial.
- As work-group level reservations put the items in order within the work-group and so it gives better cache benefits. Performance would be better.
- As reading/writing to/from a reserve space needs an index to access the item, the reserved space can be thought as array/buffer and any scatter/gather operation can be performed using the index.
- In a typical scenario where a WI working with multiple data items and wants to pass them such that corresponding consumer WI can access them as a in-order contiguous set, this is very useful to achieve the goal.