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

[P2300] Added fundamental coroutine_traits for S/R #5945

Merged
merged 15 commits into from
Jul 25, 2022

Conversation

SAtacker
Copy link
Contributor

@SAtacker SAtacker commented Jul 7, 2022

Signed-off-by: Shreyas Atre shreyasatre16@gmail.com

Proposed Changes

  • Awaiter traits
  • Awaitable traits
  • get_awaiter

Checklist

  • Awaiter traits tests
  • awaitable traits tests
  • get waiter tests

@SAtacker SAtacker force-pushed the p2300_enhancements branch from c414088 to 4d5056b Compare July 7, 2022 20:18
@hkaiser hkaiser added type: enhancement type: compatibility issue category: senders/receivers Implementations of the p0443r14 / p2300 + p1897 proposals labels Jul 8, 2022
@hkaiser hkaiser added this to the 1.9.0 milestone Jul 8, 2022
Copy link
Member

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! Thanks!

@SAtacker SAtacker force-pushed the p2300_enhancements branch 6 times, most recently from 58219b7 to a644c9b Compare July 10, 2022 10:41
@SAtacker SAtacker marked this pull request as ready for review July 16, 2022 19:43
SAtacker added 5 commits July 17, 2022 01:14
Signed-off-by: Shreyas Atre <shreyasatre16@gmail.com>
- Change `class` to `typename` for consistency
- use `_v` for variable postfix
- `inline constexpr` where ever possible
- `inline constexpr bool` maintains consistency
- using `HPX_FORWARD` which uses `static_cast`
- `void` is the default type for `std::enable_if_t`

Signed-off-by: Shreyas Atre <shreyasatre16@gmail.com>
- The awaitable concept simply checks whether the type supports
  applying the co_await operator to avalue of that type.
- If the object has either a member or non-member operator co_await()
  then its return value must satisfy the Awaiter concept. Otherwise,
  the Awaitable object must satisfy the Awaiter concept itself.

Signed-off-by: Shreyas Atre <shreyasatre16@gmail.com>
Signed-off-by: Shreyas Atre <shreyasatre16@gmail.com>
- Await transform concept was accepting universal value arguments

Signed-off-by: Shreyas Atre <shreyasatre16@gmail.com>
@SAtacker SAtacker force-pushed the p2300_enhancements branch from c903892 to 8849834 Compare July 16, 2022 19:44
Signed-off-by: Shreyas Atre <shreyasatre16@gmail.com>
Signed-off-by: Shreyas Atre <shreyasatre16@gmail.com>
@SAtacker SAtacker force-pushed the p2300_enhancements branch 2 times, most recently from e4db1fb to 8413017 Compare July 19, 2022 16:48
- `hpx::coro` is now defined under certain conditions
- `__has_include` is found and either of the coroutine std headers are
  found

Signed-off-by: Shreyas Atre <shreyasatre16@gmail.com>
@SAtacker SAtacker force-pushed the p2300_enhancements branch from 8413017 to 8e63d93 Compare July 19, 2022 17:12
@hkaiser
Copy link
Member

hkaiser commented Jul 19, 2022

@SAtacker I think you need to wrap the new configuration header in an #if defined(...) to circumvent the build errors. There is also some inspect errors that needs fixing.

@SAtacker
Copy link
Contributor Author

@SAtacker I think you need to wrap the new configuration header in an #if defined(...) to circumvent the build errors. There is also some inspect errors that needs fixing.

8e63d93#diff-c87c94ab3db419c43094f1852b046cd3200ae0bfb7a66a482f51be42bf76803bR36-R38
and 8e63d93#diff-73bb5d75ca22afdf27a16580a7a5a51d476e49c6b4357c8e591fb1485397b094R38-R40 should have taken care of it, I had thought so

@SAtacker
Copy link
Contributor Author

@hkaiser
Copy link
Member

hkaiser commented Jul 20, 2022

https://github.com/STEllAR-GROUP/hpx/runs/7414352657?check_suite_focus=true#step:6:230 the coroutine test itself is failing

What I meant is that you either have to avoid #including the new coroutine_traits.hpp if coroutines support is not detected or wrap the content of the header in a corresponding #ifdef/#endif.

@hkaiser
Copy link
Member

hkaiser commented Jul 20, 2022

https://github.com/STEllAR-GROUP/hpx/runs/7414352657?check_suite_focus=true#step:6:230 the coroutine test itself is failing

What I meant is that you either have to avoid #including the new coroutine_traits.hpp if coroutines support is not detected or wrap the content of the header in a corresponding #ifdef/#endif.

The second option seems to be better, however.

@SAtacker
Copy link
Contributor Author

