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

Add C++23 fold algorithms #6224

Open
hkaiser opened this issue Apr 13, 2023 · 8 comments · May be fixed by #6255
Open

Add C++23 fold algorithms #6224

hkaiser opened this issue Apr 13, 2023 · 8 comments · May be fixed by #6255

Comments

@hkaiser
Copy link
Member

hkaiser commented Apr 13, 2023

C++23 added the following fold algorithms:

These algorithms are specified as enforcing sequential execution. We should discuss whether those should be added to HPX anyways.

See also: http://eel.is/c++draft/alg.fold

@gonidelis
Copy link
Contributor

Note 1: Only ranges overloads were proposed.
Note 2: What's the argument against integrating them with HPX? If we do, again, we are closer to standards conformance + we could end up with a proof of concept for their parallel versions?
Note 3: Is sequential enforcement just because they are under ranges or is it unique to the nature of the fold algorithms? Isn't fold a more generic std::reduce/std::accumulate after all (same problems regarding parallelization should be expected)?

@Johan511 Johan511 linked a pull request May 23, 2023 that will close this issue
2 tasks
@Johan511
Copy link
Contributor

ranges::fold_left_first and ranges::fold_right_first return std::optional type (C++17)
ranges::fold_left_with_iter and ranges::fold_left_first_with_iter return std::in_value_result (C++23)

so should we enable fold algorithms only if HPX compiled with C++23 std?

@hkaiser
Copy link
Member Author

hkaiser commented May 25, 2023

ranges::fold_left_first and ranges::fold_right_first return std::optional type (C++17) ranges::fold_left_with_iter and ranges::fold_left_first_with_iter return std::in_value_result (C++23)

so should we enable fold algorithms only if HPX compiled with C++23 std?

No, we should have those algorithms such that people can use them with C++17, if needed.

@Johan511
Copy link
Contributor

Johan511 commented May 25, 2023

We would have to deviate from the standard.
We could alternately work on hpx::in_value_result that does seem better.

@hkaiser
Copy link
Member Author

hkaiser commented May 25, 2023

We would have to deviate from the standard. We could alternately work on hpx::in_value_result that does seem better.

Yes, that would have to be added as well. I thin pre-c++23 these should be in namespace hpx::experimental, starting C++23 they should be in namespace hpx.

@Johan511
Copy link
Contributor

sure, do we have a hpx::optional? if so do you suggest returning it instead of std::optional? If not, do we plan on implementing it?

@hkaiser
Copy link
Member Author

hkaiser commented May 25, 2023

sure, do we have a hpx::optional? if so do you suggest returning it instead of std::optional? If not, do we plan on implementing it?

Yes, please use hpx::optional, it will fall back to std::optional, if available (see: https://github.com/STEllAR-GROUP/hpx/blob/master/libs/core/datastructures/include/hpx/datastructures/optional.hpp).

@vivekd01
Copy link

vivekd01 commented Jul 1, 2023

Update the CMakeLists.txt file of your project to set the appropriate C++ standard and compiler flags. Add the following lines to enable C++23 features:
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants