You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+80-41Lines changed: 80 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,19 @@
1
1
# Senders - A Standard Model for Asynchronous Execution in C++
2
2
3
-
`stdexec` is an experimental reference implementation of the _Senders_ model of asynchronous programming proposed by [**P2300 - `std::execution`**](http://wg21.link/p2300) for adoption into the C++ Standard.
3
+
`stdexec` is an experimental reference implementation of the _Senders_ model of
4
+
asynchronous programming proposed by [**P2300 -
5
+
`std::execution`**](http://wg21.link/p2300) and accepted into the C++26 Standard.
4
6
5
7
**Purpose of this Repository:**
6
-
1. Provide a proof-of-concept implementation of the design proposed in [P2300](http://wg21.link/p2300).
7
-
2. Provide early access to developers looking to experiment with the Sender model.
8
-
3. Collaborate with those interested in participating or contributing to the design of P2300 (contributions welcome!).
8
+
9
+
1. Provide a reference implementation for the C++26 additions to `std::execution`.
10
+
11
+
2. Get usage experience with the C++26 `std::execution` additions, as well as with
12
+
not-yet-proposed extensions to `std::execution`.
13
+
14
+
3. Provide NVIDIA-specific extensions for running code on NVIDIA GPUs using standard C++.
15
+
16
+
4. Collaborate with those interested in extending `std::execution` for C++29.
9
17
10
18
## Disclaimer
11
19
@@ -18,7 +26,7 @@ The authors and NVIDIA do not guarantee that this code is fit for any purpose wh
18
26
## Example
19
27
20
28
Below is a simple program that executes three senders concurrently on a thread pool.
21
-
Try it live on [godbolt!](https://godbolt.org/z/3cseorf7M).
29
+
Try it live on [godbolt!](https://godbolt.org/z/8MqaKEEfT).
22
30
23
31
```c++
24
32
#include<stdexec/execution.hpp>
@@ -49,26 +57,11 @@ int main()
49
57
// Launch the work and wait for the result
50
58
auto [i, j, k] = stdexec::sync_wait(std::move(work)).value();
51
59
52
-
// Print the results:
60
+
// Prints "0 1 4":
53
61
std::printf("%d %d %d\n", i, j, k);
54
62
}
55
63
```
56
64
57
-
## Resources
58
-
-[Working with Asynchrony Generically: A Tour of Executors: Part 1](https://www.youtube.com/watch?v=xLboNIf7BTg) ([Part 2](https://www.youtube.com/watch?v=6a0zzUBUNW4)) (Video): A comprehensive introduction to Senders and structured concurrency
59
-
-[What are Senders Good For, Anyway?](https://ericniebler.com/2024/02/04/what-are-senders-good-for-anyway/) (Blog): Demonstrates the value of a standard async programming model by wrapping a C-style async API in a sender
60
-
-[From Zero to Sender/Receiver in ~60 Minutes](https://www.youtube.com/watch?v=xiaqNvqRB2E) (Video): Live-coding a toy sender/receiver implementation from scratch
61
-
-[A Unifying Abstraction for Async in C++](https://www.youtube.com/watch?v=h-ExnuD6jms) (Video): A simple introduction to the concepts behind P2300
62
-
-[A Universal Async Abstraction for C++](https://cor3ntin.github.io/posts/executors/) (Blog): An introduction to Senders
63
-
-[A Universal I/O Abstraction for C++](https://cor3ntin.github.io/posts/iouring/) (Blog): A look at how the Senders concepts interact with `io_uring` on Linux
64
-
-[Structured Concurrency](https://www.youtube.com/watch?v=1Wy5sq3s2rg) (Video): An explanation of structured concurrency in C++ and its benefits
65
-
-[Executors: a Change of Perspective](https://accu.org/journals/overload/29/165/teodorescu/) (Article): An article about the computational completeness of Senders
66
-
-[Structured Concurrency in C++](https://accu.org/journals/overload/30/168/teodorescu/) (Article): An article about how Senders manifest the principles of structured concurrency
67
-
-[Structured Networking in C++](https://www.youtube.com/watch?v=XaNajUp-sGY) (Video): A look at what a P2300-style networking library could look like
68
-
-[HPCWire Article](https://www.hpcwire.com/2022/12/05/new-c-sender-library-enables-portable-asynchrony/): Provides a high-level overview of the Sender model and its benefits
69
-
-[NVIDIA HPC SDK Documentation](https://docs.nvidia.com/hpc-sdk/index.html): Documentation for the NVIDIA HPC SDK
70
-
-[P2300 - `std::execution`](https://wg21.link/p2300): Senders proposal to C++ Standard
71
-
72
65
## Structure
73
66
74
67
This library is header-only, so all the source code can be found in the `include/` directory. The physical and logical structure of the code can be summarized by the following table:
@@ -85,39 +78,62 @@ This library is header-only, so all the source code can be found in the `include
2. Download the [NVIDIA HPC SDK starting with 22.11](https://developer.nvidia.com/nvidia-hpc-sdk-releases)
89
-
3. (Recommended) Use [CMake Package Manager (CPM)](https://github.com/cpm-cmake/CPM.cmake) to automatically pull `stdexec` as part of your CMake project. [See below](#cmake-package-manager-cpm) for more information.
90
81
91
-
You can also try it directly on [godbolt.org](https://godbolt.org/z/acaE93xq3) where it is available as a C++ library or via the nvc++ compiler starting with version 22.11 ([see below](#nvhpc-sdk) for more details).
3. (Recommended) Use [CMake Package Manager (CPM)](https://github.com/cpm-cmake/CPM.cmake)
86
+
to automatically pull `stdexec` as part of your CMake project. [See
87
+
below](#cmake-package-manager-cpm) for more information.
88
+
89
+
You can also try it directly on [godbolt.org](https://godbolt.org/z/acaE93xq3) where it is
90
+
available as a C++ library or via the nvc++ compiler starting with version 22.11 ([see
91
+
below](#nvhpc-sdk) for more details).
92
92
93
93
## Using `stdexec`
94
94
95
95
### Requirements
96
96
97
-
`stdexec` requires compiling with C++20 (`-std=c++20`) but otherwise does not have any dependencies and only requires a sufficiently new compiler:
97
+
`stdexec` requires compiling with C++20 (`-std=c++20`) but otherwise does not have any
98
+
dependencies and only requires a sufficiently new compiler:
98
99
99
100
- gcc 11+
100
101
- clang 16+
101
102
- XCode 16+
102
-
-[nvc++ 22.11+](https://developer.nvidia.com/nvidia-hpc-sdk-releases) (required for [GPU support](#gpu-support)). If using `stdexec` from GitHub, then nvc++ 23.3+ is required.
103
+
-[nvc++ 25.9+](https://developer.nvidia.com/nvidia-hpc-sdk-releases) (required for [GPU
104
+
support](#gpu-support)).
105
+
106
+
> [!NOTE]
107
+
> `stdexec` does not yet work with NVIDIA's nvcc compiler.
103
108
104
109
How you configure your environment to use `stdexec` depends on how you got `stdexec`.
105
110
106
111
### NVHPC SDK
107
112
108
-
Starting with the 22.11 release of the [NVHPC SDK](https://developer.nvidia.com/nvidia-hpc-sdk-releases), `stdexec` is available as an experimental, opt-in feature. Specifying the `--experimental-stdpar` flag to `nvc++` makes the `stdexec` headers available on the include path. You can then include any `stdexec` header as normal: `#include <stdexec/...>`, `#include <nvexec/...>`. See [godbolt example](https://godbolt.org/z/qc1h3sqEv).
113
+
Starting with the 22.11 release of the [NVHPC
114
+
SDK](https://developer.nvidia.com/nvidia-hpc-sdk-releases), `stdexec` is available as an
115
+
experimental, opt-in feature. Specifying the `--experimental-stdpar` flag to `nvc++` makes
116
+
the `stdexec` headers available on the include path. You can then include any `stdexec`
117
+
header as normal: `#include <stdexec/...>`, `#include <nvexec/...>`. See [godbolt
118
+
example](https://godbolt.org/z/qc1h3sqEv).
109
119
110
-
GPU features additionally require specifying `-stdpar=gpu`. For more details, see [GPU Support](#gpu-support).
120
+
GPU features additionally require specifying `-stdpar=gpu`. For more details, see [GPU
121
+
Support](#gpu-support).
111
122
112
123
### GitHub
113
124
114
-
As a header-only C++ library, technically all one needs to do is add the `stdexec``include/` directory to your include path as `-I<stdexec root>/include` in addition to specifying any necessary compile options.
125
+
As a (mostly) header-only C++ library, technically all one needs to do is add the
126
+
`stdexec``include/` directory to your include path as `-I<stdexec root>/include` in
127
+
addition to specifying any necessary compile options.
115
128
116
-
For simplicity, we recommend using the [CMake targets](#cmake) that `stdexec` provides as they encapsulate the necessary configuration.
129
+
For simplicity, we recommend using the [CMake targets](#cmake) that `stdexec` provides as
130
+
they encapsulate the necessary configuration.
117
131
118
132
#### cmake
119
133
120
-
If your project uses CMake, then after cloning `stdexec` simply add the following to your `CMakeLists.txt`:
134
+
If your project uses CMake, then after cloning `stdexec` simply add the following to your
135
+
`CMakeLists.txt`:
136
+
121
137
```
122
138
add_subdirectory(<stdexec root>)
123
139
```
@@ -128,27 +144,32 @@ This will make the `STDEXEC::stdexec` target available to link with your project
This target encapsulates all of the necessary configuration and compiler flags for using `stdexec`.
147
+
This target encapsulates all of the necessary configuration and compiler flags for using
148
+
`stdexec`.
132
149
133
150
134
151
#### CMake Package Manager (CPM)
135
152
136
-
To further simplify obtaining and including `stdexec` in your CMake project, we recommend using [CMake Package Manager (CPM)](https://github.com/cpm-cmake/CPM.cmake) to fetch and configure `stdexec`.
153
+
To further simplify obtaining and including `stdexec` in your CMake project, we recommend
154
+
using [CMake Package Manager (CPM)](https://github.com/cpm-cmake/CPM.cmake) to fetch and
-[Working with Asynchrony Generically: A Tour of Executors: Part 1](https://www.youtube.com/watch?v=xLboNIf7BTg) ([Part 2](https://www.youtube.com/watch?v=6a0zzUBUNW4)) (Video): A comprehensive introduction to Senders and structured concurrency
252
+
-[What are Senders Good For, Anyway?](https://ericniebler.com/2024/02/04/what-are-senders-good-for-anyway/) (Blog): Demonstrates the value of a standard async programming model by wrapping a C-style async API in a sender
253
+
-[From Zero to Sender/Receiver in ~60 Minutes](https://www.youtube.com/watch?v=xiaqNvqRB2E) (Video): Live-coding a toy sender/receiver implementation from scratch
254
+
-[A Unifying Abstraction for Async in C++](https://www.youtube.com/watch?v=h-ExnuD6jms) (Video): A simple introduction to the concepts behind P2300
255
+
-[A Universal Async Abstraction for C++](https://cor3ntin.github.io/posts/executors/) (Blog): An introduction to Senders
256
+
-[A Universal I/O Abstraction for C++](https://cor3ntin.github.io/posts/iouring/) (Blog): A look at how the Senders concepts interact with `io_uring` on Linux
257
+
-[Structured Concurrency](https://www.youtube.com/watch?v=1Wy5sq3s2rg) (Video): An explanation of structured concurrency in C++ and its benefits
258
+
-[Executors: a Change of Perspective](https://accu.org/journals/overload/29/165/teodorescu/) (Article): An article about the computational completeness of Senders
259
+
-[Structured Concurrency in C++](https://accu.org/journals/overload/30/168/teodorescu/) (Article): An article about how Senders manifest the principles of structured concurrency
260
+
-[Structured Networking in C++](https://www.youtube.com/watch?v=XaNajUp-sGY) (Video): A look at what a P2300-style networking library could look like
261
+
-[HPCWire Article](https://www.hpcwire.com/2022/12/05/new-c-sender-library-enables-portable-asynchrony/): Provides a high-level overview of the Sender model and its benefits
262
+
-[NVIDIA HPC SDK Documentation](https://docs.nvidia.com/hpc-sdk/index.html): Documentation for the NVIDIA HPC SDK
263
+
-[P2300 - `std::execution`](https://wg21.link/p2300): Senders proposal to C++ Standard
0 commit comments