@@ -1955,7 +1955,7 @@ typedef pthread_mutex_t ggml_mutex_t;
19551955#endif
19561956
19571957// Threadpool def
1958- struct ggml_compute_threadpool {
1958+ struct ggml_threadpool {
19591959 ggml_mutex_t mutex; // mutex for cond.var
19601960 ggml_cond_t cond; // cond.var for waiting for new work
19611961
@@ -1990,7 +1990,7 @@ struct ggml_compute_state {
19901990 int last_graph;
19911991 bool pending;
19921992#endif
1993- struct ggml_compute_threadpool * threadpool;
1993+ struct ggml_threadpool * threadpool;
19941994 int ith;
19951995};
19961996
@@ -2002,7 +2002,7 @@ struct ggml_compute_params {
20022002 size_t wsize;
20032003 void * wdata;
20042004
2005- struct ggml_compute_threadpool * threadpool;
2005+ struct ggml_threadpool * threadpool;
20062006};
20072007
20082008//
@@ -3110,15 +3110,15 @@ inline static void ggml_critical_section_start(void) {
31103110}
31113111
31123112#ifdef GGML_USE_OPENMP
3113- static void ggml_barrier(struct ggml_compute_threadpool * threadpool) {
3113+ static void ggml_barrier(struct ggml_threadpool * threadpool) {
31143114 if (threadpool->n_threads_cur == 1) {
31153115 return;
31163116 }
31173117
31183118 #pragma omp barrier
31193119}
31203120#else
3121- static void ggml_barrier(struct ggml_compute_threadpool * threadpool) {
3121+ static void ggml_barrier(struct ggml_threadpool * threadpool) {
31223122 if (threadpool->n_threads_cur == 1) {
31233123 return;
31243124 }
@@ -18837,7 +18837,7 @@ static void ggml_thread_cpumask_next(const bool * global_mask, bool * local_mask
1883718837 }
1883818838}
1883918839
18840- void ggml_release_threadpool (struct ggml_compute_threadpool * threadpool) {
18840+ void ggml_threadpool_release (struct ggml_threadpool * threadpool) {
1884118841 if (!threadpool) return;
1884218842
1884318843#ifndef GGML_USE_OPENMP
@@ -18868,36 +18868,36 @@ void ggml_release_threadpool(struct ggml_compute_threadpool* threadpool) {
1886818868
1886918869#ifndef GGML_USE_OPENMP
1887018870// 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) {
1887218872 GGML_PRINT_DEBUG("Pausing threadpool\n");
1887318873 threadpool->pause = true;
1887418874 ggml_cond_broadcast(&threadpool->cond);
1887518875}
1887618876
18877- static void ggml_resume_threadpool_locked (struct ggml_compute_threadpool * threadpool) {
18877+ static void ggml_threadpool_resume_locked (struct ggml_threadpool * threadpool) {
1887818878 GGML_PRINT_DEBUG("Resuming threadpool\n");
1887918879 threadpool->pause = false;
1888018880 ggml_cond_broadcast(&threadpool->cond);
1888118881}
1888218882#endif
1888318883
18884- void ggml_pause_threadpool (struct ggml_compute_threadpool * threadpool) {
18884+ void ggml_threadpool_pause (struct ggml_threadpool * threadpool) {
1888518885#ifndef GGML_USE_OPENMP
1888618886 ggml_mutex_lock(&threadpool->mutex);
1888718887 if (!threadpool->pause) {
18888- ggml_pause_threadpool_locked (threadpool);
18888+ ggml_threadpool_pause_locked (threadpool);
1888918889 }
1889018890 ggml_mutex_unlock(&threadpool->mutex);
1889118891#else
1889218892 UNUSED(threadpool);
1889318893#endif
1889418894}
1889518895
18896- void ggml_resume_threadpool (struct ggml_compute_threadpool * threadpool) {
18896+ void ggml_threadpool_resume (struct ggml_threadpool * threadpool) {
1889718897#ifndef GGML_USE_OPENMP
1889818898 ggml_mutex_lock(&threadpool->mutex);
1889918899 if (threadpool->pause) {
18900- ggml_resume_threadpool_locked (threadpool);
18900+ ggml_threadpool_resume_locked (threadpool);
1890118901 }
1890218902 ggml_mutex_unlock(&threadpool->mutex);
1890318903#else
@@ -18908,7 +18908,7 @@ void ggml_resume_threadpool(struct ggml_compute_threadpool * threadpool) {
1890818908struct ggml_cplan ggml_graph_plan(
1890918909 const struct ggml_cgraph * cgraph,
1891018910 int n_threads,
18911- struct ggml_compute_threadpool * threadpool) {
18911+ struct ggml_threadpool * threadpool) {
1891218912
1891318913 if (threadpool == NULL) {
1891418914 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) {
1911919119#ifndef GGML_USE_OPENMP
1912019120
1912119121static 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;
1912319123
1912419124 if (state->pending || threadpool->stop || threadpool->pause) { return true; }
1912519125
@@ -19134,7 +19134,7 @@ static inline bool ggml_graph_compute_ready(struct ggml_compute_state * state) {
1913419134}
1913519135
1913619136static 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;
1913819138
1913919139 // This seems to make 0 ... 100 a decent range for polling level across modern processors.
1914019140 // 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 *
1914919149}
1915019150
1915119151static 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;
1915319153
1915419154 if (ggml_graph_compute_poll_for_work(state)) {
1915519155 return state->pending;
@@ -19168,7 +19168,7 @@ static inline bool ggml_graph_compute_check_for_work(struct ggml_compute_state *
1916819168
1916919169static thread_ret_t ggml_graph_compute_secondary_thread(void* data) {
1917019170 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;
1917219172
1917319173 ggml_thread_apply_priority(threadpool->prio);
1917419174 if (ggml_thread_cpumask_is_valid(state->cpumask)) {
@@ -19205,7 +19205,7 @@ static thread_ret_t ggml_graph_compute_secondary_thread(void* data) {
1920519205}
1920619206
1920719207// 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)
1920919209{
1921019210 // always take the mutex here because the worker threads are doing hybrid poll/wait
1921119211
@@ -19221,7 +19221,7 @@ static void ggml_graph_compute_kickoff(struct ggml_compute_threadpool * threadpo
1922119221 }
1922219222
1922319223 // resume does cond broadcast
19224- ggml_resume_threadpool_locked (threadpool);
19224+ ggml_threadpool_resume_locked (threadpool);
1922519225 } else {
1922619226 ggml_cond_broadcast(&threadpool->cond);
1922719227 }
@@ -19254,13 +19254,13 @@ bool ggml_threadpool_params_match(const struct ggml_threadpool_params * p0, cons
1925419254 return memcmp(p0->cpumask, p1->cpumask, GGML_MAX_N_THREADS) == 0;
1925519255}
1925619256
19257- static struct ggml_compute_threadpool * ggml_create_threadpool_impl (
19257+ static struct ggml_threadpool * ggml_threadpool_create_impl (
1925819258 struct ggml_threadpool_params * tpp,
1925919259 struct ggml_cgraph * cgraph,
1926019260 struct ggml_cplan * cplan) {
1926119261
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 ));
1926419264 {
1926519265 threadpool->cgraph = cgraph;
1926619266 threadpool->cplan = cplan;
@@ -19320,8 +19320,8 @@ static struct ggml_compute_threadpool * ggml_create_threadpool_impl(
1932019320 return threadpool;
1932119321}
1932219322
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);
1932519325}
1932619326
1932719327enum 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
1933019330 GGML_ASSERT(cplan->work_size == 0 || cplan->work_data != NULL);
1933119331
1933219332 int n_threads = cplan->n_threads;
19333- struct ggml_compute_threadpool * threadpool = cplan->threadpool;
19333+ struct ggml_threadpool * threadpool = cplan->threadpool;
1933419334
1933519335 bool disposable_threadpool = false;
1933619336
@@ -19339,7 +19339,7 @@ enum ggml_status ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cpl
1933919339 disposable_threadpool = true;
1934019340
1934119341 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);
1934319343 } else {
1934419344 // Reset some of the parameters that need resetting
1934519345 // 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
1938419384 enum ggml_status ret = threadpool->ec;
1938519385
1938619386 if (disposable_threadpool) {
19387- ggml_release_threadpool (threadpool);
19387+ ggml_threadpool_release (threadpool);
1938819388 }
1938919389
1939019390 return ret;
0 commit comments