@@ -16773,13 +16773,13 @@ void clear_numa_thread_affinity(void) {}
16773
16773
#endif
16774
16774
16775
16775
struct ggml_compute_state_shared {
16776
- struct ggml_cgraph * cgraph;
16777
- struct ggml_graph_compute_plan * cgraph_ctx ;
16776
+ const struct ggml_cgraph * cgraph;
16777
+ const struct ggml_graph_compute_plan * plan ;
16778
16778
16779
16779
int64_t perf_node_start_cycles;
16780
16780
int64_t perf_node_start_time_us;
16781
16781
16782
- int n_threads;
16782
+ const int n_threads;
16783
16783
16784
16784
// synchronization primitives
16785
16785
atomic_int n_active; // num active threads
@@ -16803,10 +16803,10 @@ static void ggml_graph_compute_perf_stats_node(struct ggml_tensor * node, const
16803
16803
16804
16804
static thread_ret_t ggml_graph_compute_thread(void * data) {
16805
16805
struct ggml_compute_state * state = (struct ggml_compute_state *) data;
16806
- struct ggml_cgraph * cgraph = state->shared->cgraph;
16806
+ const struct ggml_cgraph * cgraph = state->shared->cgraph;
16807
16807
16808
- struct ggml_graph_compute_plan * ctx = state->shared->cgraph_ctx ;
16809
- const int *n_tasks_arr = ctx ->n_tasks;
16808
+ const struct ggml_graph_compute_plan * plan = state->shared->plan ;
16809
+ const int *n_tasks_arr = plan ->n_tasks;
16810
16810
16811
16811
const int n_threads = state->shared->n_threads;
16812
16812
set_numa_thread_affinity(state->ith, n_threads);
@@ -16821,8 +16821,8 @@ static thread_ret_t ggml_graph_compute_thread(void * data) {
16821
16821
/*.type =*/ GGML_TASK_FINALIZE,
16822
16822
/*.ith =*/ 0,
16823
16823
/*.nth =*/ 0,
16824
- /*.wsize =*/ ctx ->work_size,
16825
- /*.wdata =*/ ctx ->work_data,
16824
+ /*.wsize =*/ plan ->work_size,
16825
+ /*.wdata =*/ plan ->work_data,
16826
16826
};
16827
16827
16828
16828
if (node_n != -1) {
@@ -16891,8 +16891,8 @@ static thread_ret_t ggml_graph_compute_thread(void * data) {
16891
16891
/*.type =*/ GGML_TASK_COMPUTE,
16892
16892
/*.ith =*/ state->ith,
16893
16893
/*.nth =*/ n_tasks,
16894
- /*.wsize =*/ ctx ->work_size,
16895
- /*.wdata =*/ ctx ->work_data,
16894
+ /*.wsize =*/ plan ->work_size,
16895
+ /*.wdata =*/ plan ->work_data,
16896
16896
};
16897
16897
16898
16898
if (state->ith < n_tasks) {
@@ -16909,9 +16909,9 @@ struct ggml_graph_compute_plan ggml_graph_compute_make_plan(struct ggml_cgraph *
16909
16909
n_threads = GGML_DEFAULT_N_THREADS;
16910
16910
}
16911
16911
16912
- struct ggml_graph_compute_plan ctx ;
16913
- memset(&ctx , 0, sizeof(struct ggml_graph_compute_plan));
16914
- int * n_tasks = ctx .n_tasks;
16912
+ struct ggml_graph_compute_plan plan ;
16913
+ memset(&plan , 0, sizeof(struct ggml_graph_compute_plan));
16914
+ int * n_tasks = plan .n_tasks;
16915
16915
size_t work_size = 0;
16916
16916
16917
16917
// initialize tasks + work buffer
@@ -17251,35 +17251,35 @@ struct ggml_graph_compute_plan ggml_graph_compute_make_plan(struct ggml_cgraph *
17251
17251
work_size += CACHE_LINE_SIZE*(n_threads - 1);
17252
17252
}
17253
17253
17254
- ctx .n_threads = n_threads;
17255
- ctx .work_size = work_size;
17256
- ctx .work_data = NULL;
17254
+ plan .n_threads = n_threads;
17255
+ plan .work_size = work_size;
17256
+ plan .work_data = NULL;
17257
17257
17258
- return ctx ;
17258
+ return plan ;
17259
17259
}
17260
17260
17261
- void ggml_graph_compute(struct ggml_graph_compute_plan * ctx , struct ggml_cgraph * cgraph) {
17261
+ void ggml_graph_compute(struct ggml_graph_compute_plan * plan , struct ggml_cgraph * cgraph) {
17262
17262
{
17263
- GGML_ASSERT(ctx );
17264
- GGML_ASSERT(ctx ->n_threads > 0);
17263
+ GGML_ASSERT(plan );
17264
+ GGML_ASSERT(plan ->n_threads > 0);
17265
17265
17266
- if (ctx ->work_size > 0) {
17267
- GGML_ASSERT(ctx ->work_data);
17266
+ if (plan ->work_size > 0) {
17267
+ GGML_ASSERT(plan ->work_data);
17268
17268
}
17269
17269
17270
17270
for (int i = 0; i < cgraph->n_nodes; ++i) {
17271
17271
if (cgraph->nodes[i]->op != GGML_OP_NONE) {
17272
- GGML_ASSERT(ctx ->n_tasks[i] > 0);
17272
+ GGML_ASSERT(plan ->n_tasks[i] > 0);
17273
17273
}
17274
17274
}
17275
17275
17276
17276
}
17277
17277
17278
- const int n_threads = ctx ->n_threads;
17278
+ const int n_threads = plan ->n_threads;
17279
17279
17280
17280
struct ggml_compute_state_shared state_shared = {
17281
17281
/*.cgraph =*/ cgraph,
17282
- /*.cgraph_ctx =*/ ctx ,
17282
+ /*.cgraph_plan =*/ plan ,
17283
17283
/*.perf_node_start_cycles =*/ 0,
17284
17284
/*.perf_node_start_time_us =*/ 0,
17285
17285
/*.n_threads =*/ n_threads,
0 commit comments