31 #ifndef _GLIBCXX_PARALLEL_EQUALLY_SPLIT_H
32 #define _GLIBCXX_PARALLEL_EQUALLY_SPLIT_H 1
46 template<
typename difference_type,
typename OutputIterator>
50 difference_type chunk_length = n / num_threads;
51 difference_type num_longer_chunks = n % num_threads;
52 difference_type pos = 0;
56 pos += (i < num_longer_chunks) ? (chunk_length + 1) : chunk_length;
71 template<
typename difference_type>
77 difference_type chunk_length = n / num_threads;
78 difference_type num_longer_chunks = n % num_threads;
79 if (thread_no < num_longer_chunks)
80 return thread_no * (chunk_length + 1);
82 return num_longer_chunks * (chunk_length + 1)
83 + (thread_no - num_longer_chunks) * chunk_length;
GNU parallel code for public use.
difference_type equally_split_point(difference_type n, thread_index_t num_threads, thread_index_t thread_no)
Function to split a sequence into parts of almost equal size.
uint16 thread_index_t
Unsigned integer to index a thread number. The maximum thread number (for each processor) must fit in...
OutputIterator equally_split(difference_type n, thread_index_t num_threads, OutputIterator s)
Function to split a sequence into parts of almost equal size.