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
Exception Support for corun #519
Comments
@tsung-wei-huang I would like to work on this. But I don't understand weel the concept... |
No - corun will block until the predicate returns true. Basically, exception should be thrown if any. |
@tsung-wei-huang I recently played with corun implementation, and I made it rethrow an exception from the underlying taskflow.
Potential problems that I see:
Thing that IMO must be done together with this change:
Just wanted to mention: Of course I would prefer other people implementing this :), but if there are no volunteers I can help with implementation, and if you guide me a bit in resolving such opinion-based problems. I think I have good overview of how scheduling works, not perfect but good enough to start helping. |
Maybe this behavior meaningful as a long-term solution: https://oneapi-src.github.io/oneTBB/main/tbb_userguide/Cancellation_and_Nested_Parallelism.html |
@olologin Thank you for your idea! I think the best and fundamental way to solve this problem is to have an
will think about how this can be done as our other users@AMD are also requesting similar issues. In the meantime, please do not hesitate to let me know if you have any thoughts on this. |
@olologin @bradphelan this support has been implemented in the current master branch. Instead of having an additional topology as @olologin presented above, the new implementation will keep for each node a For example: tf::Executor executor(W);
tf::Taskflow taskflow1;
tf::Taskflow taskflow2;
taskflow1.emplace([](){
throw std::runtime_error("x");
});
taskflow2.emplace([&](){
try {
executor.corun(taskflow1); // exception is supported now at blocking method corun
} catch(const std::runtime_error& re) {
std::cout << re.what() << std::endl; // will get "x"
}
});
executor.run(taskflow2).get(); Would you please have a look and let me know if this works for your application? Thank you for bringing this up! Let me know if you observe any other exception problems that Taskflow does not handle properly. Handling exception in a multithreaded environment is quite tricky, and I may miss something. |
@tsung-wei-huang |
@tsung-wei-huang It seems it works correctly. I am happy with this implementation, I could not break it.
For example the following code will have sum ~ 75 at the moment we can catch the exception.
|
@olologin thank you very much for your great comments!
4-6. Thank you! I will update them later. Please also let me know if you could help update them in |
@tsung-wei-huang 4-6) Ok, I will propose MR with changes. |
Current exception supports only
tf::Future
fromtf::Executor::run
. There is a need to supporttf::Executor::co_run
as well:The text was updated successfully, but these errors were encountered: