Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[onedpl][ranges][productization] Range API productization, MVP plan, Part 1 #1457

Merged
merged 159 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 152 commits
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
ef89e35
[oneDPL] + oneapi::dpl::ranges::for_each, oneapi::dpl::ranges::transf…
MikeDvorskiy Feb 27, 2024
d476d68
[oneDPL][test] + common test engine to test range API algo
MikeDvorskiy Feb 15, 2024
bddc3b2
[oneDPL][ranges] + oneapi::dpl::ranges::iterator_t<_R>
MikeDvorskiy Feb 27, 2024
cc86b7b
[oneDPL][ranges][tests] + forward_view
MikeDvorskiy Mar 5, 2024
38b5323
[oneDPL][ranges][tests] + minor changes
MikeDvorskiy Mar 7, 2024
4a69c6f
[oneDPL][ranges] + for_each, transform => in one header/one struct de…
MikeDvorskiy Mar 5, 2024
659ddb1
[oneDPL][ranges] tag dispatching for std::ranges::for_each/one struct…
MikeDvorskiy Mar 5, 2024
797f636
[oneDPL][ranges] tag dispatching for std::ranges::for_each implementa…
MikeDvorskiy Mar 6, 2024
e8131aa
[oneDPL][ranges] + decltype(auto) for std::ranges::for_each API
MikeDvorskiy Mar 7, 2024
ccf22a5
[oneDPL][ranges] + tag dispatching for std::ranges::transform unary i…
MikeDvorskiy Mar 7, 2024
46cdcc0
[oneDPL][ranges] removed __internal::__get_result
MikeDvorskiy Mar 11, 2024
671fa06
[oneDPL][ranges] + oneapi::dpl::ranges::find, oneapi::dpl::ranges::fi…
MikeDvorskiy Feb 27, 2024
e8e6cc2
[oneDPL][ranges] + oneapi::dpl::ranges::find_if_not implementation
MikeDvorskiy Feb 23, 2024
d6bc866
[oneDPL][ranges] common test: + return values checks
MikeDvorskiy Feb 26, 2024
6251999
[oneDPL][ranges] + tag dispatch support for find, find_if, find_if_not
MikeDvorskiy Mar 14, 2024
5cadc6f
[oneDPL][ranges] + test for oneapi::dpl::ranges::find
MikeDvorskiy Mar 15, 2024
8c6b5c8
[oneDPL][ranges] + oneapi::dpl::ranges::all_of, any_of, none_of imple…
MikeDvorskiy Feb 27, 2024
3b37c92
[oneDPL][ranges] + tests for oneapi::dpl::ranges::all_of, any_of, non…
MikeDvorskiy Feb 26, 2024
87caf27
[oneDPL][ranges] + tag dispatch support for any_of, all_of, none_of
MikeDvorskiy Mar 15, 2024
60c7ed3
[oneDPL][ranges] + test for all_of, any_of, none_of
MikeDvorskiy Mar 15, 2024
d4decb6
[oneDPL][ranges][tests] + print tested algo name
MikeDvorskiy Mar 15, 2024
e43a339
[oneDPL][ranges] + tests for oneapi::dpl::ranges::all_of, any_of, non…
MikeDvorskiy Feb 26, 2024
bd61cd1
[oneDPL][ranges] + oneapi::dpl::ranges::adjacent_find implementation
MikeDvorskiy Feb 27, 2024
bcce84c
[oneDPL][ranges] + search, search_n implementation
MikeDvorskiy Feb 28, 2024
c29de85
[oneDPL][ranges] + tag dispatch support for adjacent_find, search, se…
MikeDvorskiy Mar 15, 2024
df8c554
[oneDPL][ranges][tests] + return type checks
MikeDvorskiy Mar 15, 2024
6ae3619
[oneDPL][traits] include/oneapi/dpl/pstl/iterator_defs.h - fix error …
MikeDvorskiy Mar 19, 2024
aba5463
[oneDPL][ranges] + fix error for ranges::for_each and ranges::adjacen…
MikeDvorskiy Mar 20, 2024
f5185e2
[oneDPL][ranges] + a test for ranges::adjacent_find; + range tests im…
MikeDvorskiy Mar 19, 2024
1f30614
[oneDPL][ranges] changes in return type: decltype(auto) => auto; anot…
MikeDvorskiy Mar 20, 2024
71722ca
[oneDPL][ranges] undo empty line
MikeDvorskiy Mar 20, 2024
2a2e3b1
[oneDPL][ranges] + fixes in ranges::search implementation; + test for…
MikeDvorskiy Mar 21, 2024
edefe5c
[oneDPL][ranges] + "rebasing" fix: + __ranges::
MikeDvorskiy Mar 21, 2024
cf7fa62
[oneDPL][ranges] revert unnecessary changes in iterator_defs.h
MikeDvorskiy Mar 21, 2024
5da6d7f
[oneDPL][ranges] + #if _ONEDPL___cplusplus >= 202002L
MikeDvorskiy Mar 21, 2024
b8059ac
[oneDPL][ranges] removed unused line
MikeDvorskiy Mar 21, 2024
6ba0549
[oneDPL][ranges] + minor fix
MikeDvorskiy Mar 21, 2024
32bf799
[oneDPL][ranges] + include <ranges>
MikeDvorskiy Mar 22, 2024
6d338b6
[oneDPL][ranges] + #if _ONEDPL___cplusplus >= 202002L
MikeDvorskiy Mar 22, 2024
c303204
[oneDPL][ranges] [CI] Add ranges with c++20 testing
dmitriy-sobolev Mar 25, 2024
58a4bf5
[oneDPL][ranges] + enabling _ENABLE_STD_RANGES_TESTING
MikeDvorskiy Mar 25, 2024
ec0b717
[oneDPL][ranges] + _ONEDPL_HETERO_BACKEND guards
MikeDvorskiy Mar 27, 2024
17477ab
[oneDPL][ranges] + fixes in ranges::search_n implementation; + a test…
MikeDvorskiy Mar 27, 2024
1eb9466
Revert "[oneDPL][ranges] [CI] Add ranges with c++20 testing"
MikeDvorskiy Apr 4, 2024
5978f83
Revert "Revert "[oneDPL][ranges] [CI] Add ranges with c++20 testing""
MikeDvorskiy Apr 4, 2024
50919bb
[oneDPL][ranges] + comment before #include <ranges>
MikeDvorskiy Apr 5, 2024
7097e91
[oneDPL][ranges] + type a default types in the signatures: std::range…
MikeDvorskiy Apr 12, 2024
e2f936c
[oneDPL][ranges] + introducing oneapi::dpl::ext::ranges (extension n…
MikeDvorskiy May 20, 2024
efbdad1
[oneDPL][ranges] + macro _ONEDPL_CPP20_RANGES_PRESENT
MikeDvorskiy May 22, 2024
0c70833
[oneDPL][ranges] + fix a minor error in a signature
MikeDvorskiy May 22, 2024
823342b
[oneDPL][ranges] changed _ONEDPL_CPP20_RANGES_PRESENT definition
MikeDvorskiy May 22, 2024
0f9f9df
[oneDPL][ranges] + fixes for oneapi::dpl::ext::ranges (extension nam…
MikeDvorskiy May 22, 2024
c91d20f
[oneDPL][ranges] changed a return type for ranges::for_each: for_each…
MikeDvorskiy Jun 3, 2024
770d895
Revert "[oneDPL][ranges] changed a return type for ranges::for_each: …
MikeDvorskiy Jun 3, 2024
9af69c8
//_ONEDPL___cplusplus => //_ONEDPL_CPP20_RANGES_PRESENT
MikeDvorskiy Jun 11, 2024
c051a62
//_ONEDPL_CPP20_RANGES_PRESENT => //_ONEDPL___cplusplus
MikeDvorskiy Jun 11, 2024
6d8a24e
[oneDPL][ranges] + std::invoke support
MikeDvorskiy Jun 17, 2024
a277752
[oneDPL][ranges] changed _ONEDPL_CPP20_RANGES_PRESENT definition
MikeDvorskiy Jul 4, 2024
e630771
[oneDPL][ranges] +std::forward for argument in the std::invoke calls
MikeDvorskiy Jul 3, 2024
42afbb2
[oneDPL][ranges] __pattern_adjacent_find2 => __pattern_adjacent_find_…
MikeDvorskiy Jul 3, 2024
cfad7c0
[oneDPL][ranges] begin() -> ranges::begin(), size() -> ranges::size
MikeDvorskiy Jul 3, 2024
26efbf6
[oneDPL][ranges] + std::invoke support, part2
MikeDvorskiy Jul 5, 2024
4997018
[oneDPL][ranges][test] + coverage for pointer-to-member and pointer-t…
MikeDvorskiy Jul 5, 2024
8b768f9
[oneDPL][ranges][test] + [oneDPL][ranges][test] + coverage for pointe…
MikeDvorskiy Jul 9, 2024
ecfb52e
[oneDPL][ranges] minor change: ::std -> std in the new code
MikeDvorskiy Jul 11, 2024
88c63db
[oneDPL][ranges] decltype(auto) -> auto where it is reasonable; + usi…
MikeDvorskiy Jul 11, 2024
1bc9b92
[oneDPL][ranges] + borrowed_iterator_t for parallel versions of range…
MikeDvorskiy Jul 11, 2024
0ad97bd
[oneDPL][ranges] + concepts and requires for ranges::for_each
MikeDvorskiy Jul 12, 2024
8b8a7bd
[oneDPL][ranges] + concepts and requires for the other range API from…
MikeDvorskiy Jul 15, 2024
5f12ef5
[oneDPL][ranges] removed std::projected_value_t due to is available w…
MikeDvorskiy Jul 15, 2024
8533e61
[oneDPL][ranges][test] removed "forward ranges" testing
MikeDvorskiy Jul 15, 2024
ca42e18
[oneDPL][ranges] + usage of oneapi::dpl::is_execution_policy_v trait
MikeDvorskiy Jul 16, 2024
1c6b292
[oneDPL][ranges] removed check type result for ranges::for_each, due …
MikeDvorskiy Jul 16, 2024
b6b5c9a
[oneDPL][ranges][test] test change
MikeDvorskiy Jul 16, 2024
fbcaade
[oneDPL][ranges][test] split one common test into several test files:…
MikeDvorskiy Jul 16, 2024
f89ced4
[oneDPL][ranges][test] a fix for the test flow script
MikeDvorskiy Jul 17, 2024
1df8e0e
[oneDPL][ranges] + minor fix for ranges::for_each
MikeDvorskiy Jul 17, 2024
4627e15
[oneDPL][ranges] + minor change in __pattern_search
MikeDvorskiy Jul 19, 2024
f018e17
[oneDPL][ranges][test] + passing &P2::proj as projection test case
MikeDvorskiy Jul 22, 2024
352a6e7
[oneDPL][ranges] + one space
MikeDvorskiy Jul 22, 2024
12d58b3
[oneDPL][ranges] + #if _ONEDPL_CPP20_RANGES_PRESENT
MikeDvorskiy Jul 22, 2024
9111539
[oneDPL][ranges] + unglification and other minor changes
MikeDvorskiy Jul 24, 2024
b7bf12b
[oneDPL][ranges] + ranges::transform, binary version
MikeDvorskiy Jul 24, 2024
90fcb6c
[oneDPL][ranges][test] + test case for ranges::transform, binary version
MikeDvorskiy Jul 24, 2024
a889589
[oneDPL][ranges] + __select_backend usage fixes
MikeDvorskiy Jul 24, 2024
a9837bd
[oneDPL][ranges] - constexpr, + min size of(Inange, OutPutRange)
MikeDvorskiy Jul 26, 2024
f635a11
[oneDPL][ranges][test] + usage of std subrange and span instead of on…
MikeDvorskiy Jul 29, 2024
95f1a49
[oneDPL][ranges] + usage of std::invoke for ranges::search
MikeDvorskiy Jul 29, 2024
18df896
[oneDPL] + a fix connected with __internal::__equal_value_by_pred usage
MikeDvorskiy Jul 29, 2024
693b050
[oneDPL] + another fix connected with forwarding reference type usage
MikeDvorskiy Jul 29, 2024
5aaa5d7
[oneDPL][ranges][test] + some fixes in the std range tests
MikeDvorskiy Jul 29, 2024
3eada8f
[oneDPL][ranges] oneapi::dpl::ext::ranges -> oneapi::dpl::ranges
MikeDvorskiy Jul 29, 2024
c322ca4
[oneDPL][ranges][test] removed overtesting
MikeDvorskiy Jul 29, 2024
3586a07
[oneDPL][ranges][test] + minor change
MikeDvorskiy Jul 29, 2024
3ec7357
[oneDPL][ranges][test] + fix a typo in filename
MikeDvorskiy Jul 29, 2024
5ddb41e
[oneDPL][ranges][test] + fix for USM_vector: std::ranges::subrange ap…
MikeDvorskiy Jul 30, 2024
e492fd9
[oneDPL][ranges][test] + minor change
MikeDvorskiy Jul 30, 2024
1cffe34
[oneDPL][ranges] + a fix: + std::indirectly_writable require for rang…
MikeDvorskiy Jul 31, 2024
4a5e877
[oneDPL][ranges] removed extra spaces
MikeDvorskiy Aug 1, 2024
6d2a49c
[oneDPL][ranges][test] + call_id for a device policy
MikeDvorskiy Aug 1, 2024
997d28d
[oneDPL][ranges] + a fix for _ONEDPL_CPP20_RANGES_PRESENT definition
MikeDvorskiy Aug 1, 2024
b48642f
[oneDPL][ranges] + standard "includes"
MikeDvorskiy Aug 1, 2024
3918ea5
[oneDPL][ranges][test] removed unused functor
MikeDvorskiy Aug 9, 2024
7797516
[oneDPL][ranges][test] + _ONEDPL_CPP20_SPAN_PRESENT usage
MikeDvorskiy Aug 9, 2024
bda3497
[oneDPL][ranges][test] + check return type: for_each, transform
MikeDvorskiy Aug 9, 2024
1ce4587
[oneDPL][ranges] + a specialization for enable_view to true because o…
MikeDvorskiy Aug 12, 2024
e30b60d
[oneDPL][ranges][test] + a fix for test type
MikeDvorskiy Aug 12, 2024
0814b37
[oneDPL][ranges][test] removed unused struct sycl_buffer
MikeDvorskiy Aug 12, 2024
c44bb21
[oneDPL][ranges][test] removed unused ForwardRange Checks
MikeDvorskiy Aug 12, 2024
5a4dc8b
Revert "[oneDPL][ranges][test] + a fix for test type"
MikeDvorskiy Aug 13, 2024
243dd87
[oneDPL][ranges][test] + #include <type_traits>
MikeDvorskiy Aug 13, 2024
cd8b4cd
[oneDPL][ranges] changes with #include <ranges>
MikeDvorskiy Aug 13, 2024
44cde9c
[oneDPL][ranges] + _ONEDPL_CPP20_SPAN_PRESENT usage
MikeDvorskiy Aug 13, 2024
e196507
[oneDPL][ranges][test] + std::vector a range for host policies test c…
MikeDvorskiy Aug 13, 2024
52deca7
[oneDPL][ranges] + formatting minor changes
MikeDvorskiy Aug 13, 2024
741c742
[oneDPL][ranges] removed unused code
MikeDvorskiy Aug 13, 2024
4e4d63c
[oneDPL][ranges][test] + minor changes
MikeDvorskiy Aug 13, 2024
f32108c
[oneDPL][ranges][test] + minor changes in ranges::transform checker
MikeDvorskiy Aug 13, 2024
5f3a57d
[oneDPL][ranges][test] removed unused code
MikeDvorskiy Aug 13, 2024
e67e396
[oneDPL][ranges][test] removed uglification
MikeDvorskiy Aug 14, 2024
49be4d3
[oneDPL][ranges][test] + compilation fix
MikeDvorskiy Aug 14, 2024
10ecade
[oneDPL][ranges][test] + minor fix for Windows c++ library support
MikeDvorskiy Aug 19, 2024
f046885
[oneDPL][ranges] ::std:: -> std::
MikeDvorskiy Aug 21, 2024
f0a1c82
[oneDPL][ranges][test] + different sizes for input/output ranges
MikeDvorskiy Aug 21, 2024
79e020a
[oneDPL][ranges] + unsized range support for ranges::transform
MikeDvorskiy Aug 23, 2024
235f7ee
[oneDPL][ranges][test] + usage of std::common_type_t for ranges::tran…
MikeDvorskiy Aug 23, 2024
3778000
[oneDPL][ranges][test] + sized/unsized iota test for ranges::transform
MikeDvorskiy Aug 23, 2024
1d9d621
[oneDPL][ranges] + a fix with size type, ranges::transform
MikeDvorskiy Aug 26, 2024
e98b09c
[oneDPL][ranges] + ONEDPL_HAS_RANGES_API
MikeDvorskiy Aug 27, 2024
781bf58
[oneDPL][ranges][test] + test with device policy and unsized ranges f…
MikeDvorskiy Aug 26, 2024
2abe881
[oneDPL][ranges][test] + TEST_CPP20_SPAN_PRESENT
MikeDvorskiy Aug 27, 2024
d46f77b
[oneDPL][ranges][test] + fix for file mask
MikeDvorskiy Aug 27, 2024
2d277b2
[oneDPL][ranges] + oneapi::dpl::__internal::__range_size_t
MikeDvorskiy Aug 27, 2024
0088d6e
[oneDPL][ranges][test] removed spaces
MikeDvorskiy Aug 27, 2024
79feb4a
[oneDPL][ranges][test] + compilation fix (immediate context uage)
MikeDvorskiy Aug 28, 2024
4edb8be
[oneDPL][ranges][test] + workaround for gcc bug (< gcc 14.1)
MikeDvorskiy Aug 28, 2024
93985aa
[oneDPL][ranges] + minor change in lambdas
MikeDvorskiy Aug 29, 2024
b15ab29
[oneDPL][ranges][test] + broken macro _PSTL_LAMBDA_PTR_TO_MEMBER_WIND…
MikeDvorskiy Aug 29, 2024
bd4c590
[oneDPL][ranges] + another minor changes
MikeDvorskiy Aug 30, 2024
261e267
[oneDPL][ranges] + another portion of minor fixes
MikeDvorskiy Aug 30, 2024
f1cc1cc
[oneDPL][ranges] + minor change
MikeDvorskiy Aug 30, 2024
aa53f11
[oneDPL][ranges][test] + unique kernel names
MikeDvorskiy Aug 30, 2024
b1e3f86
[oneDPL][ranges] + fix for # define _ONEDPL_CPP20_RANGES_PRESENT
MikeDvorskiy Aug 30, 2024
ea4f701
[oneDPL][ranges] + fix with includes
MikeDvorskiy Aug 30, 2024
1e09596
Simplify host patterns to dispatch just on tags
rarutyun Aug 30, 2024
6eba10c
[oneDPL][ranges][test] + minor change
MikeDvorskiy Aug 30, 2024
68ebace
[oneDPL][ranges] + removed forwarding ranges in some places where it …
MikeDvorskiy Aug 30, 2024
d396a9b
[oneDPL][ranges][test] + #include <oneapi/dpl/algorithm>
MikeDvorskiy Aug 30, 2024
be7a45f
Fix pattern_adjacent_find name
rarutyun Aug 30, 2024
8642c10
Revert unnecessary ::std changes
dmitriy-sobolev Aug 31, 2024
bb27637
Fix comment
dmitriy-sobolev Aug 31, 2024
fd83d4c
Add missing headers
dmitriy-sobolev Aug 31, 2024
07e9aaf
Add missing asserts in device backend
dmitriy-sobolev Sep 1, 2024
f6aaaa4
Use range_size_t utility in test, remove extra check
dmitriy-sobolev Sep 1, 2024
95ee76d
Remove decltype(auto)
dmitriy-sobolev Sep 1, 2024
30f7232
Remove remaining decltype(auto)
dmitriy-sobolev Sep 1, 2024
b56b014
Fix macros in test_config.h, do not use internal macros
dmitriy-sobolev Sep 1, 2024
c80fa28
Add a comment in test_config.h
dmitriy-sobolev Sep 1, 2024
119278b
Turn off ranges with clang15 and older
dmitriy-sobolev Sep 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,24 @@ jobs:
build_type: release
backend: serial
device_type: HOST
- os: ubuntu-latest
cxx_compiler: icpx
std: 20
build_type: release
backend: dpcpp
device_type: CPU
- os: ubuntu-latest
cxx_compiler: icpx
std: 20
build_type: release
backend: tbb
device_type: HOST
- os: ubuntu-latest
cxx_compiler: icpx
std: 20
build_type: release
backend: omp
device_type: HOST
steps:
- uses: actions/checkout@v4
- name: Set up Intel APT repository
Expand Down Expand Up @@ -209,8 +227,8 @@ jobs:
echo "::warning::Compiler: $(${{ matrix.cxx_compiler }} --version)"

if [[ "${{ matrix.backend }}" == "dpcpp" ]]; then
make_targets="build-onedpl-sycl_iterator-tests"
ctest_flags="-R sycl_iterator_.*\.pass"
make_targets="build-onedpl-sycl_iterator-tests build-onedpl-ranges-tests"
ctest_flags="-R (sycl_iterator_.*)|(std_ranges_.*)\.pass"
echo "::warning::dpcpp backend is set. Compile and run only sycl_iterator tests"
else
make_targets="build-onedpl-tests"
Expand Down
2 changes: 2 additions & 0 deletions include/oneapi/dpl/algorithm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#if !_ONEDPL_ALGORITHM_FORWARD_DECLARED
// If not declared, pull in forward declarations
# include "oneapi/dpl/pstl/glue_algorithm_defs.h"
# include "oneapi/dpl/pstl/glue_algorithm_ranges_defs.h"
# include "oneapi/dpl/internal/by_segment_extension_defs.h"
# include "oneapi/dpl/internal/binary_search_extension_defs.h"
# include "oneapi/dpl/pstl/histogram_extension_defs.h"
Expand All @@ -34,6 +35,7 @@
#if _ONEDPL_EXECUTION_POLICIES_DEFINED
// If <execution> has already been included, pull in implementations
# include "oneapi/dpl/pstl/glue_algorithm_impl.h"
# include "oneapi/dpl/pstl/glue_algorithm_ranges_impl.h"
# include "oneapi/dpl/pstl/histogram_impl.h"

# include "oneapi/dpl/internal/exclusive_scan_by_segment_impl.h"
Expand Down
1 change: 1 addition & 0 deletions include/oneapi/dpl/execution
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
// If the forward declarations have already been processed, pull the implementations
#if _ONEDPL_ALGORITHM_FORWARD_DECLARED
# include "oneapi/dpl/pstl/glue_algorithm_impl.h"
# include "oneapi/dpl/pstl/glue_algorithm_ranges_impl.h"
# include "oneapi/dpl/pstl/histogram_impl.h"

# include "oneapi/dpl/internal/exclusive_scan_by_segment_impl.h"
Expand Down
1 change: 0 additions & 1 deletion include/oneapi/dpl/internal/reduce_by_segment_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
#include "../pstl/utils_ranges.h"
#include "../pstl/hetero/dpcpp/utils_ranges_sycl.h"
#include "../pstl/ranges_defs.h"
#include "../pstl/glue_algorithm_ranges_defs.h"
#include "../pstl/glue_algorithm_ranges_impl.h"
#include "../pstl/hetero/dpcpp/sycl_traits.h" //SYCL traits specialization for some oneDPL types.
#include "scan_by_segment_impl.h"
Expand Down
14 changes: 8 additions & 6 deletions include/oneapi/dpl/pstl/algorithm_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,9 @@ __find_subrange(_RandomAccessIterator1 __first, _RandomAccessIterator1 __last, _
while (__first != __last && (__global_last - __first >= __n2))
{
// find position of *s_first in [first, last) (it can be start of subsequence)
__first = __internal::__brick_find_if(
__first, __last, __equal_value_by_pred<_ValueType, _BinaryPredicate&>(*__s_first, __pred), __is_vector);
auto __u_pred =
[__pred, __s_first](auto&& __val) mutable { return __pred(std::forward<decltype(__val)>(__val), *__s_first); };
__first = __internal::__brick_find_if(__first, __last, __u_pred, __is_vector);
dmitriy-sobolev marked this conversation as resolved.
Show resolved Hide resolved

// if position that was found previously is the start of subsequence
// then we can exit the loop (b_first == true) or keep the position
Expand Down Expand Up @@ -804,7 +805,8 @@ __find_subrange(_RandomAccessIterator __first, _RandomAccessIterator __last, _Ra
return __last;
}

auto __unary_pred = __equal_value_by_pred<_Tp, _BinaryPredicate&>(__value, __pred);
auto __unary_pred =
[__pred, &__value](auto&& __val) mutable { return __pred(std::forward<decltype(__val)>(__val), __value); };
danhoeflinger marked this conversation as resolved.
Show resolved Hide resolved
MikeDvorskiy marked this conversation as resolved.
Show resolved Hide resolved
while (__first != __last && (static_cast<_Size>(__global_last - __first) >= __count))
{
__first = __internal::__brick_find_if(__first, __last, __unary_pred, __is_vector);
Expand Down Expand Up @@ -1021,9 +1023,9 @@ __pattern_search_n(__parallel_tag<_IsVector> __tag, _ExecutionPolicy&& __exec, _
{
if (static_cast<_Size>(__last - __first) == __count)
{
const bool __result =
!__internal::__pattern_any_of(__tag, ::std::forward<_ExecutionPolicy>(__exec), __first, __last,
[&__value, &__pred](const _Tp& __val) { return !__pred(__val, __value); });
const bool __result = !__internal::__pattern_any_of(__tag, std::forward<_ExecutionPolicy>(__exec), __first,
__last, [&__value, __pred](auto&& __val) mutable { return !__pred(std::forward<decltype(__val)>(__val),
dmitriy-sobolev marked this conversation as resolved.
Show resolved Hide resolved
__value); });
danhoeflinger marked this conversation as resolved.
Show resolved Hide resolved
return __result ? __first : __last;
}
else
Expand Down
263 changes: 263 additions & 0 deletions include/oneapi/dpl/pstl/algorithm_ranges_impl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Copyright (C) Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// This file incorporates work covered by the following copyright and permission
// notice:
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
//
//===----------------------------------------------------------------------===//

#ifndef _ONEDPL_ALGORITHM_RANGES_IMPL_H
#define _ONEDPL_ALGORITHM_RANGES_IMPL_H

#if _ONEDPL_CPP20_RANGES_PRESENT

#include <ranges>
#include <utility>
#include <functional>
#include <type_traits>

#include "algorithm_fwd.h"
#include "execution_impl.h"

namespace oneapi
{
namespace dpl
{
namespace __internal
{
namespace __ranges
{

//---------------------------------------------------------------------------------------------------------------------
// pattern_for_each
//---------------------------------------------------------------------------------------------------------------------

template <typename _Tag, typename _ExecutionPolicy, typename _R, typename _Proj, typename _Fun>
void
__pattern_for_each(_Tag __tag, _ExecutionPolicy&& __exec, _R&& __r, _Fun __f, _Proj __proj)
{
static_assert(__is_parallel_tag_v<_Tag> || typename _Tag::__is_vector{});

auto __f_1 =
[__f, __proj](auto&& __val) { std::invoke(__f, std::invoke(__proj, std::forward<decltype(__val)>(__val)));};

oneapi::dpl::__internal::__pattern_walk1(__tag, std::forward<_ExecutionPolicy>(__exec), std::ranges::begin(__r),
std::ranges::begin(__r) + std::ranges::size(__r), __f_1);
}

template <typename _ExecutionPolicy, typename _R, typename _Proj, typename _Fun>
void
__pattern_for_each(__serial_tag</*IsVector*/std::false_type>, _ExecutionPolicy&& __exec, _R&& __r, _Fun __f, _Proj __proj)
{
std::ranges::for_each(std::forward<_R>(__r), __f, __proj);
}

//---------------------------------------------------------------------------------------------------------------------
// pattern_transform
//---------------------------------------------------------------------------------------------------------------------

template<typename _Tag, typename _ExecutionPolicy, typename _InRange, typename _OutRange, typename _F, typename _Proj>
void
__pattern_transform(_Tag __tag, _ExecutionPolicy&& __exec, _InRange&& __in_r, _OutRange&& __out_r, _F __op,
_Proj __proj)
{
static_assert(__is_parallel_tag_v<_Tag> || typename _Tag::__is_vector{});
assert(std::ranges::size(__in_r) <= std::ranges::size(__out_r));

auto __unary_op = [__op, __proj](auto&& __val) -> decltype(auto) {
return std::invoke(__op, std::invoke(__proj, std::forward<decltype(__val)>(__val)));};

oneapi::dpl::__internal::__pattern_walk2(__tag, std::forward<_ExecutionPolicy>(__exec), std::ranges::begin(__in_r),
std::ranges::begin(__in_r) + std::ranges::size(__in_r), std::ranges::begin(__out_r),
oneapi::dpl::__internal::__transform_functor<decltype(__unary_op)>{std::move(__unary_op)});
}

template<typename _ExecutionPolicy, typename _InRange, typename _OutRange, typename _F, typename _Proj>
void
__pattern_transform(__serial_tag</*IsVector*/std::false_type>, _ExecutionPolicy&& __exec, _InRange&& __in_r, _OutRange&& __out_r,
_F __op, _Proj __proj)
{
std::ranges::transform(std::forward<_InRange>(__in_r), std::ranges::begin(__out_r), __op, __proj);
}

//---------------------------------------------------------------------------------------------------------------------
// pattern_transform (binary vesrion)
//---------------------------------------------------------------------------------------------------------------------

template<typename _Tag, typename _ExecutionPolicy, typename _InRange1, typename _InRange2, typename _OutRange,
typename _F, typename _Proj1, typename _Proj2>
void
__pattern_transform(_Tag __tag, _ExecutionPolicy&& __exec, _InRange1&& __in_r1, _InRange2&& __in_r2,
_OutRange&& __out_r, _F __binary_op, _Proj1 __proj1,_Proj2 __proj2)
{
static_assert(__is_parallel_tag_v<_Tag> || typename _Tag::__is_vector{});

auto __f = [__binary_op, __proj1, __proj2](auto&& __val1, auto&& __val2) -> decltype(auto) {
return std::invoke(__binary_op, std::invoke(__proj1, std::forward<decltype(__val1)>(__val1)),
std::invoke(__proj2, std::forward<decltype(__val2)>(__val2)));};

oneapi::dpl::__internal::__pattern_walk3(__tag, std::forward<_ExecutionPolicy>(__exec), std::ranges::begin(__in_r1),
std::ranges::begin(__in_r1) + std::ranges::size(__in_r1), std::ranges::begin(__in_r2),
std::ranges::begin(__out_r), oneapi::dpl::__internal::__transform_functor<decltype(__f)>{std::move(__f)});
}

template<typename _ExecutionPolicy, typename _InRange1, typename _InRange2, typename _OutRange, typename _F,
typename _Proj1, typename _Proj2>
void
__pattern_transform(__serial_tag</*IsVector*/std::false_type>, _ExecutionPolicy&& __exec, _InRange1&& __in_r1, _InRange2&& __in_r2, _OutRange&& __out_r,
_F __binary_op, _Proj1 __proj1, _Proj2 __proj2)
{
std::ranges::transform(std::forward<_InRange1>(__in_r1), std::forward<_InRange2>(__in_r2),
std::ranges::begin(__out_r), __binary_op, __proj1, __proj2);
}

//---------------------------------------------------------------------------------------------------------------------
// pattern_find_if
//---------------------------------------------------------------------------------------------------------------------

template <typename _Tag, typename _ExecutionPolicy, typename _R, typename _Proj, typename _Pred>
auto
__pattern_find_if(_Tag __tag, _ExecutionPolicy&& __exec, _R&& __r, _Pred __pred, _Proj __proj)
{
static_assert(__is_parallel_tag_v<_Tag> || typename _Tag::__is_vector{});

auto __pred_1 = [__pred, __proj](auto&& __val) {
return std::invoke(__pred, std::invoke(__proj, std::forward<decltype(__val)>(__val)));};

return std::ranges::borrowed_iterator_t<_R>(oneapi::dpl::__internal::__pattern_find_if(__tag,
std::forward<_ExecutionPolicy>(__exec), std::ranges::begin(__r), std::ranges::begin(__r) +
std::ranges::size(__r), __pred_1));
}

template <typename _ExecutionPolicy, typename _R, typename _Proj, typename _Pred>
auto
__pattern_find_if(__serial_tag</*IsVector*/std::false_type>, _ExecutionPolicy&& __exec, _R&& __r, _Pred __pred, _Proj __proj)
{
return std::ranges::find_if(std::forward<_R>(__r), __pred, __proj);
}

//---------------------------------------------------------------------------------------------------------------------
// pattern_any_of
//---------------------------------------------------------------------------------------------------------------------

template <typename _Tag, typename _ExecutionPolicy, typename _R, typename _Proj, typename _Pred>
bool
__pattern_any_of(_Tag __tag, _ExecutionPolicy&& __exec, _R&& __r, _Pred __pred, _Proj __proj)
{
static_assert(__is_parallel_tag_v<_Tag> || typename _Tag::__is_vector{});

auto __pred_1 = [__pred, __proj](auto&& __val) {
return std::invoke(__pred, std::invoke(__proj, std::forward<decltype(__val)>(__val)));};
return oneapi::dpl::__internal::__pattern_any_of(__tag, std::forward<_ExecutionPolicy>(__exec),
std::ranges::begin(__r), std::ranges::begin(__r) + std::ranges::size(__r), __pred_1);
}

template <typename _ExecutionPolicy, typename _R, typename _Proj, typename _Pred>
bool
__pattern_any_of(__serial_tag</*IsVector*/std::false_type>, _ExecutionPolicy&& __exec, _R&& __r, _Pred __pred, _Proj __proj)
{
return std::ranges::any_of(std::forward<_R>(__r), __pred, __proj);
}

//---------------------------------------------------------------------------------------------------------------------
// pattern_adjacent_find
//---------------------------------------------------------------------------------------------------------------------

template <typename _Tag, typename _ExecutionPolicy, typename _R, typename _Proj, typename _Pred>
auto
__pattern_adjacent_find_ranges(_Tag __tag, _ExecutionPolicy&& __exec, _R&& __r, _Pred __pred,
_Proj __proj)
{
static_assert(__is_parallel_tag_v<_Tag> || typename _Tag::__is_vector{});

auto __pred_2 = [__pred, __proj](auto&& __val, auto&& __next) { return std::invoke(__pred, std::invoke(__proj,
std::forward<decltype(__val)>(__val)), std::invoke(__proj, std::forward<decltype(__next)>(__next)));};

auto __res = oneapi::dpl::__internal::__pattern_adjacent_find(__tag, std::forward<_ExecutionPolicy>(__exec),
std::ranges::begin(__r), std::ranges::begin(__r) + std::ranges::size(__r), __pred_2,
oneapi::dpl::__internal::__first_semantic());
return std::ranges::borrowed_iterator_t<_R>(__res);
}

template <typename _ExecutionPolicy, typename _R, typename _Proj, typename _Pred>
auto
__pattern_adjacent_find_ranges(__serial_tag</*IsVector*/std::false_type>, _ExecutionPolicy&& __exec, _R&& __r, _Pred __pred, _Proj __proj)
{
return std::ranges::adjacent_find(std::forward<_R>(__r), __pred, __proj);
}

//---------------------------------------------------------------------------------------------------------------------
// pattern_search
//---------------------------------------------------------------------------------------------------------------------

template<typename _Tag, typename _ExecutionPolicy, typename _R1, typename _R2, typename _Pred, typename _Proj1,
typename _Proj2>
auto
__pattern_search(_Tag __tag, _ExecutionPolicy&& __exec, _R1&& __r1, _R2&& __r2, _Pred __pred,
_Proj1 __proj1, _Proj2 __proj2)
{
static_assert(__is_parallel_tag_v<_Tag> || typename _Tag::__is_vector{});

auto __pred_2 = [__pred, __proj1, __proj2](auto&& __val1, auto&& __val2) { return std::invoke(__pred,
std::invoke(__proj1, std::forward<decltype(__val1)>(__val1)),
std::invoke(__proj2, std::forward<decltype(__val2)>(__val2)));};

auto __res = oneapi::dpl::__internal::__pattern_search(__tag, std::forward<_ExecutionPolicy>(__exec),
std::ranges::begin(__r1), std::ranges::begin(__r1) + std::ranges::size(__r1), std::ranges::begin(__r2),
std::ranges::begin(__r2) + std::ranges::size(__r2), __pred_2);

return std::ranges::borrowed_subrange_t<_R1>(__res, __res == std::ranges::end(__r1)
? __res : __res + std::ranges::size(__r2));
}

template<typename _ExecutionPolicy, typename _R1, typename _R2, typename _Pred, typename _Proj1,
typename _Proj2>
auto
__pattern_search(__serial_tag</*IsVector*/std::false_type>, _ExecutionPolicy&& __exec, _R1&& __r1, _R2&& __r2, _Pred __pred, _Proj1 __proj1, _Proj2 __proj2)
{
return std::ranges::search(std::forward<_R1>(__r1), std::forward<_R2>(__r2), __pred, __proj1, __proj2);
}

//---------------------------------------------------------------------------------------------------------------------
// pattern_search_n
//---------------------------------------------------------------------------------------------------------------------

template<typename _Tag, typename _ExecutionPolicy, typename _R, typename _T, typename _Pred, typename _Proj>
auto
__pattern_search_n(_Tag __tag, _ExecutionPolicy&& __exec, _R&& __r,
std::ranges::range_difference_t<_R> __count, const _T& __value, _Pred __pred, _Proj __proj)
{
static_assert(__is_parallel_tag_v<_Tag> || typename _Tag::__is_vector{});

auto __pred_2 = [__pred, __proj](auto&& __val1, auto&& __val2) { return std::invoke(__pred,
std::invoke(__proj, std::forward<decltype(__val1)>(__val1)), std::forward<decltype(__val2)>(__val2));};

auto __res = oneapi::dpl::__internal::__pattern_search_n(__tag, std::forward<_ExecutionPolicy>(__exec),
std::ranges::begin(__r), std::ranges::begin(__r) + std::ranges::size(__r), __count, __value, __pred_2);

return std::ranges::borrowed_subrange_t<_R>(__res, __res == std::ranges::end(__r) ? __res : __res + __count);
}

template<typename _ExecutionPolicy, typename _R, typename _T, typename _Pred, typename _Proj>
auto
__pattern_search_n(__serial_tag</*IsVector*/std::false_type>, _ExecutionPolicy&& __exec, _R&& __r, std::ranges::range_difference_t<_R> __count, const _T& __value,
_Pred __pred, _Proj __proj)
{
return std::ranges::search_n(std::forward<_R>(__r), __count, __value, __pred, __proj);
}

} // namespace __ranges
} // namespace __internal
} // namespace dpl
} // namespace oneapi

#endif //_ONEDPL_CPP20_RANGES_PRESENT

#endif // _ONEDPL_ALGORITHM_RANGES_IMPL_H
5 changes: 4 additions & 1 deletion include/oneapi/dpl/pstl/execution_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ inline constexpr bool is_execution_policy_v = oneapi::dpl::execution::is_executi
} // namespace v1
} // namespace execution

using oneapi::dpl::execution::is_execution_policy;
using oneapi::dpl::execution::is_execution_policy_v;
danhoeflinger marked this conversation as resolved.
Show resolved Hide resolved

namespace __internal
{

Expand Down Expand Up @@ -110,7 +113,7 @@ struct __is_host_execution_policy<oneapi::dpl::execution::unsequenced_policy> :

template <class _ExecPolicy, class _T = void>
using __enable_if_execution_policy =
::std::enable_if_t<oneapi::dpl::execution::is_execution_policy_v<::std::decay_t<_ExecPolicy>>, _T>;
std::enable_if_t<oneapi::dpl::is_execution_policy_v<std::decay_t<_ExecPolicy>>, _T>;

template <typename _ExecPolicy, typename _T>
struct __ref_or_copy_impl
Expand Down
Loading
Loading