Skip to content

Commit

Permalink
[oneDPL][ranges] + _ONEDPL_HETERO_BACKEND guards
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeDvorskiy committed Mar 27, 2024
1 parent eaa4cbb commit 82897bd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
13 changes: 9 additions & 4 deletions include/oneapi/dpl/pstl/glue_algorithm_ranges_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ struct none_of_fn
constexpr oneapi::dpl::__internal::__enable_if_execution_policy<_ExecutionPolicy, bool>
operator()(_ExecutionPolicy&& __exec, _R&& __r, _Pred __pred, _Proj __proj) const
{
return !oneapi::dpl::ranges::any_of(::std::forward<_ExecutionPolicy>(__exec),
oneapi::dpl::views::all_read(::std::forward<_R>(__r)), __pred, __proj);
return !oneapi::dpl::ranges::any_of(::std::forward<_ExecutionPolicy>(__exec), std::forward<_R>(__r),
__pred, __proj);
}
}; //none_of_fn

Expand Down Expand Up @@ -204,15 +204,17 @@ struct search_n_fn
operator()(_ExecutionPolicy&& __exec, _R&& __r, std::ranges::range_difference_t<_R> __count, const _T& __value,
_Pred __pred, _Proj __proj) const
{
const auto __dispatch_tag = oneapi::dpl::__internal::__select_backend(__exec, __r);
const auto __dispatch_tag = oneapi::dpl::__internal::__select_backend(__exec, __r.begin());
return oneapi::dpl::__internal::__ranges::__pattern_search_n(__dispatch_tag,
std::forward<_ExecutionPolicy>(__exec), std::forward<_R>(__r), __count, __value, __pred, __proj);
}
}; //search_n_fn

} //ranges
#endif

#endif //_ONEDPL___cplusplus >= 202002L

#if _ONEDPL_HETERO_BACKEND
namespace experimental
{
namespace ranges
Expand Down Expand Up @@ -928,6 +930,9 @@ reduce_by_segment(_ExecutionPolicy&& __exec, _Range1&& __keys, _Range2&& __value

} // namespace ranges
} // namespace experimental

#endif //_ONEDPL_HETERO_BACKEND

} // namespace dpl
} // namespace oneapi

Expand Down
3 changes: 2 additions & 1 deletion include/oneapi/dpl/pstl/glue_numeric_ranges_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#if _ONEDPL_HETERO_BACKEND
# include "hetero/numeric_ranges_impl_hetero.h"
#endif

namespace oneapi
{
Expand Down Expand Up @@ -204,4 +203,6 @@ transform_inclusive_scan(_ExecutionPolicy&& __exec, _Range1&& __rng1, _Range2&&
} // namespace dpl
} // namespace oneapi

#endif //_ONEDPL_HETERO_BACKEND

#endif // _ONEDPL_GLUE_NUMERIC_RANGES_IMPL_H
8 changes: 7 additions & 1 deletion include/oneapi/dpl/pstl/ranges_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "ranges/nanorange.hpp"
#include "ranges/nanorange_ext.h"

#include "utils_ranges.h"
#if _ONEDPL_BACKEND_SYCL
# include "hetero/dpcpp/utils_ranges_sycl.h"
#endif
Expand All @@ -28,20 +29,24 @@ namespace oneapi
namespace dpl
{

#if _ONEDPL_BACKEND_SYCL
namespace views
{
using oneapi::dpl::__ranges::views::all;
using oneapi::dpl::__ranges::views::all_read;
using oneapi::dpl::__ranges::views::all_write;
}
#endif // _ONEDPL_BACKEND_SYCL

namespace experimental
{
namespace ranges
{

//custom views
#if _ONEDPL_BACKEND_SYCL
using oneapi::dpl::__ranges::all_view;
#endif // _ONEDPL_BACKEND_SYCL
using oneapi::dpl::__ranges::guard_view;
using oneapi::dpl::__ranges::zip_view;

Expand All @@ -55,11 +60,12 @@ using __nanorange::nano::ranges::transform_view;
//adaptors
namespace views
{
#if _ONEDPL_BACKEND_SYCL
using oneapi::dpl::__ranges::views::all;
using oneapi::dpl::__ranges::views::all_read;
using oneapi::dpl::__ranges::views::all_write;

using oneapi::dpl::__ranges::views::host_all;
#endif // _ONEDPL_BACKEND_SYCL

using __nanorange::nano::views::drop;
using __nanorange::nano::views::fill;
Expand Down
10 changes: 10 additions & 0 deletions test/parallel_api/ranges/std_ranges_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@
namespace test_std_ranges
{;

#if _ONEDPL_HETERO_BACKEND
template<int call_id = 0>
auto dpcpp_policy()
{
auto exec = TestUtils::default_dpcpp_policy;
using Policy = decltype(exec);
return TestUtils::make_new_policy<TestUtils::new_kernel_name<Policy, call_id>>(TestUtils::default_dpcpp_policy);
}
#endif //_ONEDPL_HETERO_BACKEND

auto host_policies() { return std::true_type{};}

Expand Down Expand Up @@ -217,6 +219,7 @@ struct test
}
};

#if _ONEDPL_HETERO_BACKEND
struct sycl_buffer
{
using type = sycl::buffer<int>;
Expand All @@ -229,6 +232,7 @@ struct sycl_buffer
return buf;
}
};
#endif //#if _ONEDPL_HETERO_BACKEND

template<typename Type>
struct host_subrange_impl
Expand Down Expand Up @@ -265,6 +269,7 @@ struct host_vector
}
};

#if _ONEDPL_HETERO_BACKEND
struct usm_vector
{
using shared_allocator = sycl::usm_allocator<int, sycl::usm::alloc::shared>;
Expand Down Expand Up @@ -321,6 +326,8 @@ struct usm_subrange_impl
using usm_subrange = usm_subrange_impl<std::ranges::subrange<int*>>;
using usm_span = usm_subrange_impl<std::span<int>>;

#endif // _ONEDPL_HETERO_BACKEND

template<TestDataMode TestDataMode = data_in, bool RetTypeCheck = true>
struct test_range_algo
{
Expand All @@ -343,6 +350,7 @@ struct test_range_algo
test<host_subrange, TestDataMode, RetTypeCheck>{}(host_policies(), algo, checker, f, proj, std::views::all);
test<host_span, TestDataMode, RetTypeCheck>{}(host_policies(), algo, checker, f, proj, std::views::all);

#if _ONEDPL_HETERO_BACKEND
test<usm_vector, TestDataMode, RetTypeCheck>{}(dpcpp_policy(), algo, checker, f, proj);
test<usm_vector, TestDataMode, RetTypeCheck>{}(dpcpp_policy(), algo, checker, f, proj, oneapi::dpl::views::all);
test<usm_vector, TestDataMode, RetTypeCheck>{}(dpcpp_policy(), algo, checker, f, proj, subrange_view);
Expand All @@ -353,6 +361,8 @@ struct test_range_algo
#if 0 //sycl buffer
test<sycl_buffer, TestDataMode, RetTypeCheck>{}(dpcpp_policy(), algo, checker, f, std::identity{}, oneapi::dpl::views::all);
#endif

#endif //_ONEDPL_HETERO_BACKEND
}
};

Expand Down

0 comments on commit 82897bd

Please sign in to comment.