@@ -1955,7 +1955,7 @@ typedef pthread_mutex_t ggml_mutex_t;
1955
1955
#endif
1956
1956
1957
1957
// Threadpool def
1958
- struct ggml_compute_threadpool {
1958
+ struct ggml_threadpool {
1959
1959
ggml_mutex_t mutex; // mutex for cond.var
1960
1960
ggml_cond_t cond; // cond.var for waiting for new work
1961
1961
@@ -1990,7 +1990,7 @@ struct ggml_compute_state {
1990
1990
int last_graph;
1991
1991
bool pending;
1992
1992
#endif
1993
- struct ggml_compute_threadpool * threadpool;
1993
+ struct ggml_threadpool * threadpool;
1994
1994
int ith;
1995
1995
};
1996
1996
@@ -2002,7 +2002,7 @@ struct ggml_compute_params {
2002
2002
size_t wsize;
2003
2003
void * wdata;
2004
2004
2005
- struct ggml_compute_threadpool * threadpool;
2005
+ struct ggml_threadpool * threadpool;
2006
2006
};
2007
2007
2008
2008
//
@@ -3110,15 +3110,15 @@ inline static void ggml_critical_section_start(void) {
3110
3110
}
3111
3111
3112
3112
#ifdef GGML_USE_OPENMP
3113
- static void ggml_barrier(struct ggml_compute_threadpool * threadpool) {
3113
+ static void ggml_barrier(struct ggml_threadpool * threadpool) {
3114
3114
if (threadpool->n_threads_cur == 1) {
3115
3115
return;
3116
3116
}
3117
3117
3118
3118
#pragma omp barrier
3119
3119
}
3120
3120
#else
3121
- static void ggml_barrier(struct ggml_compute_threadpool * threadpool) {
3121
+ static void ggml_barrier(struct ggml_threadpool * threadpool) {
3122
3122
if (threadpool->n_threads_cur == 1) {
3123
3123
return;
3124
3124
}
@@ -18837,7 +18837,7 @@ static void ggml_thread_cpumask_next(const bool * global_mask, bool * local_mask
18837
18837
}
18838
18838
}
18839
18839
18840
- void ggml_release_threadpool (struct ggml_compute_threadpool * threadpool) {
18840
+ void ggml_threadpool_release (struct ggml_threadpool * threadpool) {
18841
18841
if (!threadpool) return;
18842
18842
18843
18843
#ifndef GGML_USE_OPENMP
@@ -18868,36 +18868,36 @@ void ggml_release_threadpool(struct ggml_compute_threadpool* threadpool) {
18868
18868
18869
18869
#ifndef GGML_USE_OPENMP
18870
18870
// pause/resume must be called under mutex
18871
- static void ggml_pause_threadpool_locked (struct ggml_compute_threadpool * threadpool) {
18871
+ static void ggml_threadpool_pause_locked (struct ggml_threadpool * threadpool) {
18872
18872
GGML_PRINT_DEBUG("Pausing threadpool\n");
18873
18873
threadpool->pause = true;
18874
18874
ggml_cond_broadcast(&threadpool->cond);
18875
18875
}
18876
18876
18877
- static void ggml_resume_threadpool_locked (struct ggml_compute_threadpool * threadpool) {
18877
+ static void ggml_threadpool_resume_locked (struct ggml_threadpool * threadpool) {
18878
18878
GGML_PRINT_DEBUG("Resuming threadpool\n");
18879
18879
threadpool->pause = false;
18880
18880
ggml_cond_broadcast(&threadpool->cond);
18881
18881
}
18882
18882
#endif
18883
18883
18884
- void ggml_pause_threadpool (struct ggml_compute_threadpool * threadpool) {
18884
+ void ggml_threadpool_pause (struct ggml_threadpool * threadpool) {
18885
18885
#ifndef GGML_USE_OPENMP
18886
18886
ggml_mutex_lock(&threadpool->mutex);
18887
18887
if (!threadpool->pause) {
18888
- ggml_pause_threadpool_locked (threadpool);
18888
+ ggml_threadpool_pause_locked (threadpool);
18889
18889
}
18890
18890
ggml_mutex_unlock(&threadpool->mutex);
18891
18891
#else
18892
18892
UNUSED(threadpool);
18893
18893
#endif
18894
18894
}
18895
18895
18896
- void ggml_resume_threadpool (struct ggml_compute_threadpool * threadpool) {
18896
+ void ggml_threadpool_resume (struct ggml_threadpool * threadpool) {
18897
18897
#ifndef GGML_USE_OPENMP
18898
18898
ggml_mutex_lock(&threadpool->mutex);
18899
18899
if (threadpool->pause) {
18900
- ggml_resume_threadpool_locked (threadpool);
18900
+ ggml_threadpool_resume_locked (threadpool);
18901
18901
}
18902
18902
ggml_mutex_unlock(&threadpool->mutex);
18903
18903
#else
@@ -18908,7 +18908,7 @@ void ggml_resume_threadpool(struct ggml_compute_threadpool * threadpool) {
18908
18908
struct ggml_cplan ggml_graph_plan(
18909
18909
const struct ggml_cgraph * cgraph,
18910
18910
int n_threads,
18911
- struct ggml_compute_threadpool * threadpool) {
18911
+ struct ggml_threadpool * threadpool) {
18912
18912
18913
18913
if (threadpool == NULL) {
18914
18914
GGML_PRINT_DEBUG("Threadpool is not specified. Will create a disposable threadpool : n_threads %d\n", n_threads);
@@ -19119,7 +19119,7 @@ static thread_ret_t ggml_graph_compute_thread(void * data) {
19119
19119
#ifndef GGML_USE_OPENMP
19120
19120
19121
19121
static inline bool ggml_graph_compute_ready(struct ggml_compute_state * state) {
19122
- struct ggml_compute_threadpool * threadpool = state->threadpool;
19122
+ struct ggml_threadpool * threadpool = state->threadpool;
19123
19123
19124
19124
if (state->pending || threadpool->stop || threadpool->pause) { return true; }
19125
19125
@@ -19134,7 +19134,7 @@ static inline bool ggml_graph_compute_ready(struct ggml_compute_state * state) {
19134
19134
}
19135
19135
19136
19136
static inline bool ggml_graph_compute_poll_for_work(struct ggml_compute_state * state) {
19137
- struct ggml_compute_threadpool * threadpool = state->threadpool;
19137
+ struct ggml_threadpool * threadpool = state->threadpool;
19138
19138
19139
19139
// This seems to make 0 ... 100 a decent range for polling level across modern processors.
19140
19140
// Perhaps, we can adjust it dynamically based on load and things.
@@ -19149,7 +19149,7 @@ static inline bool ggml_graph_compute_poll_for_work(struct ggml_compute_state *
19149
19149
}
19150
19150
19151
19151
static inline bool ggml_graph_compute_check_for_work(struct ggml_compute_state * state) {
19152
- struct ggml_compute_threadpool * threadpool = state->threadpool;
19152
+ struct ggml_threadpool * threadpool = state->threadpool;
19153
19153
19154
19154
if (ggml_graph_compute_poll_for_work(state)) {
19155
19155
return state->pending;
@@ -19168,7 +19168,7 @@ static inline bool ggml_graph_compute_check_for_work(struct ggml_compute_state *
19168
19168
19169
19169
static thread_ret_t ggml_graph_compute_secondary_thread(void* data) {
19170
19170
struct ggml_compute_state * state = (struct ggml_compute_state *) data;
19171
- struct ggml_compute_threadpool * threadpool = state->threadpool;
19171
+ struct ggml_threadpool * threadpool = state->threadpool;
19172
19172
19173
19173
ggml_thread_apply_priority(threadpool->prio);
19174
19174
if (ggml_thread_cpumask_is_valid(state->cpumask)) {
@@ -19205,7 +19205,7 @@ static thread_ret_t ggml_graph_compute_secondary_thread(void* data) {
19205
19205
}
19206
19206
19207
19207
// Start processing new graph
19208
- static void ggml_graph_compute_kickoff(struct ggml_compute_threadpool * threadpool)
19208
+ static void ggml_graph_compute_kickoff(struct ggml_threadpool * threadpool)
19209
19209
{
19210
19210
// always take the mutex here because the worker threads are doing hybrid poll/wait
19211
19211
@@ -19221,7 +19221,7 @@ static void ggml_graph_compute_kickoff(struct ggml_compute_threadpool * threadpo
19221
19221
}
19222
19222
19223
19223
// resume does cond broadcast
19224
- ggml_resume_threadpool_locked (threadpool);
19224
+ ggml_threadpool_resume_locked (threadpool);
19225
19225
} else {
19226
19226
ggml_cond_broadcast(&threadpool->cond);
19227
19227
}
@@ -19254,13 +19254,13 @@ bool ggml_threadpool_params_match(const struct ggml_threadpool_params * p0, cons
19254
19254
return memcmp(p0->cpumask, p1->cpumask, GGML_MAX_N_THREADS) == 0;
19255
19255
}
19256
19256
19257
- static struct ggml_compute_threadpool * ggml_create_threadpool_impl (
19257
+ static struct ggml_threadpool * ggml_threadpool_create_impl (
19258
19258
struct ggml_threadpool_params * tpp,
19259
19259
struct ggml_cgraph * cgraph,
19260
19260
struct ggml_cplan * cplan) {
19261
19261
19262
- struct ggml_compute_threadpool * threadpool =
19263
- GGML_ALIGNED_MALLOC(sizeof(struct ggml_compute_threadpool ));
19262
+ struct ggml_threadpool * threadpool =
19263
+ GGML_ALIGNED_MALLOC(sizeof(struct ggml_threadpool ));
19264
19264
{
19265
19265
threadpool->cgraph = cgraph;
19266
19266
threadpool->cplan = cplan;
@@ -19320,8 +19320,8 @@ static struct ggml_compute_threadpool * ggml_create_threadpool_impl(
19320
19320
return threadpool;
19321
19321
}
19322
19322
19323
- struct ggml_compute_threadpool * ggml_create_threadpool (struct ggml_threadpool_params * tpp) {
19324
- return ggml_create_threadpool_impl (tpp, NULL, NULL);
19323
+ struct ggml_threadpool * ggml_threadpool_create (struct ggml_threadpool_params * tpp) {
19324
+ return ggml_threadpool_create_impl (tpp, NULL, NULL);
19325
19325
}
19326
19326
19327
19327
enum ggml_status ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cplan * cplan) {
@@ -19330,7 +19330,7 @@ enum ggml_status ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cpl
19330
19330
GGML_ASSERT(cplan->work_size == 0 || cplan->work_data != NULL);
19331
19331
19332
19332
int n_threads = cplan->n_threads;
19333
- struct ggml_compute_threadpool * threadpool = cplan->threadpool;
19333
+ struct ggml_threadpool * threadpool = cplan->threadpool;
19334
19334
19335
19335
bool disposable_threadpool = false;
19336
19336
@@ -19339,7 +19339,7 @@ enum ggml_status ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cpl
19339
19339
disposable_threadpool = true;
19340
19340
19341
19341
struct ggml_threadpool_params ttp = ggml_threadpool_params_default(n_threads);
19342
- threadpool = ggml_create_threadpool_impl (&ttp, cgraph, cplan);
19342
+ threadpool = ggml_threadpool_create_impl (&ttp, cgraph, cplan);
19343
19343
} else {
19344
19344
// Reset some of the parameters that need resetting
19345
19345
// No worker threads should be accessing the parameters below at this stage
@@ -19384,7 +19384,7 @@ enum ggml_status ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cpl
19384
19384
enum ggml_status ret = threadpool->ec;
19385
19385
19386
19386
if (disposable_threadpool) {
19387
- ggml_release_threadpool (threadpool);
19387
+ ggml_threadpool_release (threadpool);
19388
19388
}
19389
19389
19390
19390
return ret;
0 commit comments