Skip to content

Commit

Permalink
Revert "test/parallel_api/numeric/numeric.ops/scan_2.pass.cpp - remov…
Browse files Browse the repository at this point in the history
…e empty operator() implementations"

This reverts commit 09eff62.
  • Loading branch information
Sergey Kopienko authored and SergeyKopienko committed Apr 12, 2024
1 parent 64f32f8 commit 61fc29f
Showing 1 changed file with 47 additions and 32 deletions.
79 changes: 47 additions & 32 deletions test/parallel_api/numeric/numeric.ops/scan_2.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,29 +190,38 @@ DEFINE_TEST_1(test_scan_non_inplace, TestingAlgoritm)
EXPECT_EQ_N(expected.cbegin(), host_vals.get(), n, TestingAlgoritm().getMsg(false));
}

// specialization for host execution policies
template <typename Policy, typename Iterator1, typename Iterator2, typename Size>
void
::std::enable_if_t<
!oneapi::dpl::__internal::__is_hetero_execution_policy_v<::std::decay_t<Policy>> &&
is_base_of_iterator_category_v<::std::random_access_iterator_tag, Iterator1>>
operator()(Policy&& exec,
Iterator1 keys_first, Iterator1 keys_last,
Iterator2 vals_first, Iterator2 vals_last,
Size n)
{
if constexpr (!oneapi::dpl::__internal::__is_hetero_execution_policy_v<::std::decay_t<Policy>> &&
is_base_of_iterator_category_v<::std::random_access_iterator_tag, Iterator1>)
{
using ValT = typename ::std::iterator_traits<Iterator2>::value_type;
using ValT = typename ::std::iterator_traits<Iterator2>::value_type;

TestingAlgoritm testingAlgo;
TestingAlgoritm testingAlgo;

// Initialize source data in the buffer [keys_first, keys_last)
initialize_data(keys_first, n);
// Initialize source data in the buffer [keys_first, keys_last)
initialize_data(keys_first, n);

testingAlgo.call_onedpl(exec, keys_first, keys_last, vals_first);
testingAlgo.call_onedpl(exec, keys_first, keys_last, vals_first);

std::vector<ValT> expected(n);
testingAlgo.call_serial(keys_first, keys_last + n, expected.data());
EXPECT_EQ_N(expected.cbegin(), vals_first, n, TestingAlgoritm().getMsg(false));
}
std::vector<ValT> expected(n);
testingAlgo.call_serial(keys_first, keys_last + n, expected.data());
EXPECT_EQ_N(expected.cbegin(), vals_first, n, TestingAlgoritm().getMsg(false));
}

// specialization for non-random_access iterators
template <typename Policy, typename Iterator1, typename Iterator2, typename Size>
::std::enable_if_t<!is_base_of_iterator_category_v<::std::random_access_iterator_tag, Iterator1>>
operator()(Policy&& exec,
Iterator1 keys_first, Iterator1 keys_last,
Iterator2 vals_first, Iterator2 vals_last,
Size n)
{
}
};

Expand Down Expand Up @@ -243,36 +252,42 @@ DEFINE_TEST_1(test_scan_inplace, TestingAlgoritm)
EXPECT_EQ_N(expected.cbegin(), keys_first, n, testingAlgo.getMsg(true));
}

// specialization for hetero policy
template <typename Policy, typename Iterator1, typename Size>
void
::std::enable_if_t<
oneapi::dpl::__internal::__is_hetero_execution_policy_v<::std::decay_t<Policy>> &&
is_base_of_iterator_category_v<::std::random_access_iterator_tag, Iterator1>>
operator()(Policy&& exec, Iterator1 keys_first, Iterator1 keys_last,
Size n)
{
if constexpr (oneapi::dpl::__internal::__is_hetero_execution_policy_v<::std::decay_t<Policy>> &&
is_base_of_iterator_category_v<::std::random_access_iterator_tag, Iterator1>)
{
using KeyT = typename ::std::iterator_traits<Iterator1>::value_type;
using KeyT = typename ::std::iterator_traits<Iterator1>::value_type;

TestingAlgoritm testingAlgo;
TestingAlgoritm testingAlgo;

TestDataTransfer<UDTKind::eKeys, Size> host_keys(*this, n);

TestDataTransfer<UDTKind::eKeys, Size> host_keys(*this, n);
// Initialize source data in the buffer [keys_first, keys_last)
initialize_data(host_keys.get(), n);
const std::vector<KeyT> source_host_keys_state(host_keys.get(), host_keys.get() + n);

// Initialize source data in the buffer [keys_first, keys_last)
initialize_data(host_keys.get(), n);
const std::vector<KeyT> source_host_keys_state(host_keys.get(), host_keys.get() + n);
// Copy data from the buffer [keys_first, keys_last) to a device.
update_data(host_keys);

// Copy data from the buffer [keys_first, keys_last) to a device.
update_data(host_keys);
// Now we are ready to call tested algorithm
testingAlgo.call_onedpl(make_new_policy<new_kernel_name<Policy, 0>>(exec), keys_first, keys_last, keys_first);

// Now we are ready to call tested algorithm
testingAlgo.call_onedpl(make_new_policy<new_kernel_name<Policy, 0>>(exec), keys_first, keys_last, keys_first);
retrieve_data(host_keys);

retrieve_data(host_keys);
std::vector<KeyT> expected(n);
testingAlgo.call_serial(source_host_keys_state.cbegin(), source_host_keys_state.cend(), expected.data());
EXPECT_EQ_N(expected.cbegin(), host_keys.get(), n, testingAlgo.getMsg(true));
}

std::vector<KeyT> expected(n);
testingAlgo.call_serial(source_host_keys_state.cbegin(), source_host_keys_state.cend(), expected.data());
EXPECT_EQ_N(expected.cbegin(), host_keys.get(), n, testingAlgo.getMsg(true));
}
// specialization for non-random_access iterators
template <typename Policy, typename Iterator1, typename Size>
::std::enable_if_t<!is_base_of_iterator_category_v<::std::random_access_iterator_tag, Iterator1>>
operator()(Policy&& exec, Iterator1 keys_first, Iterator1 keys_last, Size n)
{
}
};

Expand Down

0 comments on commit 61fc29f

Please sign in to comment.