instead of using the vector's `operator[]` (which internally creates a new `command_queue` to use just for the operation), it would be better just to say `fill_n(counts.begin() - end, 1, 0, queue)` (or something similar with `copy()`). This is more efficient and removes the need for the `queue.finish()` call below.

just fyi, I'm thinking about deprecating the `operator[]` in favor of explicitly copying values (via `copy()` or `fill()` or `vector<T>::assign()`) which doesn't have to create it's own queue internally and removes race conditions between operations performed on different command queues (which would eliminate the need to call `queue.finish()` after each operation to be safe).