-
Notifications
You must be signed in to change notification settings - Fork 1k
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
task.h is deprecated, alternative? #243
Comments
The proposed path forward is to use high-level API such as parallel algorithms (e.g. |
@tjhei , can you please describe your use case for the class |
thanks for the quick reply.
Okay, we can probably migrate to task_group.
I went through the document you link before opening the issue, but I can not find any mention of a) task being deprecated or b) what to use instead. Maybe I am missing something? The example |
@aleksei-fedotov -- thanks indeed for chiming in! The use case in our software is here: https://github.com/dealii/dealii/blob/master/include/deal.II/base/thread_management.h#L1200-L1231 and https://github.com/dealii/dealii/blob/master/include/deal.II/base/thread_management.h#L1349-L1361 We are, in essence, building there what in C++11 one would achieve with |
To extend what @bangerth just wrote:
|
Overall, we do not recommend using task API in TBB directly because it is too low level and hides multiple caveats. @tjheu, as for your use cases
|
It is likely that this change will also cause serious difficulties with the CMS experiment at CERN. We rely on tbb::tasks directly and we've designed the system using tasks in order to avoid the need to do a wait (except one wait which is only waiting on the application to end). We chose tbb 8 years ago specifically because the low level task support gave us the flexibility we needed. Our initial look at task_group seems to indicate they are not flexible enough for our need. |
We are not going to drop task API but it will be significantly reworked and it will not directly replaceable with the current task API.
Can you list the interfaces that you are using to understand what we can do to simply the migration? |
@alexey-katranov -- this might be a good time to ask whether under the hood, TBB and C++11 use the same thread pools? If |
@Dr15Jones -- take a look at If I read this right (confirmation from @alexey-katranov welcome!), then the only thing it doesn't do is give you a handle to the task itself that is being created. So you can't easily wait for it. But if you wrap the operation you want into a |
No, it does not. Unfortunately, the entity "thread pool" is not defined in C++11. Even Parallel STL (C++17) does not define anything about that. Hopefully, C++ executors will help us to manage/share threads more efficient with future standards. As for |
On 4/21/20 10:31 AM, Alex wrote:
TBB and C++11 use the same thread pools?
No, it does not.
Unfortunately, the entity "thread pool" is not defined in C++11. Even Parallel
STL (C++17) does not define anything about that. Hopefully, C++ executors will
help us to manage/share threads more efficient with future standards.
Right -- it was a question about implementation practice, not what the
standard guarantees. How does TBB implement tasks? Using the C++11 facilities,
or does it use its own thread pool?
As for |parallel_invoke|, it is a blocking API;
Oh, I had assumed that there is a version of |parallel_invoke| with a single
argument that just creates a task and immediately returns. But you're saying
that all of these functions only return when all tasks have finished.
So then what is the equivalent of |std::async(std::launch::async, ...);|?
|
As for As for Parallel STL, it should be mentioned that some implementations use TBB underneath, so TBB thread pool is shared in such C++ implementations. |
@alexey-katranov Thanks for your reply
It will take some time for me to do a comprehensive inventory of what we are using. Most of our wrappings around TBB are here (https://github.com/cms-sw/cmssw/tree/master/FWCore/Concurrency) though we do have non-wrapped usages as well. Consulting with my colleagues, we will explore trying to use just Other than direct use of tasks, are there any other TBB constructs we should avoid? |
I've looked through the code, overall, the usage does not seem complex. However, I've noticed |
We use that in the cases where we are communicating with a thread not under the control of tbb. For example, that could be a callback from CUDA or a thread which is waiting for a response from another process (e.g. evaluating a ML inference being done remotely). In all other cases we use |
@Dr15Jones , it seems as a some sort of workaround because |
Yes. We typically have one main arena (the default one) for the majority of our tasks. When we have work that is coming from outside of TBB (e.g. a CUDA callback) we want to add a task to the arena from which the external request was made (e.g. the arena assigned to the thread used to call a CUDA asynchronous function that takes the callback parameter). We do have a few other arenas (primarily used to fence off third party functions which are also using TBB) so we do not assume there is only one arena active in our application. |
@alexey-katranov I also wanted to say 'thank you' for taking the time to take a look at our code. |
@Dr15Jones, you are welcome. I am closing this thread if there is no more questions. If you still have some issues or questions, feel free to reopen the thread or start a new issue. |
Consider #367 and uxlfoundation/oneAPI-spec#292 that introduce |
Yeah, I do need the help as well : heremaps/pptk#58 |
With a recent version of TBB I am getting the warning
but I am unable to find information about the deprecation or an alternative to using the class
task
. What is the proposed path forward?The text was updated successfully, but these errors were encountered: