Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, inplace modification of the object passed to a filter is allowed, and frequently useful when dealing with objects that are expensive to copy. I've done this when parallelizing Bzip2 with parallel_pipeline. As far as TBB is concerned, the pointer "input" in your example is just a value that TBB makes no attempt to interpret. </p> <p>There's a further trick that I sometimes use to save allocation/freeing in the first/last filters. If the first and last filters are serial filters, and the first filter produces objects of the same type that the last filter consumes, then a circular queue of objects can be used to recycle objects. The buffer needs to be of size max_number_of_live_tokens (first parameter to parallel_pipeline). The first filter can allocate an object by dequeuing; the last stage can free an object by enqueuing it. Start with a queue of max_number_of_live_tokens. The token limit guarantees that the queue will never underflow or overflow. </p> <p>The neat part is that the circular queue can be implemented using trivial serial code. An array and two pointers for the tail/head suffice. No atomic operations, locking, or memory fences are required. The guarantee of no underflow/overflow implies that the enqueue operation can be implemented by just bumping the tail pointer (and blissfully ignoring the head pointer). And vice-versa for the deque operation. No locking is required since the callers are serial filters. At worse, both the tail and head pointers are bumped concurrently, but independently. TBB will take care of the memory fencing.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload