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

run worker on mainthread #36

Open
michaelsippel opened this issue Dec 6, 2023 · 0 comments
Open

run worker on mainthread #36

michaelsippel opened this issue Dec 6, 2023 · 0 comments

Comments

@michaelsippel
Copy link
Member

michaelsippel commented Dec 6, 2023

For n requested workers, the current implementation spawns n additional threads executing work_loop() while the main() -thread does nothing but emplacing the tasks and then waiting for the other (worker-)threads to finish executing all tasks.

The proposal is to

  1. enable the main thread to change its role from "task-creator" to "worker" by storing some task_creator_continuation in the redgrapes::Context , which is initalized whenever the current task-creator thread decides to switch into worker-mode.
  2. let other worker threads take the task_creator_continuation as a last resort to obtain new tasks when all queues are empty.
  3. create n-1 additional threads when n workers are requested.

Potential benefits:

  • might decrease latency because after task emplacement, we do not need to wake up another, potentially sleeping thread which will then further process this task on another core. Instead we can directly proceed on the same thread and core from where the task originated.

Questions:

  • strategy for when the task-creator should switch into worker mode. As soon as possible, i.e. whenever it created a task that is immediately ready ?

Implementation Details:

  • create a "Root Task" , which is referenced from the redGrapes::Context instead of referencing the "Root task-space" and a separate continuation.
  • conceptually the functor for the root-task is the main() function., but its initialized implicitly and not by emplace_task.
  • for sub-graphs, the task-creator-continuation corresponds to the continuation of the parent task.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant