In the TBB book it shows that concurrent_vector has a function named range(size_t grainsize).
I want to iterate over a concurrent_vector, applying an operation to each element. However, I would prefer to use the auto partitioner. Currently, I am passing this for range type in a parallel_for:
Is there a better way, that uses the auto partitioner?
You should be able to use the blocked_range as youcreated above together with auto_partitioner.
You could also use the method range(size_t grainsize)of concurrent_vector with auto_partitioner; just specify grainsize of 1 for it. This method will do for you what you did manually, i.e. construct a blocked_range over iteration space [ v.begin(), v(end) ) with a given grainsize. The value of 1 is the default grainsize value for blocked_range; we should have made it the default value in the concurrent_vector's range method as well.
Both ways are essentially the same.