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

Taskflow for async #15634

Closed
wants to merge 3 commits into from
Closed

Taskflow for async #15634

wants to merge 3 commits into from

Conversation

tjhei
Copy link
Member

@tjhei tjhei commented Jul 3, 2023

sitting on top of #15610

Thank you @bangerth

@tjhei tjhei added this to the Developer workshop 2023 milestone Jul 3, 2023
@tjhei tjhei marked this pull request as draft July 3, 2023 21:32
@bangerth
Copy link
Member

bangerth commented Jul 3, 2023

Yes, good to go once the other PR is merged and this one is rebased!

@bangerth
Copy link
Member

bangerth commented Jul 9, 2023

Can you rebase on master?

@tamiko tamiko marked this pull request as ready for review July 9, 2023 04:28
@tamiko
Copy link
Member

tamiko commented Jul 9, 2023

@bangerth This PR is now rebased. I am not sure it is wise to merge this without a testsuite run.

@tjhei
Copy link
Member Author

tjhei commented Jul 9, 2023

This does not work as mentioned during the hackathon. I see deadlocks inside the call to join.

@bangerth
Copy link
Member

bangerth commented Jul 9, 2023

Yes, we're absolutely not going to merge this without testing on many platforms :-)

@bangerth
Copy link
Member

For reference, the issue is this one: taskflow/taskflow#575 I must be fundamentally misunderstanding how to create asynchronous tasks.

@tjhei
Copy link
Member Author

tjhei commented Apr 18, 2024

What a coincidence. I was just looking at this PR again a week or so ago. When updating to the development version of taskflow, the tests using async() no longer crash for me but they do hang in an infinite loop as you describe.

@bangerth
Copy link
Member

The reason why this patch doesn't work in its current form is described in #16935 and tested in #16934. We need to also add a way to wait for tasks to finish that informs the scheduler that that's what we're currently doing.

@bangerth
Copy link
Member

bangerth commented May 7, 2024

This seems to almost work. It hangs if a task ends with an exception (task_01_exception and derivative tests), but the other task-related tests seem to all work. I will have to debug this.

@bangerth
Copy link
Member

bangerth commented May 7, 2024

This is a bug in TaskFlow 3.6:

template <typename R, typename F>
auto Executor::_make_promised_async(std::promise<R>&& p, F&& func) {
  return [p=make_moc(std::move(p)), func=std::forward<F>(func)]() mutable {
    if constexpr(std::is_same_v<R, void>) {
      func();
      p.object.set_value();
    }
    else {
      p.object.set_value(func());
    }
  };
}

The function wants to put the output of func into the std::promise object, but forgets that the function could exit via an exception. I will have to check whether that is perhaps fixed in 3.7.

@bangerth
Copy link
Member

bangerth commented May 7, 2024

This seems to be fixed in the pre-release snapshot of TaskFlow that I'm importing in #16892. So now I will need to update that to the actual 3.7 release that came out a couple of days ago.

@bangerth
Copy link
Member

bangerth commented May 8, 2024

Superseded by #16976.

@bangerth bangerth closed this May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants