-
Notifications
You must be signed in to change notification settings - Fork 12
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
RFC: more verbose, more readable TT construction #264
base: master
Are you sure you want to change the base?
Conversation
Idea: create a TT from a functor and add inputs, outputs, and names step by step to improve code readability. Signed-off-by: Joseph Schuchart <[email protected]>
Aren't you missing the ttb in the |
Ahh right, added. |
Alternative: make the edge the center piece of the connection instead of the TT:
Since edges can have names too we would default to the edge name for the terminals if no explicit name is given. This really is syntactic sugar based on the initial proposal. It makes it clearer which inputs and outputs are connected. |
Inspired by https://github.com/mangpo/floem: do we really need edges? We use them as vehicle to glue to terminals together. A possible alternative could use the stream operators on the terminals directly:
When connecting only two terminals the order can be reversed: Connecting multiple TT inputs to the first output of
The stream operator does suggest some form of ordering between the TT inputs, which is not intended here. That may be somewhat misleading? |
Notes from the August 31, 2023 meeting The current state with strong typing of inputs and outputs for improved readability: ttg::Edge<int, float> a2b, b2a;
/* construct without edges */
auto tta = ttg::make_tt([](int key, float value){}, ttg::input(a2b), ttg::output(b2a),
"A", ttg::input_names{"b2a"}, ttg::output_names{"a2b"});
auto ttb = ttg::make_tt([](int key, float value){}, ttg::input(b2a), ttg::output(a2b),
"B", ttg::input_names{"a2b"}, ttg::output_names{"b2a"}); Still somewhat confusing and even more cluttered (IMO). As @therault suggested, having a way to specify the signature of the task upon creation and providing implementations later would be useful for multi-implementation tasks: auto tta = ttg::make_multi_tt(ttg::key<int>{}, ttg::args<float>{}); /* names are placeholders */
tta->add_impl<ttg::ExecutionSpace::CPU>([](int, float){ /* host implementation here */ });
tta->add_impl<ttg::ExecutionSpace::CUDA>([](int, float){ /* CUDA implementation here */ });
tta->add_impl<ttg::ExecutionSpace::HIP>([](int, float){ /* HIP implementation here */ }); This would allow us to use generic arguments again. The question on how to express the connection between TTs is orthogonal. @evaleev expressed concern that this adds yet another way of doing the same thing (on top of the original |
Alternative to chaining the
|
Another proposal at the end of the day:
|
could be shortened to:
by overloading |
Signed-off-by: Joseph Schuchart <[email protected]>
Signed-off-by: Joseph Schuchart <[email protected]>
At the last meeting we discussed using auto tta = ttg::make_tt([](int key, float value){});
auto ttb = ttg::make_tt([](int key, float value){});
ttg::connect(ttb->out<0>(), tta->in<0>()); // B -> A
ttg::connect(tta->out<0>(), ttb->in<0>()); // A -> B The problem is that we know the type of input terminals (from the argument list) but not the type of output terminals (because we have no edges to infer from). I found that there is already a version of auto tta = ttg::make_tt([](int key, float value){});
auto ttb = ttg::make_tt([](int key, float value){});
ttg::connect<0, 0>(ttb, tta); // B -> A
ttg::connect<0, 0>(tta, ttb); // A -> B We could default the indices to 0 if we wanted. Probably should add the ability to pass names... Also missing: output terminal fusion. Maybe we can pass a tuple of TTs and array of indices from which to fuse the outputs? auto tta = ttg::make_tt([](int key, float value){});
auto ttb = ttg::make_tt([](int key, float value){});
auto ttc = ttg::make_tt([](int key, float value){});
ttg::connect<{0, 0} 0>({ttb, ttc}, tta); // {B|C} -> A
ttg::connect<0, 0>(tta, ttb); // A -> B (C++-20 allows arrays as template arguments without specifying their size but that only seems to work with GCC so far) |
Based on a discussion between @bosilca, @therault and myself, I started to extend the API to improve readability. This gets us a bit closer to the style of TaskFlow.
Example:
The old way:
The new way:
This patch preserves the old way and adds the partial construction. The named member functions provide context for the arguments and help structure the code, at the cost of being more verbose.
Notes:
make_tt
.