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

Pipeline Forking #12

Open
massadop opened this issue Jun 9, 2021 · 2 comments
Open

Pipeline Forking #12

massadop opened this issue Jun 9, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@massadop
Copy link

massadop commented Jun 9, 2021

Hi Joel,
Thank you very much for the fix. TDP works fine now.
I would be very interested in "Forking (parallel task)`metioned at the end of the TODO list. I am not completely sure if this 'forking' means to install a new branch on the pipeline, so one input can pass the data to more than one stages or pipes and at the end to have different outputs one per each branch.
Brgds

@JoelFilho JoelFilho added the enhancement New feature or request label Jun 9, 2021
@JoelFilho JoelFilho changed the title TDP C++ 20 fix Pipeline Forking Jun 9, 2021
@JoelFilho
Copy link
Owner

Hello, the idea of forking is exactly that: feeding the output of a pipeline into multiple others.

However, this kind of operation incurs some complications:

  • The DSL becomes really complicated, especially when joining back
  • How do we synchronize the input into multiple pipelines? (Which brings some overhead into the library, if we need to release them simultaneously)
  • Putting parallel pipelines inside a pipeline? That's not a pipeline anymore, it's a flow graph! There are more complete tools that deal with such a thing, like Intel TBB. Notice how much more complex it is to define a graph there, when compared to a pipeline.

So, the things listed as "Possible features" on the TODO are just ideas of future features, after the 1.0 release of TDP, and there are still no plans for those features.

If you need to fork pipelines without needing to rejoin them, and still want to use TDP, it's fairly easy to compose a series of pipelines with your own dispatcher, adding it as a consumer to the main pipeline, e.g.:

auto square_pipe = tdp::input<int> >> square >> tdp::consumer{print};
auto increment_pipe = tdp::input<int> >> increment >> tdp::consumer{print};

auto forker = [&](int in){
    square_pipe.input(in);
    increment_pipe.input(in);
};

auto my_pipe = tdp::input<int, int> >> add >> tdp::consumer{forker};

(Notice the structures in TDP are single-producer, single-consumer, so you cannot use square_pipe.input() and increment_pipe.input() in their scope, in this example. You would instead make a self-contained class or use the ownership wrappers, to prevent such kind of problem)

@massadop
Copy link
Author

massadop commented Jun 10, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants