Skip to content

Commit

Permalink
Reached scan_partition bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dcbdan committed Mar 2, 2015
1 parent aba9224 commit 67f1a06
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
4 changes: 4 additions & 0 deletions hpx/parallel/algorithm.hpp
@@ -1,5 +1,6 @@
// Copyright (c) 2007-2015 Hartmut Kaiser
// Copyright (c) 2014 Grant Mercer
// Copyright (c) 2015 Daniel Bourgeois
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -17,16 +18,19 @@
#include <hpx/parallel/algorithms/copy.hpp>
#include <hpx/parallel/algorithms/count.hpp>
#include <hpx/parallel/algorithms/equal.hpp>
#include <hpx/parallel/algorithms/exclusive_scan.hpp>
#include <hpx/parallel/algorithms/fill.hpp>

This comment has been minimized.

Copy link
@hkaiser

hkaiser Mar 3, 2015

Member

This header file does not belong here. N4310 requires it to be included from parallel/numeric.hpp (see https://github.com/STEllAR-GROUP/hpx/blob/master/hpx/parallel/numeric.hpp#L15).

#include <hpx/parallel/algorithms/find.hpp>
#include <hpx/parallel/algorithms/for_each.hpp>
#include <hpx/parallel/algorithms/generate.hpp>
#include <hpx/parallel/algorithms/inclusive_scan.hpp>
#include <hpx/parallel/algorithms/is_partitioned.hpp>

This comment has been minimized.

Copy link
@hkaiser

hkaiser Mar 3, 2015

Member

Same as above, inclusive_scan has to be included from parallel/numeric.hpp

#include <hpx/parallel/algorithms/is_sorted.hpp>
#include <hpx/parallel/algorithms/lexicographical_compare.hpp>
#include <hpx/parallel/algorithms/minmax.hpp>
#include <hpx/parallel/algorithms/mismatch.hpp>
#include <hpx/parallel/algorithms/move.hpp>
#include <hpx/parallel/algorithms/partition.hpp>
#include <hpx/parallel/algorithms/reduce.hpp>
#include <hpx/parallel/algorithms/remove_copy.hpp>
#include <hpx/parallel/algorithms/replace.hpp>
Expand Down
9 changes: 4 additions & 5 deletions hpx/parallel/algorithms/unique.hpp
Expand Up @@ -60,22 +60,21 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1)
std::size_t count = std::distance(first, last);
if (count < 1)
return result::get(std::move(dest));
*dest = *first;
FwdIter prev = first;
*dest = *first++;

typedef hpx::util::zip_iterator<FwdIter, FwdIter, char*>
zip_iterator1;
typedef hpx::util::zip_iterator<FwdIter, char*> zip_iterator2;
boost::shared_array<char> flags(new char[count-1]);
std::size_t init = 1;
FwdIter lead = first;
FwdIter prev = lead++;

using hpx::util::get;
using hpx::util::make_zip_iterator;
return util::scan_partitioner<ExPolicy, Iter,
std::size_t>::call(
policy,
make_zip_iterator(prev, lead, flags.get()),
make_zip_iterator(prev, first, flags.get()),
count - 1,
init,
// Flag the duplicates
Expand Down Expand Up @@ -106,7 +105,7 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1)
return util::partitioner<ExPolicy, Iter, void>::
call_with_data(
policy,
hpx::util::make_zip_iterator(++first, flags.get()),
hpx::util::make_zip_iterator(first, flags.get()),
count - 1,
[dest](hpx::shared_future<std::size_t>&& pos,
zip_iterator2 part_begin,std::size_t part_count)
Expand Down
32 changes: 28 additions & 4 deletions tests/unit/parallel/unique_copy.cpp
Expand Up @@ -6,18 +6,42 @@
#include <hpx/hpx_init.hpp>
#include <hpx/hpx.hpp>
#include <hpx/include/parallel_unique.hpp>
#include <hpx/include/parallel_partition.hpp>
#include <hpx/include/parallel_copy.hpp>
#include <hpx/include/parallel_scan.hpp>
#include <hpx/util/lightweight_test.hpp>

#include "test_utils.hpp"

int hpx_main(boost::program_options::variables_map& vm)
{
using namespace hpx::parallel;
std::vector<int> a{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3};

//HPX_ASSERT(workitems.size() == 2) from scan_partitioner
std::vector<int> a{1,1};
std::vector<int> b(a.size());
hpx::future<std::vector<int>::iterator>
f = unique_copy(par(task), a.begin(), a.end(), b.begin());
f.get();
exclusive_scan(par(task), a.begin(), a.end(), b.begin(), 100);
//

/*
// for(int i = 0; i < 5000; ++i){ a.push_back(i); a.push_back(i); }
// auto f2 = copy_if(par(task), a.begin(), a.end(), b.begin(), [](int qwe){ return true; });
// auto f1 = unique_copy(par(task), a.begin(), a.end(), b.begin());
// if (f1.get() == b.begin() && f2.get() == b.begin()) std::cout << "GOOD TO GO!\n";
// if (f2.get() == b.begin()) std::cout << "copy_if is good!\n";
// if (f1.get() == b.begin()) std::cout << "unique_copy good at zero length!\n";
std::vector<int> a;
for(int i = 0; i < 5000; ++i){ a.push_back(i); }
std::vector<int> a_true(a.size()), a_false(a.size());
auto f = partition(par(task), a.begin(), a.end(),
a_true.begin(), a_false.begin(),
[](int asd){ return asd % 2 == 0; });
f.wait();
for(int z : a_true) std::cout << z << " "; std::cout << std::endl;
for(int z : a_false) std::cout << z << " "; std::cout << std::endl;
*/
for(int z : b) std::cout << z << " "; std::cout << std::endl;
return hpx::finalize();
}
Expand Down

0 comments on commit 67f1a06

Please sign in to comment.