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

callback to abort ggml_graph_compute() #328

Merged
merged 13 commits into from
Jul 11, 2023
Prev Previous commit
make sure all threads abort
  • Loading branch information
CCLDArjun committed Jul 11, 2023
commit 26b90d06eae80ef295be14071be714ac8e39ee2f
1 change: 1 addition & 0 deletions src/ggml.c
Original file line number Diff line number Diff line change
Expand Up @@ -15982,6 +15982,7 @@ static thread_ret_t ggml_graph_compute_thread(void * data) {

while (true) {
if (cplan->abort_callback && cplan->abort_callback(cplan->abort_callback_data)) {
state->shared->node_n += 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found an issue while testing that sometimes all but one thread aborts and that one thread is spinning, waiting for shared->node_n to be updated. So, I decided to modify node_n

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. Would be nice to have some test program for this functionality added

return GGML_EXIT_ABORTED;
}
if (atomic_fetch_sub(&state->shared->n_active, 1) == 1) {
Expand Down