From 8a5a863d5e4ba6293ed28008f187a7913022c03c Mon Sep 17 00:00:00 2001 From: MikeDvorskiy Date: Fri, 28 Mar 2025 11:38:49 +0100 Subject: [PATCH 1/7] [oneDPL][rfc] tuple like concept RFC draft --- rfcs/proposed/tuple_concept/readme.md | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 rfcs/proposed/tuple_concept/readme.md diff --git a/rfcs/proposed/tuple_concept/readme.md b/rfcs/proposed/tuple_concept/readme.md new file mode 100644 index 00000000000..4f275f43ac9 --- /dev/null +++ b/rfcs/proposed/tuple_concept/readme.md @@ -0,0 +1,33 @@ +# tuple like concept for the oneDPL C++20 + +## Introduction +A tuple like type in C++ is a powerful utility that enables developers to combine two or more types into a single one - a tuple. +There are very usefull other types based on a tuple like type. For example, zip iterator or zip view types. +C++ standard library indroduces `std::tuple` type and `std::ranges::zip_view` is based on `std::tuple`. + +## Motivation +In spite of `std::tuple` is present in C++ standard library, there are unresolvable issues in usage of zip iterator or zip view types +(based on `std::tuple`) with parallel algorithms and oneDPL parallel algorithms in particular. +- Derefernced zip_view iterator is not value-swappable in C++20 (https://en.cppreference.com/w/cpp/named_req/ValueSwappable) +So, it is not able to be used with the non-range algorithms +- Usage of `std::tuple` as `value_type` for zip_view iterator leads to the issues, at least, with `sortable`, `permutable` + and `indirectly_writable` concepts: const_cast&&>(*o) = std::forward(t) is not compiled till C++23. (https://godbolt.org/z/zT9qqnjWq) +- There is an issue with `std::ranges::sort(zip_view)` with clang 19.0 and older. (https://godbolt.org/z/jKvG9rY5M) +- There is an issue with `std::ranges::stable_sort(zip_view)` with gcc library +- Passing `std::zip_view::iterator` intances to the iterator-based algorithms works only for gcc 14.1 and newer, clang 19.1 and newer or + starting 17.01 with libc++ lib (https://godbolt.org/z/To6Mjr9M6) +- Any wrapper over `std::tuple` is not device copyable. (https://godbolt.org/z/brfvcMeM6). A device copyability of the `std::tuple` is not transitive property. + +oneDPL has internal tuple like type without the issues mentioned above. +But, we would not specify that internal type in oneDPL specification. Rather we would have a tuple like concept for oneDPL. + + +### Key Requirements +TODO + + +### Implementation proposal (C++20) +TODO + +### Test coverage +TODO From a642eb1cfc3199e3cac51bb43c3187e9c555c961 Mon Sep 17 00:00:00 2001 From: MikeDvorskiy Date: Fri, 28 Mar 2025 14:12:41 +0100 Subject: [PATCH 2/7] [oneDPL][rfc] tuple like concept RFC, +Key Requirements --- rfcs/proposed/tuple_concept/readme.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rfcs/proposed/tuple_concept/readme.md b/rfcs/proposed/tuple_concept/readme.md index 4f275f43ac9..4ae247fc36e 100644 --- a/rfcs/proposed/tuple_concept/readme.md +++ b/rfcs/proposed/tuple_concept/readme.md @@ -23,7 +23,9 @@ But, we would not specify that internal type in oneDPL specification. Rather we ### Key Requirements -TODO +- oneDPL tuple type should be explcitly convertable to `std::tuple` +- Elements of tuple-like types can be accessed using structured bindings. +- The type can be used with `onedpl::get`, `onedpl::tuple_element` and `onedpl::tuple_size`. ### Implementation proposal (C++20) From 0acef34324f070d47400e30e8bcbe7b2c44f3dd7 Mon Sep 17 00:00:00 2001 From: MikeDvorskiy Date: Fri, 28 Mar 2025 14:27:12 +0100 Subject: [PATCH 3/7] [oneDPL][rfc] tuple like concept RFC, spell error fixing --- rfcs/proposed/tuple_concept/readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rfcs/proposed/tuple_concept/readme.md b/rfcs/proposed/tuple_concept/readme.md index 4ae247fc36e..dba2f00a6d6 100644 --- a/rfcs/proposed/tuple_concept/readme.md +++ b/rfcs/proposed/tuple_concept/readme.md @@ -2,19 +2,19 @@ ## Introduction A tuple like type in C++ is a powerful utility that enables developers to combine two or more types into a single one - a tuple. -There are very usefull other types based on a tuple like type. For example, zip iterator or zip view types. +There are very useful other types based on a tuple like type. For example, zip iterator or zip view types. C++ standard library indroduces `std::tuple` type and `std::ranges::zip_view` is based on `std::tuple`. ## Motivation In spite of `std::tuple` is present in C++ standard library, there are unresolvable issues in usage of zip iterator or zip view types (based on `std::tuple`) with parallel algorithms and oneDPL parallel algorithms in particular. -- Derefernced zip_view iterator is not value-swappable in C++20 (https://en.cppreference.com/w/cpp/named_req/ValueSwappable) +- Dereferenced zip_view iterator is not value-swappable in C++20 (https://en.cppreference.com/w/cpp/named_req/ValueSwappable) So, it is not able to be used with the non-range algorithms - Usage of `std::tuple` as `value_type` for zip_view iterator leads to the issues, at least, with `sortable`, `permutable` and `indirectly_writable` concepts: const_cast&&>(*o) = std::forward(t) is not compiled till C++23. (https://godbolt.org/z/zT9qqnjWq) - There is an issue with `std::ranges::sort(zip_view)` with clang 19.0 and older. (https://godbolt.org/z/jKvG9rY5M) - There is an issue with `std::ranges::stable_sort(zip_view)` with gcc library -- Passing `std::zip_view::iterator` intances to the iterator-based algorithms works only for gcc 14.1 and newer, clang 19.1 and newer or +- Passing `std::zip_view::iterator` instances to the iterator-based algorithms works only for gcc 14.1 and newer, clang 19.1 and newer or starting 17.01 with libc++ lib (https://godbolt.org/z/To6Mjr9M6) - Any wrapper over `std::tuple` is not device copyable. (https://godbolt.org/z/brfvcMeM6). A device copyability of the `std::tuple` is not transitive property. @@ -23,7 +23,7 @@ But, we would not specify that internal type in oneDPL specification. Rather we ### Key Requirements -- oneDPL tuple type should be explcitly convertable to `std::tuple` +- oneDPL tuple type should be explicitly convertible to `std::tuple` - Elements of tuple-like types can be accessed using structured bindings. - The type can be used with `onedpl::get`, `onedpl::tuple_element` and `onedpl::tuple_size`. From afb78247e0889eac3ac21b7a2f9a62bae35e76c3 Mon Sep 17 00:00:00 2001 From: MikeDvorskiy Date: Mon, 19 May 2025 12:37:48 +0200 Subject: [PATCH 4/7] Update readme.md --- rfcs/proposed/tuple_concept/readme.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rfcs/proposed/tuple_concept/readme.md b/rfcs/proposed/tuple_concept/readme.md index dba2f00a6d6..55af7b8f49a 100644 --- a/rfcs/proposed/tuple_concept/readme.md +++ b/rfcs/proposed/tuple_concept/readme.md @@ -21,15 +21,14 @@ So, it is not able to be used with the non-range algorithms oneDPL has internal tuple like type without the issues mentioned above. But, we would not specify that internal type in oneDPL specification. Rather we would have a tuple like concept for oneDPL. - ### Key Requirements - oneDPL tuple type should be explicitly convertible to `std::tuple` - Elements of tuple-like types can be accessed using structured bindings. - The type can be used with `onedpl::get`, `onedpl::tuple_element` and `onedpl::tuple_size`. - ### Implementation proposal (C++20) -TODO +- For C++20 oneDPL introduces a C++ concept, for exampple, `oneapi::dpl::tuple`. A proper name may be discussed. +- This C++ concept is defined via a list of C++ requirements, corresponding to the `Key Requirements` list above. ### Test coverage -TODO +- The test cases should cover each require from the `Key Requirements` list. From c14f7b98e8108b4ec486a542a211bb8f9aaad769 Mon Sep 17 00:00:00 2001 From: MikeDvorskiy Date: Mon, 19 May 2025 12:38:59 +0200 Subject: [PATCH 5/7] Update readme.md --- rfcs/proposed/tuple_concept/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rfcs/proposed/tuple_concept/readme.md b/rfcs/proposed/tuple_concept/readme.md index 55af7b8f49a..2c62015f11e 100644 --- a/rfcs/proposed/tuple_concept/readme.md +++ b/rfcs/proposed/tuple_concept/readme.md @@ -27,7 +27,7 @@ But, we would not specify that internal type in oneDPL specification. Rather we - The type can be used with `onedpl::get`, `onedpl::tuple_element` and `onedpl::tuple_size`. ### Implementation proposal (C++20) -- For C++20 oneDPL introduces a C++ concept, for exampple, `oneapi::dpl::tuple`. A proper name may be discussed. +- For C++20 oneDPL introduces a C++ concept, for example, `oneapi::dpl::tuple`. A proper name may be discussed. - This C++ concept is defined via a list of C++ requirements, corresponding to the `Key Requirements` list above. ### Test coverage From 23888678ca616f1ed13c12710deab572bcfb26ba Mon Sep 17 00:00:00 2001 From: MikeDvorskiy Date: Mon, 19 May 2025 12:47:46 +0200 Subject: [PATCH 6/7] Update readme.md --- rfcs/proposed/tuple_concept/readme.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/rfcs/proposed/tuple_concept/readme.md b/rfcs/proposed/tuple_concept/readme.md index 2c62015f11e..1eb23984772 100644 --- a/rfcs/proposed/tuple_concept/readme.md +++ b/rfcs/proposed/tuple_concept/readme.md @@ -1,7 +1,7 @@ # tuple like concept for the oneDPL C++20 ## Introduction -A tuple like type in C++ is a powerful utility that enables developers to combine two or more types into a single one - a tuple. +A tuple like type in C++ is a powerful utility that enables developers to combine two or more types into a single one - a tuple. There are very useful other types based on a tuple like type. For example, zip iterator or zip view types. C++ standard library indroduces `std::tuple` type and `std::ranges::zip_view` is based on `std::tuple`. @@ -19,11 +19,13 @@ So, it is not able to be used with the non-range algorithms - Any wrapper over `std::tuple` is not device copyable. (https://godbolt.org/z/brfvcMeM6). A device copyability of the `std::tuple` is not transitive property. oneDPL has internal tuple like type without the issues mentioned above. -But, we would not specify that internal type in oneDPL specification. Rather we would have a tuple like concept for oneDPL. +But, we would not specify that internal type in oneDPL specification. Rather we would have a `tuple like concept` for oneDPL. ### Key Requirements -- oneDPL tuple type should be explicitly convertible to `std::tuple` -- Elements of tuple-like types can be accessed using structured bindings. +A tuple type, which is satisfying a `tuple like concept`, should be: +- Explicitly convertible to `std::tuple`. +- A SYCL device copyable type. +- Elements of such typel type can be accessed using structured bindings. - The type can be used with `onedpl::get`, `onedpl::tuple_element` and `onedpl::tuple_size`. ### Implementation proposal (C++20) @@ -31,4 +33,4 @@ But, we would not specify that internal type in oneDPL specification. Rather we - This C++ concept is defined via a list of C++ requirements, corresponding to the `Key Requirements` list above. ### Test coverage -- The test cases should cover each require from the `Key Requirements` list. +- The test cases should cover as the whole concept and as each require from the `Key Requirements` list for `oneapi::dpl::__internal::tuple` type. From 849067dd348fc7095d98d7bbf07c93e7f23fae4e Mon Sep 17 00:00:00 2001 From: MikeDvorskiy Date: Mon, 19 May 2025 13:00:36 +0200 Subject: [PATCH 7/7] Update readme.md --- rfcs/proposed/tuple_concept/readme.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rfcs/proposed/tuple_concept/readme.md b/rfcs/proposed/tuple_concept/readme.md index 1eb23984772..72342e8c153 100644 --- a/rfcs/proposed/tuple_concept/readme.md +++ b/rfcs/proposed/tuple_concept/readme.md @@ -26,8 +26,11 @@ A tuple type, which is satisfying a `tuple like concept`, should be: - Explicitly convertible to `std::tuple`. - A SYCL device copyable type. - Elements of such typel type can be accessed using structured bindings. -- The type can be used with `onedpl::get`, `onedpl::tuple_element` and `onedpl::tuple_size`. - +- The type can be used with `std::get`, `std::tuple_element` and `std::tuple_size`, `std::apply`. +- The type is lexicographically comparable the values in the tuple. Other words, the following operators should be defined for the type: + `operator==`, `operator!=`, `operator<`, `operator<=`, `operator>`, `operator>=`, `operator<=>`. +- The standard typrs `std::common_type` and `std::basic_common_reference` should be specified for the type. + ### Implementation proposal (C++20) - For C++20 oneDPL introduces a C++ concept, for example, `oneapi::dpl::tuple`. A proper name may be discussed. - This C++ concept is defined via a list of C++ requirements, corresponding to the `Key Requirements` list above.