Commit 58a6ef4b by Benjamin Kosnik Committed by Benjamin Kosnik

partial_sum.h: Include new.

2007-12-15  Benjamin Kosnik  <bkoz@redhat.com>
	    Paolo Carlini  <pcarlini@suse.de>
	
	* include/parallel/partial_sum.h: Include new. Fix for DR 402.	
	* include/parallel/multiway_merge.h:Fix for DR 402.
	* include/parallel/losertree.h: Same.
	* include/parallel/quicksort.h: Same.
	* include/parallel/random_shuffle.h: Same.
	* include/parallel/multiway_mergesort.h: Same.


Co-Authored-By: Paolo Carlini <pcarlini@suse.de>

From-SVN: r130956
parent ffe3dcd9
2007-12-15 Benjamin Kosnik <bkoz@redhat.com>
Paolo Carlini <pcarlini@suse.de>
* include/parallel/partial_sum.h: Include new. Fix for DR 402.
* include/parallel/multiway_merge.h:Fix for DR 402.
* include/parallel/losertree.h: Same.
* include/parallel/quicksort.h: Same.
* include/parallel/random_shuffle.h: Same.
* include/parallel/multiway_mergesort.h: Same.
2007-12-14 Benjamin Kosnik <bkoz@redhat.com> 2007-12-14 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/30127 PR libstdc++/30127
......
...@@ -265,11 +265,11 @@ template<typename T, typename Comparator = std::less<T> > ...@@ -265,11 +265,11 @@ template<typename T, typename Comparator = std::less<T> >
{ {
// Construct all keys, so we can easily deconstruct them. // Construct all keys, so we can easily deconstruct them.
for (unsigned int i = 0; i < (2 * k); ++i) for (unsigned int i = 0; i < (2 * k); ++i)
new(&(losers[i].key)) T(key); ::new(&(losers[i].key)) T(key);
first_insert = false; first_insert = false;
} }
else else
new(&(losers[pos].key)) T(key); ::new(&(losers[pos].key)) T(key);
losers[pos].sup = sup; losers[pos].sup = sup;
losers[pos].source = source; losers[pos].source = source;
......
...@@ -800,7 +800,7 @@ template< ...@@ -800,7 +800,7 @@ template<
{ {
if (seqs_begin[pi].first != seqs_begin[pi].second) if (seqs_begin[pi].first != seqs_begin[pi].second)
{ {
new(&(fe[nrs])) value_type(*(seqs_begin[pi].first)); ::new(&(fe[nrs])) value_type(*(seqs_begin[pi].first));
source[nrs] = pi; source[nrs] = pi;
++nrs; ++nrs;
total_length += _GLIBCXX_PARALLEL_LENGTH(seqs_begin[pi]); total_length += _GLIBCXX_PARALLEL_LENGTH(seqs_begin[pi]);
...@@ -1582,7 +1582,7 @@ template< ...@@ -1582,7 +1582,7 @@ template<
_GLIBCXX_PARALLEL_LENGTH(seqs_begin[s]) * (double(i + 1) / _GLIBCXX_PARALLEL_LENGTH(seqs_begin[s]) * (double(i + 1) /
(num_samples + 1)) * (double(length) (num_samples + 1)) * (double(length)
/ total_length)); / total_length));
new(&(samples[s * num_samples + i])) value_type( ::new(&(samples[s * num_samples + i])) value_type(
seqs_begin[s].first[sample_index]); seqs_begin[s].first[sample_index]);
} }
......
...@@ -139,7 +139,7 @@ template<typename RandomAccessIterator, typename _DifferenceTp> ...@@ -139,7 +139,7 @@ template<typename RandomAccessIterator, typename _DifferenceTp>
num_samples + 1, es); num_samples + 1, es);
for (difference_type i = 0; i < num_samples; i++) for (difference_type i = 0; i < num_samples; i++)
new(&(sd->samples[iam * num_samples + i])) value_type( ::new(&(sd->samples[iam * num_samples + i])) value_type(
sd->source[sd->starts[iam] + es[i + 1]]); sd->source[sd->starts[iam] + es[i + 1]]);
delete[] es; delete[] es;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#define _GLIBCXX_PARALLEL_PARTIAL_SUM_H 1 #define _GLIBCXX_PARALLEL_PARTIAL_SUM_H 1
#include <omp.h> #include <omp.h>
#include <new>
#include <bits/stl_algobase.h> #include <bits/stl_algobase.h>
#include <parallel/parallel.h> #include <parallel/parallel.h>
#include <parallel/numericfwd.h> #include <parallel/numericfwd.h>
...@@ -155,11 +156,11 @@ template< ...@@ -155,11 +156,11 @@ template<
*result = *begin; *result = *begin;
parallel_partial_sum_basecase(begin + 1, begin + borders[1], parallel_partial_sum_basecase(begin + 1, begin + borders[1],
result + 1, bin_op, *begin); result + 1, bin_op, *begin);
new(&(sums[iam])) value_type(*(result + borders[1] - 1)); ::new(&(sums[iam])) value_type(*(result + borders[1] - 1));
} }
else else
{ {
new(&(sums[iam])) value_type( ::new(&(sums[iam])) value_type(
std::accumulate(begin + borders[iam] + 1, std::accumulate(begin + borders[iam] + 1,
begin + borders[iam + 1], begin + borders[iam + 1],
*(begin + borders[iam]), *(begin + borders[iam]),
......
...@@ -80,7 +80,7 @@ namespace __gnu_parallel ...@@ -80,7 +80,7 @@ namespace __gnu_parallel
{ {
const unsigned long long index = static_cast<unsigned long long>(s) const unsigned long long index = static_cast<unsigned long long>(s)
* n / num_samples; * n / num_samples;
new(&(samples[s])) value_type(begin[index]); ::new(&(samples[s])) value_type(begin[index]);
} }
__gnu_sequential::sort(samples, samples + num_samples, comp); __gnu_sequential::sort(samples, samples + num_samples, comp);
......
...@@ -213,7 +213,7 @@ template<typename RandomAccessIterator, typename RandomNumberGenerator> ...@@ -213,7 +213,7 @@ template<typename RandomAccessIterator, typename RandomNumberGenerator>
thread_index_t target_p = bin_proc[target_bin]; thread_index_t target_p = bin_proc[target_bin];
// Last column [d->num_threads] stays unchanged. // Last column [d->num_threads] stays unchanged.
new(&(temporaries[target_p][dist[target_bin + 1]++])) value_type( ::new(&(temporaries[target_p][dist[target_bin + 1]++])) value_type(
*(source + i + start)); *(source + i + start));
} }
...@@ -478,7 +478,7 @@ template<typename RandomAccessIterator, typename RandomNumberGenerator> ...@@ -478,7 +478,7 @@ template<typename RandomAccessIterator, typename RandomNumberGenerator>
// Distribute according to oracles. // Distribute according to oracles.
for (difference_type i = 0; i < n; ++i) for (difference_type i = 0; i < n; ++i)
new(&(target[(dist0[oracles[i]])++])) value_type(*(begin + i)); ::new(&(target[(dist0[oracles[i]])++])) value_type(*(begin + i));
for (int b = 0; b < num_bins; ++b) for (int b = 0; b < num_bins; ++b)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment