mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2024-12-31 22:04:35 +00:00
Simplify the logic of scheduling
This commit is contained in:
parent
6d18c6ea3e
commit
94ddd6204c
17
ggml.c
17
ggml.c
@ -9258,8 +9258,6 @@ struct ggml_compute_state {
|
|||||||
static void ggml_graph_compute_thread(void * data) {
|
static void ggml_graph_compute_thread(void * data) {
|
||||||
struct ggml_compute_state * state = (struct ggml_compute_state *) data;
|
struct ggml_compute_state * state = (struct ggml_compute_state *) data;
|
||||||
int type = state->params.type;
|
int type = state->params.type;
|
||||||
if (state->node) {
|
|
||||||
if (state->params.ith < state->params.nth) {
|
|
||||||
if (type == GGML_TASK_INIT)
|
if (type == GGML_TASK_INIT)
|
||||||
{
|
{
|
||||||
state->params.type = GGML_TASK_INIT;
|
state->params.type = GGML_TASK_INIT;
|
||||||
@ -9273,9 +9271,6 @@ static void ggml_graph_compute_thread(void * data) {
|
|||||||
ggml_compute_forward(&state->params, state->node);
|
ggml_compute_forward(&state->params, state->node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state->node = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ggml_graph_compute(struct ggml_context * ctx, struct ggml_cgraph * cgraph) {
|
void ggml_graph_compute(struct ggml_context * ctx, struct ggml_cgraph * cgraph) {
|
||||||
const int n_threads = cgraph->n_threads;
|
const int n_threads = cgraph->n_threads;
|
||||||
@ -9284,18 +9279,6 @@ void ggml_graph_compute(struct ggml_context * ctx, struct ggml_cgraph * cgraph)
|
|||||||
|
|
||||||
// create thread pool
|
// create thread pool
|
||||||
ctx->tpool = thpool_init(n_threads);
|
ctx->tpool = thpool_init(n_threads);
|
||||||
for (int j = 0; j < n_threads - 1; j++) {
|
|
||||||
workers[j] = (struct ggml_compute_state) {
|
|
||||||
.params = {
|
|
||||||
.type = GGML_TASK_COMPUTE,
|
|
||||||
.ith = j + 1,
|
|
||||||
.nth = n_threads,
|
|
||||||
.wsize = cgraph->work ? ggml_nbytes(cgraph->work) : 0,
|
|
||||||
.wdata = cgraph->work ? cgraph->work->data : NULL,
|
|
||||||
},
|
|
||||||
.node = NULL,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// initialize tasks + work buffer
|
// initialize tasks + work buffer
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user