Lightweight way of spawning task and waiting for it
Prior to oneTBB, it was quite easy to spawn a task, do some work, and then wait for it at some future point in time. With oneTBB, the only way to do this seems to be via a tbb::task_group. However, on Windows, even on a release build, sizeof(tbb::task_group) is 264 bytes which is comparatively large overhead, especially if I have to keep many of these around.
@e4lam I believe in general this is the only way. To advise more specific solution some input is required. A code sample would be ideal :) Some helper questions are:
- are tasks being spawn independent ?
- are the task lifetimes intersect ?
@anton-potapov Yes, the tasks are all independently spawned and have no dependencies (lifetime or otherwise) between them. It really is the equivalent of a std::future except I want to use the TBB thread pool.
IMHO, the removal of the low-level task API is a mistake as while one can still do the same operations in the higher-level API, it's not equivalent because they're incurring much higher overhead. If someone is going to start restructuring code to adopt to oneTBB, then maybe they might start looking at other APIs like taskflow instead where they purport to have better scheduling performance than TBB.
@e4lam Is this problem still relevant to you?
If yes, what do you think about combined approach task_group + arena enqueue. You might submit single functions (task) via arena enqueue and wait for completion on atomic (for example) and for group of task use task_ group.
Yes, this is still an issue and I'm suffering for it. I don't see how this "combined" approach helps because the point is to NOT keep around a task_group at all.
Rolling my own synchronization is not better because we used to have the low-level API so I presume all the infrastructure to wait on a task still exists in the library, except that it's been made all private.