Skip to content

[Sycl][Graph] Reimplement topological sort algorithm #17495

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

Merged
merged 3 commits into from
Mar 19, 2025

Conversation

fabiomestre
Copy link
Contributor

The current implementation of the topological sort algorithm relies on a recursive function. This causes stack overflow issues when the graphs are very large. There is also a performance issue in the current implementation related to the way std::find() is being used.

This commit reimplements the topological sort algorithm to fix these issues:

  • Uses an iterative approach instead of recursive.
  • Removes the use of std::find() and instead relies on keeping the state with a helper variable.
  • Reimplements the cycle checking algorithm to use the same topological sort function as the one used during scheduling.
  • Fixes a bug with make_edge() not removing the dest node from the list of root nodes.

@fabiomestre fabiomestre marked this pull request as ready for review March 17, 2025 19:04
@fabiomestre fabiomestre requested a review from a team as a code owner March 17, 2025 19:04
@fabiomestre fabiomestre requested a review from EwanC March 17, 2025 19:04
The current implementation of the topological sort
algorithm relies on a recursive function. This causes
stack overflow issues when the graphs are very large.
There is also a performance issue in the current implementation
related to the way std::find() is being used.

This commit reimplements the topological sort algorithm to fix
these issues:

- Uses an iterative approach instead of recursive.
- Removes the use of std::find() and instead relies on keeping the state
  with a helper variable.
- Reimplements the cycle checking algorithm to use the same topological
  sort function as the one used during scheduling.
- Fixes a bug with make_edge() not removing the dest node from the list of
  root nodes.
@fabiomestre
Copy link
Contributor Author

@intel/llvm-gatekeepers This should be ready to merge.

@kbenzie kbenzie merged commit d2578a3 into intel:sycl Mar 19, 2025
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants