Skip to content

Commit 94ddd62

Browse files
committed
Simplify the logic of scheduling
1 parent 6d18c6e commit 94ddd62

File tree

1 file changed

+10
-27
lines changed

1 file changed

+10
-27
lines changed

ggml.c

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9258,22 +9258,17 @@ struct ggml_compute_state {
92589258
static void ggml_graph_compute_thread(void * data) {
92599259
struct ggml_compute_state * state = (struct ggml_compute_state *) data;
92609260
int type = state->params.type;
9261-
if (state->node) {
9262-
if (state->params.ith < state->params.nth) {
9263-
if (type == GGML_TASK_INIT)
9264-
{
9265-
state->params.type = GGML_TASK_INIT;
9266-
ggml_compute_forward(&state->params, state->node);
9267-
type = GGML_TASK_COMPUTE;
9268-
}
9261+
if (type == GGML_TASK_INIT)
9262+
{
9263+
state->params.type = GGML_TASK_INIT;
9264+
ggml_compute_forward(&state->params, state->node);
9265+
type = GGML_TASK_COMPUTE;
9266+
}
92699267

9270-
if (type == GGML_TASK_COMPUTE)
9271-
{
9272-
state->params.type = GGML_TASK_COMPUTE;
9273-
ggml_compute_forward(&state->params, state->node);
9274-
}
9275-
}
9276-
state->node = NULL;
9268+
if (type == GGML_TASK_COMPUTE)
9269+
{
9270+
state->params.type = GGML_TASK_COMPUTE;
9271+
ggml_compute_forward(&state->params, state->node);
92779272
}
92789273
}
92799274

@@ -9284,18 +9279,6 @@ void ggml_graph_compute(struct ggml_context * ctx, struct ggml_cgraph * cgraph)
92849279

92859280
// create thread pool
92869281
ctx->tpool = thpool_init(n_threads);
9287-
for (int j = 0; j < n_threads - 1; j++) {
9288-
workers[j] = (struct ggml_compute_state) {
9289-
.params = {
9290-
.type = GGML_TASK_COMPUTE,
9291-
.ith = j + 1,
9292-
.nth = n_threads,
9293-
.wsize = cgraph->work ? ggml_nbytes(cgraph->work) : 0,
9294-
.wdata = cgraph->work ? cgraph->work->data : NULL,
9295-
},
9296-
.node = NULL,
9297-
};
9298-
}
92999282

93009283
// initialize tasks + work buffer
93019284
{

0 commit comments

Comments
 (0)