Skip to content

Commit f0dc257

Browse files
committed
minor: rename ctx as plan; const
1 parent e052bc4 commit f0dc257

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

ggml.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16773,13 +16773,13 @@ void clear_numa_thread_affinity(void) {}
1677316773
#endif
1677416774

1677516775
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;
1677816778

1677916779
int64_t perf_node_start_cycles;
1678016780
int64_t perf_node_start_time_us;
1678116781

16782-
int n_threads;
16782+
const int n_threads;
1678316783

1678416784
// synchronization primitives
1678516785
atomic_int n_active; // num active threads
@@ -16803,10 +16803,10 @@ static void ggml_graph_compute_perf_stats_node(struct ggml_tensor * node, const
1680316803

1680416804
static thread_ret_t ggml_graph_compute_thread(void * data) {
1680516805
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;
1680716807

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;
1681016810

1681116811
const int n_threads = state->shared->n_threads;
1681216812
set_numa_thread_affinity(state->ith, n_threads);
@@ -16821,8 +16821,8 @@ static thread_ret_t ggml_graph_compute_thread(void * data) {
1682116821
/*.type =*/ GGML_TASK_FINALIZE,
1682216822
/*.ith =*/ 0,
1682316823
/*.nth =*/ 0,
16824-
/*.wsize =*/ ctx->work_size,
16825-
/*.wdata =*/ ctx->work_data,
16824+
/*.wsize =*/ plan->work_size,
16825+
/*.wdata =*/ plan->work_data,
1682616826
};
1682716827

1682816828
if (node_n != -1) {
@@ -16891,8 +16891,8 @@ static thread_ret_t ggml_graph_compute_thread(void * data) {
1689116891
/*.type =*/ GGML_TASK_COMPUTE,
1689216892
/*.ith =*/ state->ith,
1689316893
/*.nth =*/ n_tasks,
16894-
/*.wsize =*/ ctx->work_size,
16895-
/*.wdata =*/ ctx->work_data,
16894+
/*.wsize =*/ plan->work_size,
16895+
/*.wdata =*/ plan->work_data,
1689616896
};
1689716897

1689816898
if (state->ith < n_tasks) {
@@ -16909,9 +16909,9 @@ struct ggml_graph_compute_plan ggml_graph_compute_make_plan(struct ggml_cgraph *
1690916909
n_threads = GGML_DEFAULT_N_THREADS;
1691016910
}
1691116911

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;
1691516915
size_t work_size = 0;
1691616916

1691716917
// initialize tasks + work buffer
@@ -17251,35 +17251,35 @@ struct ggml_graph_compute_plan ggml_graph_compute_make_plan(struct ggml_cgraph *
1725117251
work_size += CACHE_LINE_SIZE*(n_threads - 1);
1725217252
}
1725317253

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;
1725717257

17258-
return ctx;
17258+
return plan;
1725917259
}
1726017260

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) {
1726217262
{
17263-
GGML_ASSERT(ctx);
17264-
GGML_ASSERT(ctx->n_threads > 0);
17263+
GGML_ASSERT(plan);
17264+
GGML_ASSERT(plan->n_threads > 0);
1726517265

17266-
if (ctx->work_size > 0) {
17267-
GGML_ASSERT(ctx->work_data);
17266+
if (plan->work_size > 0) {
17267+
GGML_ASSERT(plan->work_data);
1726817268
}
1726917269

1727017270
for (int i = 0; i < cgraph->n_nodes; ++i) {
1727117271
if (cgraph->nodes[i]->op != GGML_OP_NONE) {
17272-
GGML_ASSERT(ctx->n_tasks[i] > 0);
17272+
GGML_ASSERT(plan->n_tasks[i] > 0);
1727317273
}
1727417274
}
1727517275

1727617276
}
1727717277

17278-
const int n_threads = ctx->n_threads;
17278+
const int n_threads = plan->n_threads;
1727917279

1728017280
struct ggml_compute_state_shared state_shared = {
1728117281
/*.cgraph =*/ cgraph,
17282-
/*.cgraph_ctx =*/ ctx,
17282+
/*.cgraph_plan =*/ plan,
1728317283
/*.perf_node_start_cycles =*/ 0,
1728417284
/*.perf_node_start_time_us =*/ 0,
1728517285
/*.n_threads =*/ n_threads,

ggml.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@
6666
// ggml_set_f32(b, 4.0f);
6767
//
6868
// const int n_threads = 1;
69-
// struct ggml_graph_compute_plan ctx = ggml_graph_compute_make_plan(&gf, n_threads);
70-
// if (ctx.work_size > 0) {
71-
// ctx.work_data = malloc(ctx.work_size);
72-
// GGML_ASSERT(ctx.work_data);
69+
// struct ggml_graph_compute_plan plan = ggml_graph_compute_make_plan(&gf, n_threads);
70+
// if (plan.work_size > 0) {
71+
// plan.work_data = malloc(plan.work_size);
72+
// GGML_ASSERT(plan.work_data);
7373
// }
74-
// ggml_graph_compute(&ctx, &gf);
75-
// if (ctx.work_data) {
76-
// free(ctx.work_data);
74+
// ggml_graph_compute(&plan, &gf);
75+
// if (plan.work_data) {
76+
// free(plan.work_data);
7777
// }
7878
//
7979
// printf("f = %f\n", ggml_get_f32_1d(f, 0));

0 commit comments

Comments
 (0)