Skip to content

Commit

Permalink
ggml : try to fix the abort mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
ggerganov committed Nov 5, 2023
1 parent 39cfad0 commit aaa3b5e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions ggml.c
Original file line number Diff line number Diff line change
Expand Up @@ -16391,9 +16391,6 @@ struct ggml_compute_state_shared {
// synchronization primitives
atomic_int n_active; // num active threads
atomic_int node_n; // active graph node

bool (*abort_callback)(void * data); // abort ggml_graph_compute when true
void * abort_callback_data;
};

struct ggml_compute_state {
Expand Down Expand Up @@ -16744,6 +16741,10 @@ static thread_ret_t ggml_graph_compute_thread(void * data) {

node_n = atomic_load(&state->shared->node_n);
if (node_n != last) break;

if (cplan->abort_callback && cplan->abort_callback(cplan->abort_callback_data)) {
break;
}
};
}

Expand Down Expand Up @@ -17037,8 +17038,6 @@ int ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cplan * cplan) {
/*.n_threads =*/ n_threads,
/*.n_active =*/ n_threads,
/*.node_n =*/ -1,
/*.abort_callback =*/ NULL,
/*.abort_callback_data =*/ NULL,
};
struct ggml_compute_state * workers = alloca(sizeof(struct ggml_compute_state)*n_threads);

Expand Down

0 comments on commit aaa3b5e

Please sign in to comment.