@@ -15941,13 +15941,13 @@ void clear_numa_thread_affinity(void) {}
15941
15941
#endif
15942
15942
15943
15943
struct ggml_compute_state_shared {
15944
- struct ggml_cgraph * cgraph;
15945
- struct ggml_graph_compute_plan * cgraph_ctx ;
15944
+ const struct ggml_cgraph * cgraph;
15945
+ const struct ggml_graph_compute_plan * plan ;
15946
15946
15947
15947
int64_t perf_node_start_cycles;
15948
15948
int64_t perf_node_start_time_us;
15949
15949
15950
- int n_threads;
15950
+ const int n_threads;
15951
15951
15952
15952
// synchronization primitives
15953
15953
atomic_int n_active; // num active threads
@@ -15971,10 +15971,10 @@ static void ggml_graph_compute_perf_stats_node(struct ggml_tensor * node, const
15971
15971
15972
15972
static thread_ret_t ggml_graph_compute_thread(void * data) {
15973
15973
struct ggml_compute_state * state = (struct ggml_compute_state *) data;
15974
- struct ggml_cgraph * cgraph = state->shared->cgraph;
15974
+ const struct ggml_cgraph * cgraph = state->shared->cgraph;
15975
15975
15976
- struct ggml_graph_compute_plan * ctx = state->shared->cgraph_ctx ;
15977
- const int *n_tasks_arr = ctx ->n_tasks;
15976
+ const struct ggml_graph_compute_plan * plan = state->shared->plan ;
15977
+ const int *n_tasks_arr = plan ->n_tasks;
15978
15978
15979
15979
const int n_threads = state->shared->n_threads;
15980
15980
set_numa_thread_affinity(state->ith, n_threads);
@@ -15989,8 +15989,8 @@ static thread_ret_t ggml_graph_compute_thread(void * data) {
15989
15989
/*.type =*/ GGML_TASK_FINALIZE,
15990
15990
/*.ith =*/ 0,
15991
15991
/*.nth =*/ 0,
15992
- /*.wsize =*/ ctx ->work_size,
15993
- /*.wdata =*/ ctx ->work_data,
15992
+ /*.wsize =*/ plan ->work_size,
15993
+ /*.wdata =*/ plan ->work_data,
15994
15994
};
15995
15995
15996
15996
if (node_n != -1) {
@@ -16059,8 +16059,8 @@ static thread_ret_t ggml_graph_compute_thread(void * data) {
16059
16059
/*.type =*/ GGML_TASK_COMPUTE,
16060
16060
/*.ith =*/ state->ith,
16061
16061
/*.nth =*/ n_tasks,
16062
- /*.wsize =*/ ctx ->work_size,
16063
- /*.wdata =*/ ctx ->work_data,
16062
+ /*.wsize =*/ plan ->work_size,
16063
+ /*.wdata =*/ plan ->work_data,
16064
16064
};
16065
16065
16066
16066
if (state->ith < n_tasks) {
@@ -16077,9 +16077,9 @@ struct ggml_graph_compute_plan ggml_graph_compute_make_plan(struct ggml_cgraph *
16077
16077
n_threads = GGML_DEFAULT_N_THREADS;
16078
16078
}
16079
16079
16080
- struct ggml_graph_compute_plan ctx ;
16081
- memset(&ctx , 0, sizeof(struct ggml_graph_compute_plan));
16082
- int * n_tasks = ctx .n_tasks;
16080
+ struct ggml_graph_compute_plan plan ;
16081
+ memset(&plan , 0, sizeof(struct ggml_graph_compute_plan));
16082
+ int * n_tasks = plan .n_tasks;
16083
16083
size_t work_size = 0;
16084
16084
16085
16085
// initialize tasks + work buffer
@@ -16403,35 +16403,35 @@ struct ggml_graph_compute_plan ggml_graph_compute_make_plan(struct ggml_cgraph *
16403
16403
work_size += CACHE_LINE_SIZE*(n_threads - 1);
16404
16404
}
16405
16405
16406
- ctx .n_threads = n_threads;
16407
- ctx .work_size = work_size;
16408
- ctx .work_data = NULL;
16406
+ plan .n_threads = n_threads;
16407
+ plan .work_size = work_size;
16408
+ plan .work_data = NULL;
16409
16409
16410
- return ctx ;
16410
+ return plan ;
16411
16411
}
16412
16412
16413
- void ggml_graph_compute(struct ggml_graph_compute_plan * ctx , struct ggml_cgraph * cgraph) {
16413
+ void ggml_graph_compute(struct ggml_graph_compute_plan * plan , struct ggml_cgraph * cgraph) {
16414
16414
{
16415
- GGML_ASSERT(ctx );
16416
- GGML_ASSERT(ctx ->n_threads > 0);
16415
+ GGML_ASSERT(plan );
16416
+ GGML_ASSERT(plan ->n_threads > 0);
16417
16417
16418
- if (ctx ->work_size > 0) {
16419
- GGML_ASSERT(ctx ->work_data);
16418
+ if (plan ->work_size > 0) {
16419
+ GGML_ASSERT(plan ->work_data);
16420
16420
}
16421
16421
16422
16422
for (int i = 0; i < cgraph->n_nodes; ++i) {
16423
16423
if (cgraph->nodes[i]->op != GGML_OP_NONE) {
16424
- GGML_ASSERT(ctx ->n_tasks[i] > 0);
16424
+ GGML_ASSERT(plan ->n_tasks[i] > 0);
16425
16425
}
16426
16426
}
16427
16427
16428
16428
}
16429
16429
16430
- const int n_threads = ctx ->n_threads;
16430
+ const int n_threads = plan ->n_threads;
16431
16431
16432
16432
struct ggml_compute_state_shared state_shared = {
16433
16433
/*.cgraph =*/ cgraph,
16434
- /*.cgraph_ctx =*/ ctx ,
16434
+ /*.cgraph_plan =*/ plan ,
16435
16435
/*.perf_node_start_cycles =*/ 0,
16436
16436
/*.perf_node_start_time_us =*/ 0,
16437
16437
/*.n_threads =*/ n_threads,
0 commit comments