https://github.com/STEllAR-GROUP/hpx/runs/7414352657?check_suite_focus=true#step:6:230 the coroutine test itself is failing

What I meant is that you either have to avoid #including the new coroutine_traits.hpp if coroutines support is not detected or wrap the content of the header in a corresponding #ifdef/#endif.

The second option seems to be better, however.

Did you mean https://github.com/STEllAR-GROUP/hpx/pull/5945/files#diff-73bb5d75ca22afdf27a16580a7a5a51d476e49c6b4357c8e591fb1485397b094R38-R40 ?

@hkaiser
Copy link
Member

hkaiser commented Jul 20, 2022

https://github.com/STEllAR-GROUP/hpx/runs/7414352657?check_suite_focus=true#step:6:230 the coroutine test itself is failing

What I meant is that you either have to avoid #including the new coroutine_traits.hpp if coroutines support is not detected or wrap the content of the header in a corresponding #ifdef/#endif.

The second option seems to be better, however.

Did you mean https://github.com/STEllAR-GROUP/hpx/pull/5945/files#diff-73bb5d75ca22afdf27a16580a7a5a51d476e49c6b4357c8e591fb1485397b094R38-R40 ?

I meant adding a wrapper here: libs/core/config/include/hpx/config/coroutines_support.hpp

@SAtacker
Copy link
Contributor Author

https://github.com/STEllAR-GROUP/hpx/runs/7414352657?check_suite_focus=true#step:6:230 the coroutine test itself is failing

What I meant is that you either have to avoid #including the new coroutine_traits.hpp if coroutines support is not detected or wrap the content of the header in a corresponding #ifdef/#endif.

The second option seems to be better, however.

Did you mean https://github.com/STEllAR-GROUP/hpx/pull/5945/files#diff-73bb5d75ca22afdf27a16580a7a5a51d476e49c6b4357c8e591fb1485397b094R38-R40 ?

I meant adding a wrapper here: libs/core/config/include/hpx/config/coroutines_support.hpp

Then hpx::coro is not found by it.

diff --git a/libs/core/config/include/hpx/config/coroutines_support.hpp b/libs/core/config/include/hpx/config/coroutines_support.hpp
index fb7be8d728..08b1adb20a 100644
--- a/libs/core/config/include/hpx/config/coroutines_support.hpp
+++ b/libs/core/config/include/hpx/config/coroutines_support.hpp
@@ -6,6 +6,8 @@
 
 #pragma once
 
+#if defined(HPX_HAVE_CXX20_COROUTINES)
+
 #if defined(__has_include)
 #if __has_include(<coroutine>)
 #include <coroutine>
