[PATCH][libstdc++-v3 parallel mode] Get rid of hard-coded ints [was: Re: ints in parallel code]
Johannes Singler
singler@kit.edu
Mon Nov 9 13:20:00 GMT 2009
Paolo Carlini wrote:
> Hi,
>> All the ints in multiway*.h address sequences, i. e. the functions are
>> limited to about 2^31 sequences. The number of elements in these
>> sequences can be much higher.
>>
>> In principle, you are right, the sequences are passed using iterators,
>> and their difference could be 64 bits. In practice, we are much further
>> away from having more than 2^31 sequences, than having more than 2^31
>> elements e. g. for sorting.
>>
> Ok... Then, please help me summarizing the issue: if the user has a
> "data set" of 2^34 alements, will it be automatically "split", ie,
> processed, in chunks each < 2^31 elements?
No, for sorting, we will have p sequences, for p the number of threads
used. That should be safe for an int anyway (omp_get_num_threads also
returns an int restrictions).
In general, the number of sequences is determined by the caller.
>> Anyway, do you want me to replace it with the appropriate
>> difference_type? It might have performance implications, though.
>>
> In general, if you want my opinion, these days unless you have *very
> clear* benchmarking numbers in front of you, it's always a very good
> idea to use the correct types, to begin with: if the difference can need
> 64 bits to be represented, use a 64-bit type.
The attached patch should get rid of most hard-coded occurrences of int.
Tested x86_64-unknown-linux-gnu: No regressions
Please approve for mainline.
2009-11-09 Johannes Singler <singler@kit.edu>
* include/parallel/multiway_merge.h (multiway_merge_*,
__sequential_multiway_merge, parallel_multiway_merge):
Replace int by appropriate difference_type (typedef to
_SeqNumber) or _ThreadIndex.
* include/parallel/multiseq_selection.h (multiseq_partition,
multiseq_selection): Replace int by appropriate difference_type
(typedef to _SeqNumber)
* include/parallel/base.h (__get_max_threads): Replace int by
_ThreadIndex.
* include/parallel/balanced_quicksort.h
(__qsb_local_sort_with_helping, __parallel_sort_qsb): Likewise.
* include/parallel/set_operations.h (__parallel_set_operation):
Likewise.
* include/parallel/unique_copy.h (__parallel_unique_copy):
Likewise.
* include/parallel/multiway_mergesort.h (_SplitConsistently,
parallel_sort_mwms_pu, parallel_sort_mwms): Likewise.
* include/parallel/partial_sum.h
(__parallel_partial_sum_linear): Likewise.
* include/parallel/partition.h (__parallel_partition): Replace
int by appropriate difference_type or _ThreadIndex.
Johannes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: get_rid_of_int.patch
Type: text/x-patch
Size: 27823 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20091109/6f4826f8/attachment.bin>
More information about the Libstdc++
mailing list