Skip to content

Commit 3b14c84

Browse files
fmzfmz
authored andcommitted
fixed a harmless race condition
1 parent ecf54e2 commit 3b14c84

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

ggml/src/ggml.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19312,18 +19312,16 @@ enum ggml_status ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cpl
1931219312
};
1931319313

1931419314
threadpool = ggml_create_threadpool_impl(&ttp, true, cgraph, cplan);
19315-
} else if (n_threads > threadpool->n_threads_max) {
19316-
GGML_PRINT("WARNING: cplan is requesting more threads than the threadpool contains. Expect a bad time!\n");
19317-
}
19318-
19319-
// Set up work
19320-
threadpool->cgraph = cgraph;
19321-
threadpool->cplan = cplan;
19322-
threadpool->n_threads_cur = n_threads;
19323-
19324-
if (!disposable_threadpool) {
19315+
} else {
19316+
if (n_threads > threadpool->n_threads_max) {
19317+
GGML_PRINT("WARNING: cplan is requesting more threads than the threadpool contains. Expect a bad time!\n");
19318+
}
19319+
// Not a disposable threadpool:
1932519320
// Reset some of the paramters that need resetting
1932619321
// No worker threads should be accessing the parameters below at this stage
19322+
threadpool->cgraph = cgraph;
19323+
threadpool->cplan = cplan;
19324+
threadpool->n_threads_cur = n_threads;
1932719325
threadpool->n_barrier = 0;
1932819326
threadpool->n_barrier_passed = 0;
1932919327
threadpool->current_chunk = 0;

0 commit comments

Comments
 (0)