@@ -1302,7 +1302,7 @@ struct ggml_threadpool {
1302
1302
// these are atomic as an annotation for thread-sanitizer
1303
1303
atomic_bool stop ; // Used for stopping the threadpool altogether
1304
1304
atomic_bool pause ; // Used for pausing the threadpool or individual threads
1305
- atomic_bool abort ; // Used for aborting processing of a graph
1305
+ atomic_int abort ; // Used for aborting processing of a graph
1306
1306
1307
1307
struct ggml_compute_state * workers ; // per thread state
1308
1308
int n_threads_max ; // number of threads in the pool
@@ -13851,14 +13851,14 @@ static thread_ret_t ggml_graph_compute_thread(void * data) {
13851
13851
/*.threadpool=*/ tp ,
13852
13852
};
13853
13853
13854
- for (int node_n = 0 ; node_n < cgraph -> n_nodes && ! tp -> abort ; node_n ++ ) {
13854
+ for (int node_n = 0 ; node_n < cgraph -> n_nodes && atomic_load_explicit ( & tp -> abort , memory_order_relaxed ) != node_n ; node_n ++ ) {
13855
13855
struct ggml_tensor * node = cgraph -> nodes [node_n ];
13856
13856
13857
13857
ggml_compute_forward (& params , node );
13858
13858
13859
13859
if (state -> ith == 0 && cplan -> abort_callback &&
13860
13860
cplan -> abort_callback (cplan -> abort_callback_data )) {
13861
- tp -> abort = true ;
13861
+ atomic_store_explicit ( & tp -> abort , node_n + 1 , memory_order_relaxed ) ;
13862
13862
tp -> ec = GGML_STATUS_ABORTED ;
13863
13863
}
13864
13864
@@ -14031,7 +14031,7 @@ static struct ggml_threadpool * ggml_threadpool_new_impl(
14031
14031
threadpool -> current_chunk = 0 ;
14032
14032
threadpool -> stop = false;
14033
14033
threadpool -> pause = tpp -> paused ;
14034
- threadpool -> abort = false ;
14034
+ threadpool -> abort = -1 ;
14035
14035
threadpool -> workers = NULL ;
14036
14036
threadpool -> n_threads_max = tpp -> n_threads ;
14037
14037
threadpool -> n_threads_cur = tpp -> n_threads ;
@@ -14110,7 +14110,7 @@ enum ggml_status ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cpl
14110
14110
threadpool -> cgraph = cgraph ;
14111
14111
threadpool -> cplan = cplan ;
14112
14112
threadpool -> current_chunk = 0 ;
14113
- threadpool -> abort = false ;
14113
+ threadpool -> abort = -1 ;
14114
14114
threadpool -> ec = GGML_STATUS_SUCCESS ;
14115
14115
}
14116
14116
0 commit comments