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

[WIP] Aggregators #229

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

[WIP] Aggregators #229

wants to merge 14 commits into from

Conversation

devreal
Copy link
Contributor

@devreal devreal commented Apr 4, 2022

Aggregators are meant to replace reduction terminals where the sole purpose is to collect a number of inputs before passing them into the task. An aggregator is created by wrapping the input type in a ttg::aggregator, which will cause values to be aggregated until either the target count is reached (if provided) or the stream size has been reached. The aggregator is then passed directly into the task and can be iterated over.

In combination with make_tt, an aggregator is created using ttg::make_aggregator(inedge) or ttg::make_aggregator(inedge, target). These calls will return a specialized Edge that allows to check at compile-time and create aggregators in the backend.

Example:

ttg::Edge<int, int> edge;
auto tt = make_tt(
  [](const int& key, ttg::aggregator<int>&& agg){
    for (auto&& v : agg) {
       ...
    }
  },
  ttg::edges(ttg::make_aggregator(edge)), ...);

Still to do:

[ ] Adapt the MADNESS backend.
[ ] Add support for void terminals (aggregator terminals will aggregate signals, not values)
[ ] Make sure the copies stored in the aggregator are properly found and released (needs #206 first)

Signed-off-by: Joseph Schuchart [email protected]

@devreal devreal force-pushed the aggregators2 branch 2 times, most recently from 03bb105 to 8a2cce3 Compare April 20, 2022 21:06
devreal and others added 7 commits April 26, 2022 13:35
Aggregators are meant to replace reduction terminals where the sole purpose
is to collect a number of inputs before passing them into the
task. An aggregator is created by wrapping the input type in a
ttg::aggregator, which will cause values to be aggregated until either
the target count is reached (if provided) or the stream size has been reached.
The aggregator is then passed directly into the task and can be iterated over.

In combination with make_tt, an aggregator is created using
`ttg::make_aggregator(inedge)` or `ttg::make_aggregator(inedge, target)`.
These calls will return a specialized Edge that allows to check at
compile-time and create aggregators in the backend.

Example:

```
ttg::Edge<int, int> edge;
auto tt = make_tt(
  [](const int& key, ttg::aggregator<int>& agg){
    for (auto&& v : agg) {
       ...
    }
  },
  ttg::edges(ttg::make_aggregator(edge)), ...);
```

Signed-off-by: Joseph Schuchart <[email protected]>
Some use-cases have per-key aggregation targets so we need the added
flexibility.

Signed-off-by: Joseph Schuchart <[email protected]>
Signed-off-by: Joseph Schuchart <[email protected]>
devreal added 7 commits April 27, 2022 12:12
This feature is useful if there is sufficient concurrency in the application,
with multiple consumers and one subsequent producer on a data.
By seting defer_writer(), the application can signal that it is ok
to defer the next writer on the data until all readers completed,
avoiding the data to be copied.
This may lead to a deadlock though, if the execution of the readers
depends on the writer. This feature thus has to be used cautiously.

Signed-off-by: Joseph Schuchart <[email protected]>
Signed-off-by: Joseph Schuchart <[email protected]>
For small aggregators the dynamic memory management of a vector
is potentially too costly. Unfortunately, we cannot use unions with
non-POD datatypes and std::variant won't work with arrays and requires
initialization of the member that is used.

Signed-off-by: Joseph Schuchart <[email protected]>
Look at the in_data_count instead of the remove_from_hash field

Signed-off-by: Joseph Schuchart <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants