1 #ifndef DASH__ALGORITHM__EQUAL_H__ 2 #define DASH__ALGORITHM__EQUAL_H__ 4 #include <dash/algorithm/LocalRange.h> 5 #include <dash/algorithm/Operation.h> 7 #include <dash/iterator/GlobIter.h> 11 template<
typename Ptr>
12 inline char equal_loc_impl(
13 const Ptr & l_first_1,
15 const Ptr & l_first_2){
16 return static_cast<char>(
std::equal(l_first_1, l_last_1, l_first_2));
18 template<
typename Ptr,
typename BinaryPredicate>
19 inline char equal_loc_impl(
20 const Ptr & l_first_1,
22 const Ptr & l_first_2,
23 BinaryPredicate pred){
24 return static_cast<char>(
std::equal(l_first_1, l_last_1, l_first_2, pred));
27 template<
typename GlobIter>
28 char equal_overlapping_impl(
29 const GlobIter & first_1,
30 const GlobIter & last_1,
31 const GlobIter & first_2){
33 auto dist = loc_idx_r.end - loc_idx_r.begin;
34 auto git_beg_idx = first_1.pattern().global(loc_idx_r.begin);
35 auto offset = git_beg_idx - first_1.gpos();
36 auto glfirst_1 = first_1+offset;
40 return std::equal(glfirst_1, glfirst_1+dist, first_2+offset);
50 template <
typename GlobIter>
60 "invalid iterator: Need to be a global iterator");
62 auto& team = first_1.team();
63 auto myid = team.myid();
66 auto l_first_1 = index_range_in.begin;
67 auto l_last_1 = index_range_in.end;
70 auto common_dist = std::min(
71 std::distance(index_range_out.begin, index_range_out.end), dist);
75 if (common_dist == dist) {
76 l_result = ::dash::internal::equal_loc_impl(
77 l_first_1, l_last_1, first_2.
local());
78 }
else if(common_dist > 0) {
79 l_result = ::dash::internal::equal_overlapping_impl(
80 first_1, last_1, first_2);
99 template <
typename GlobIter,
class BinaryPredicate>
110 "invalid iterator: Need to be a global iterator");
112 auto & team = first_1.team();
113 auto myid = team.myid();
116 auto l_first_1 = index_range_in.begin;
117 auto l_last_1 = index_range_in.end;
120 auto common_dist = std::min(
std::distance(index_range_out.begin, index_range_out.end),dist);
124 if(
std::distance(index_range_out.begin, index_range_out.end) == dist){
125 l_result = ::dash::internal::equal_loc_impl(l_first_1, l_last_1, first_2.
local());
126 }
else if(common_dist > 0) {
127 l_result = ::dash::internal::equal_overlapping_impl(
128 first_1, last_1, first_2);
142 #endif // DASH__ALGORITHM__EQUAL_H__ global_unit_t myid()
Shortcut to query the global unit ID of the calling unit.
This class is a simple memory pool which holds allocates elements of size ValueType.
RandomAccessIt::difference_type distance(const RandomAccessIt &first, const RandomAccessIt &last)
Resolve the number of elements between two iterators.
bool equal(GlobIter first_1, GlobIter last_1, GlobIter first_2, BinaryPredicate)
Returns true if the range [first1, last1) is equal to the range [first2, first2 + (last1 - first1)) w...
LocalRange< const typename GlobIterType::value_type > local_range(const GlobIterType &first, const GlobIterType &last)
Resolves the local address range between global iterators.
DASH_CONSTEXPR local_type local() const
Convert global iterator to native pointer.
dart_ret_t dart_allreduce(const void *sendbuf, void *recvbuf, size_t nelem, dart_datatype_t dtype, dart_operation_t op, dart_team_t team)
DART Equivalent to MPI allreduce.
Iterator on Partitioned Global Address Space.
#define DART_TYPE_BYTE
integral data types
bool equal(GlobIter first_1, GlobIter last_1, GlobIter first_2)
Returns true if the range [first1, last1) is equal to the range [first2, first2 + (last1 - first1))...
std::enable_if< !GlobInputIter::has_view::value, LocalIndexRange< typename GlobInputIter::pattern_type::index_type >>::type local_index_range(const GlobInputIter &first, const GlobInputIter &last)
Resolves the local index range between global iterators.