Commit 2f730962 authored by Xavier Thompson's avatar Xavier Thompson

Improve README.md

parent beb737fa
# (*Working Title*) Typon
> typon \ti.pɔ̃\ masculin
>
> (Imprimerie) Masque, feuille transparente, sur laquelle est imprimé un motif
> dans une encre opaque qui permet d'insoler, puis de graver la plaque qui
> servira à imprimer.
>
> (Électronique) Masque transparent sur lequel sont imprimées les pistes, dans
> une encre opaque aux ultraviolets, permettant de réaliser un circuit imprimé
> par photogravure soustractive.
Typon is a three-part project to bring practical GIL-free concurrency to Python:
1. [ ] Write a C++ concurrency runtime
2. [ ] Write a compiler from Python syntax into C++
3. [ ] Add C++/Python bindings for interoperability with actual Python
Step 1 is currently in progress.
## (*in progress*) `typon/rt`, A Concurrency Runtime
## `typon/rt`, A Concurrency Runtime
A continuation-stealing concurrency runtime using cutting-edge C++20 coroutines,
featuring both `fork`/`sync` structured concurrency and `future`-based unbounded
concurrency.
### Status
- [x] structured concurrency with `fork`/`sync`
- [x] systematic exception propagation from `fork`ed tasks
- [x] unbounded concurrency with `future`
- [x] asynchronous waiting (`Promise`, `future`/`Future`)
- [ ] channels (single producer, single consumer)
- [ ] mutexes (with asynchronous blocking)
- [ ] asynchronous I/O
- [ ] builtin task cancellation
- [x] unbounded concurrency with the `future` primitive
- [x] asynchronous waiting on `Future` and `Promise` objects
- [ ] channels (single producer, single consumer)
- [ ] mutexes (with asynchronous blocking)
- [ ] asynchronous I/O
- [ ] task cancellation
### `fork`/`sync`, Structured Concurrency
......@@ -56,8 +39,25 @@ Join<int> fibo(int n) {
}
```
[Structured concurrency](https://en.wikipedia.org/wiki/Structured_concurrency)
is a concurrency paradigm where parallel execution paths are always joined
before exiting the function which created them.
It makes it possible to reason locally about concurrent code, since concurrent
tasks will not outlive the current function. This makes concurrent code more
intuitive and readable, and makes it much easier to reason about memory safety
and thread safety. It also enables systematic exception propagation from
spawned tasks to the parent scope.
The `fork`/`sync` primitives mirror the `spawn`/`sync` paradigm of [Cilk](http://cilk.mit.edu/).
`fork` introduces a potentially parallel nested task. `sync` waits for all
the tasks forked so far in the current scope. `fork`/`sync` can only be used
inside a `Join` coroutine, which guarantees all forked tasks complete before
the parent `Join` coroutine returns, even when there is no explicit `sync`.
### `future`, Unbounded Concurrency
### `future`, A Primitive for Unbounded Concurrency
```
using namespace typon;
......@@ -74,9 +74,69 @@ Task<int> fibo(int n) {
}
```
In cases when structured concurrency is too constraining, the `future` primitive
creates concurrent tasks that may outlive the parent scope, more like the `go`
statement in Go. Unlike `go`, `future` immediately returns a `Future` object
that can be used to wait for the task to complete. If the `Future` object is
not used, the task becomes "detached" and lives independantly.
### Examples
See `rt/examples`.
### Using `rt/typon`
`typon/rt` is a headers-only library, so no preliminary build step is required.
Programs only need to include `rt/include/typon/typon.hpp`.
Compiling requires `gcc++-11` or `clang++-14` or more recent.
See `rt/examples` for hints.
### References
- https://en.wikipedia.org/wiki/Work_stealing#Child_stealing_vs._continuation_stealing
##### Structured Concurrency
- Nathaniel J. Smith's [Notes on structured concurrency](https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/)
- Martin Sústrik's blog articles on [structured concurrency](https://250bpm.com/blog:137/index.html)
- Lewis Baker's talk on [structured concurrency with C++20 coroutines](https://www.youtube.com/watch?v=1Wy5sq3s2rg)
##### C++20 Coroutines
- Lewis Baker's [Asymmetric Transfer blog on C++20 coroutines](https://lewissbaker.github.io/)
- [C++20 coroutines at cppreference.com](https://en.cppreference.com/w/cpp/language/coroutines)
##### Papers
- N. S. Arora, R. D. Blumofe, and C. G. Plaxton. 1998.
Thread scheduling for multiprogrammed multiprocessors.
https://doi.org/10.1145/277651.277678
- D. Chase and Y. Lev. 2005.
Dynamic circular work-stealing deque.
https://doi.org/10.1145/1073970.1073974
- N. M. Lê, A. Pop, A. Cohen, and F. Zappa Nardelli. 2013.
Correct and efficient work-stealing for weak memory models.
https://doi.org/10.1145/2517327.2442524
- Kyle Singer, Yifan Xu, and I-Ting Angelina Lee. 2019.
Proactive work stealing for futures.
https://doi.org/10.1145/3293883.3295735
- C. X. Lin, T .W Huang, and M. D. F. Wong. 2020.
An efficient work-stealing scheduler for task dependency graph.
https://tsung-wei-huang.github.io/papers/icpads20.pdf
- https://en.wikipedia.org/wiki/Futures_and_promises
- F. Schmaus, N. Pfeiffer, W. Schröder-Preikschat, T. Hönig, and J. Nolte.
2021. Nowa: a wait-free continuation-stealing concurrency platform.
https://www4.cs.fau.de/Publications/2021/schmaus2021nowa.pdf
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment