Skip to content

Commit

Permalink
Move difference_t utility to utils_ranges header (#1887)
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitriy Sobolev <[email protected]>
  • Loading branch information
dmitriy-sobolev authored Oct 8, 2024
1 parent 2be9d5f commit 2fc85a6
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 18 deletions.
16 changes: 0 additions & 16 deletions include/oneapi/dpl/pstl/execution_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,6 @@ struct __ref_or_copy_impl
template <typename _ExecPolicy, typename _T>
using __ref_or_copy = typename __ref_or_copy_impl<::std::decay_t<_ExecPolicy>, _T>::type;

// utilities for Range API
template <typename _R>
auto
__check_size(int) -> decltype(::std::declval<_R&>().size());

template <typename _R>
auto
__check_size(long) -> decltype(::std::declval<_R&>().get_count());

template <typename _It>
auto
__check_size(...) -> typename ::std::iterator_traits<_It>::difference_type;

template <typename _R>
using __difference_t = ::std::make_signed_t<decltype(__check_size<_R>(0))>;

//------------------------------------------------------------------------
// backend tags
//------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions include/oneapi/dpl/pstl/glue_algorithm_ranges_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "../functional"
#include "execution_defs.h"
#include "utils_ranges.h"

namespace oneapi
{
Expand Down
4 changes: 3 additions & 1 deletion include/oneapi/dpl/pstl/glue_algorithm_ranges_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
# include <functional>
# include <type_traits>
# include <iterator>
# include <algorithm> //to use std::ranges::sort, std::ranges::stable_sort
# include <algorithm> // std::ranges::sort, std::ranges::stable_sort
#endif

#include "utils_ranges.h" // __difference_t

#include "execution_defs.h"
#include "oneapi/dpl/pstl/ranges_defs.h"

Expand Down
1 change: 1 addition & 0 deletions include/oneapi/dpl/pstl/glue_numeric_ranges_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define _ONEDPL_GLUE_NUMERIC_RANGES_DEFS_H

#include "execution_defs.h"
#include "utils_ranges.h"

namespace oneapi
{
Expand Down
1 change: 1 addition & 0 deletions include/oneapi/dpl/pstl/glue_numeric_ranges_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define _ONEDPL_GLUE_NUMERIC_RANGES_IMPL_H

#include "execution_defs.h"
#include "utils_ranges.h"
#include "glue_numeric_defs.h"

#if _ONEDPL_HETERO_BACKEND
Expand Down
1 change: 1 addition & 0 deletions include/oneapi/dpl/pstl/hetero/algorithm_impl_hetero.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "../algorithm_fwd.h"

#include "../parallel_backend.h"
#include "../utils_ranges.h"
#include "utils_hetero.h"

#if _ONEDPL_BACKEND_SYCL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "../algorithm_fwd.h"
#include "../parallel_backend.h"
#include "../utils_ranges.h"
#include "utils_hetero.h"

#if _ONEDPL_BACKEND_SYCL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "sycl_defs.h" // __dpl_sycl::__local_accessor, __dpl_sycl::__group_barrier
#include "../../utils.h" // __dpl_bit_floor, __dpl_bit_ceil
#include "../../utils_ranges.h" // __difference_t
#include "parallel_backend_sycl_merge.h" // __find_start_point, __serial_merge

namespace oneapi
Expand Down
2 changes: 2 additions & 0 deletions include/oneapi/dpl/pstl/hetero/numeric_ranges_impl_hetero.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
# include "dpcpp/unseq_backend_sycl.h"
#endif

#include "../utils_ranges.h"

namespace oneapi
{
namespace dpl
Expand Down
16 changes: 15 additions & 1 deletion include/oneapi/dpl/pstl/utils_ranges.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "iterator_defs.h"
#include "iterator_impl.h"
#include "execution_defs.h" // __internal::__difference_t

namespace oneapi
{
Expand Down Expand Up @@ -92,6 +91,21 @@ using __range_size_t = typename __range_size<_R>::type;

#endif //_ONEDPL_CPP20_RANGES_PRESENT

template <typename _R>
auto
__check_size(int) -> decltype(std::declval<_R&>().size());

template <typename _R>
auto
__check_size(long) -> decltype(std::declval<_R&>().get_count());

template <typename _It>
auto
__check_size(...) -> typename std::iterator_traits<_It>::difference_type;

template <typename _R>
using __difference_t = std::make_signed_t<decltype(__check_size<_R>(0))>;

} //namespace __internal

namespace __ranges
Expand Down

0 comments on commit 2fc85a6

Please sign in to comment.