@@ -25,3 +27,5 @@ namespace hpx { namespace coro {
 #define HPX_COROUTINE_NAMESPACE_STD std::experimental
 #endif
 #endif
+
+#endif // HPX_HAVE_CXX20_COROUTINES
\ No newline at end of file

@SAtacker
Copy link
Contributor Author

I know it is supposed to work, but building systems always make it harder to believe.

@hkaiser
Copy link
Member

hkaiser commented Jul 20, 2022

https://github.com/STEllAR-GROUP/hpx/runs/7414352657?check_suite_focus=true#step:6:230 the coroutine test itself is failing

What I meant is that you either have to avoid #including the new coroutine_traits.hpp if coroutines support is not detected or wrap the content of the header in a corresponding #ifdef/#endif.

The second option seems to be better, however.

Did you mean https://github.com/STEllAR-GROUP/hpx/pull/5945/files#diff-73bb5d75ca22afdf27a16580a7a5a51d476e49c6b4357c8e591fb1485397b094R38-R40 ?

I meant adding a wrapper here: libs/core/config/include/hpx/config/coroutines_support.hpp

Then hpx::coro is not found by it.

diff --git a/libs/core/config/include/hpx/config/coroutines_support.hpp b/libs/core/config/include/hpx/config/coroutines_support.hpp
index fb7be8d728..08b1adb20a 100644
--- a/libs/core/config/include/hpx/config/coroutines_support.hpp
+++ b/libs/core/config/include/hpx/config/coroutines_support.hpp
@@ -6,6 +6,8 @@
 
 #pragma once
 
+#if defined(HPX_HAVE_CXX20_COROUTINES)
+
 #if defined(__has_include)
 #if __has_include(<coroutine>)
 #include <coroutine>
@@ -25,3 +27,5 @@ namespace hpx { namespace coro {
 #define HPX_COROUTINE_NAMESPACE_STD std::experimental
 #endif
 #endif
+
+#endif // HPX_HAVE_CXX20_COROUTINES
\ No newline at end of file

You need to add a #include <hpx/config/defines.hpp> before using the HPX_HAVE_CXX20_COROUTINES constant (it's defined in that header).

- Add #ifdef guards around the namespace include file

Signed-off-by: Shreyas Atre <shreyasatre16@gmail.com>
SAtacker added 2 commits July 21, 2022 12:42
- `#if defined` not needed
- Change `#pragma` location
- Include `config` header instead of including separately
- Prefer to check coroutine support first and then include the required
  headers

Signed-off-by: Shreyas Atre <shreyasatre16@gmail.com>
- await_suspend() accepts an argument of type coroutine_handle<void>

Signed-off-by: Shreyas Atre <shreyasatre16@gmail.com>
@SAtacker SAtacker force-pushed the p2300_enhancements branch from a7da48b to ff0ba76 Compare July 21, 2022 08:10
- Remove additional parentheses
- Missing EOL

Signed-off-by: Shreyas Atre <shreyasatre16@gmail.com>
@SAtacker SAtacker force-pushed the p2300_enhancements branch from ff0ba76 to c2117dd Compare July 21, 2022 16:05
Signed-off-by: Shreyas Atre <shreyasatre16@gmail.com>
@StellarBot
Copy link

Performance test report

HPX Performance

Comparison

BENCHMARKFORK_JOIN_EXECUTORPARALLEL_EXECUTORSCHEDULER_EXECUTOR
For Each(=)(=)(=)

Info

PropertyBeforeAfter
HPX Commitd5655f8a7fffac
HPX Datetime2022-05-31T12:57:29+00:002022-07-21T18:55:40+00:00
Clusternamedaintdaint
Compiler/apps/daint/SSL/HPX/packages/llvm-11.0.0/bin/clang++ 11.0.0/apps/daint/SSL/HPX/packages/llvm-11.0.0/bin/clang++ 11.0.0
Hostnamenid01193nid00907
Envfile
Datetime2022-05-31T15:13:01.357969+02:002022-07-21T22:30:12.398199+02:00

Comparison

BENCHMARKNO-EXECUTOR
Future Overhead - Create Thread Hierarchical - Latch-

Info

PropertyBeforeAfter
HPX Commitd5655f8a7fffac
HPX Datetime2022-05-31T12:57:29+00:002022-07-21T18:55:40+00:00
Clusternamedaintdaint
Compiler/apps/daint/SSL/HPX/packages/llvm-11.0.0/bin/clang++ 11.0.0/apps/daint/SSL/HPX/packages/llvm-11.0.0/bin/clang++ 11.0.0
Hostnamenid01193nid00907
Envfile
Datetime2022-05-31T15:13:18.026239+02:002022-07-21T22:30:29.436978+02:00

Comparison

BENCHMARKFORK_JOIN_EXECUTOR_DEFAULT_FORK_JOIN_POLICY_ALLOCATORPARALLEL_EXECUTOR_DEFAULT_PARALLEL_POLICY_ALLOCATORSCHEDULER_EXECUTOR_DEFAULT_SCHEDULER_EXECUTOR_ALLOCATOR
Stream Benchmark - Add(=)(=)(=)
Stream Benchmark - Scale(=)(=)(=)
Stream Benchmark - Triad(=)(=)(=)
Stream Benchmark - Copy(=)(=)(=)

Info

PropertyBeforeAfter
HPX Commit71d8dbea7fffac
HPX Datetime2021-11-10T19:14:21+00:002022-07-21T18:55:40+00:00
Clusternamedaintdaint
Compiler/apps/daint/SSL/HPX/packages/llvm-11.0.0/bin/clang++ 11.0.0/apps/daint/SSL/HPX/packages/llvm-11.0.0/bin/clang++ 11.0.0
Hostnamenid00120nid00907
Envfile
Datetime2021-11-10T20:28:18.266961+01:002022-07-21T22:30:44.790145+02:00

Explanation of Symbols

SymbolMEANING
=No performance change (confidence interval within ±1%)
(=)Probably no performance change (confidence interval within ±2%)
(+)/(-)Very small performance improvement/degradation (≤1%)
+/-Small performance improvement/degradation (≤5%)
++/--Large performance improvement/degradation (≤10%)
+++/---Very large performance improvement/degradation (>10%)
?Probably no change, but quite large uncertainty (confidence interval with ±5%)
??Unclear result, very large uncertainty (±10%)
???Something unexpected…

Copy link
Member

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@hkaiser
Copy link
Member

hkaiser commented Jul 25, 2022

bors merge

@bors
Copy link

bors bot commented Jul 25, 2022

Build succeeded:

@bors bors bot merged commit fa80b96 into STEllAR-GROUP:master Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: senders/receivers Implementations of the p0443r14 / p2300 + p1897 proposals type: compatibility issue type: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants