Skip to content

Commit c49d634

Browse files
threadpool: use _new and _free instead of _create and _release
1 parent cae35b9 commit c49d634

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

examples/llama-bench/llama-bench.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ int main(int argc, char ** argv) {
15311531
tpp.poll = t.poll;
15321532
tpp.prio = params.prio;
15331533

1534-
struct ggml_threadpool* threadpool = ggml_threadpool_create(&tpp);
1534+
struct ggml_threadpool* threadpool = ggml_threadpool_new(&tpp);
15351535
if (!threadpool) {
15361536
LOG_TEE("%s: threadpool create failed : n_threads %d\n", __func__, tpp.n_threads);
15371537
exit(1);
@@ -1578,7 +1578,7 @@ int main(int argc, char ** argv) {
15781578

15791579
llama_free(ctx);
15801580

1581-
ggml_threadpool_release(threadpool);
1581+
ggml_threadpool_free(threadpool);
15821582
}
15831583

15841584
llama_free_model(lmodel);

examples/main/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ int main(int argc, char ** argv) {
234234

235235
struct ggml_threadpool * threadpool_batch = NULL;
236236
if (!ggml_threadpool_params_match(&tpp, &tpp_batch)) {
237-
threadpool_batch = ggml_threadpool_create(&tpp_batch);
237+
threadpool_batch = ggml_threadpool_new(&tpp_batch);
238238
if (!threadpool_batch) {
239239
LOG_TEE("%s: batch threadpool create failed : n_threads %d\n", __func__, tpp_batch.n_threads);
240240
exit(1);
@@ -244,7 +244,7 @@ int main(int argc, char ** argv) {
244244
tpp.paused = true;
245245
}
246246

247-
struct ggml_threadpool * threadpool = ggml_threadpool_create(&tpp);
247+
struct ggml_threadpool * threadpool = ggml_threadpool_new(&tpp);
248248
if (!threadpool) {
249249
LOG_TEE("%s: threadpool create failed : n_threads %d\n", __func__, tpp.n_threads);
250250
exit(1);
@@ -1023,8 +1023,8 @@ int main(int argc, char ** argv) {
10231023
llama_sampling_free(ctx_sampling);
10241024
llama_backend_free();
10251025

1026-
ggml_threadpool_release(threadpool);
1027-
ggml_threadpool_release(threadpool_batch);
1026+
ggml_threadpool_free(threadpool);
1027+
ggml_threadpool_free(threadpool_batch);
10281028

10291029
#ifndef LOG_DISABLE_LOGS
10301030
LOG_TEE("Log end\n");

ggml/include/ggml.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,10 +2037,10 @@ extern "C" {
20372037
GGML_API size_t ggml_graph_overhead_custom(size_t size, bool grads);
20382038

20392039
GGML_API struct ggml_threadpool_params ggml_threadpool_params_default(int n_threads);
2040-
GGML_API void ggml_threadpool_params_init(struct ggml_threadpool_params *p, int n_threads);
2040+
GGML_API void ggml_threadpool_params_init (struct ggml_threadpool_params *p, int n_threads);
20412041
GGML_API bool ggml_threadpool_params_match (const struct ggml_threadpool_params *p0, const struct ggml_threadpool_params *p1);
2042-
GGML_API struct ggml_threadpool* ggml_threadpool_create (struct ggml_threadpool_params * params);
2043-
GGML_API void ggml_threadpool_release (struct ggml_threadpool * threadpool);
2042+
GGML_API struct ggml_threadpool* ggml_threadpool_new (struct ggml_threadpool_params * params);
2043+
GGML_API void ggml_threadpool_free (struct ggml_threadpool * threadpool);
20442044
GGML_API int ggml_threadpool_get_n_threads(struct ggml_threadpool * threadpool);
20452045
GGML_API void ggml_threadpool_pause (struct ggml_threadpool * threadpool);
20462046
GGML_API void ggml_threadpool_resume (struct ggml_threadpool * threadpool);

ggml/src/ggml.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18837,7 +18837,7 @@ static void ggml_thread_cpumask_next(const bool * global_mask, bool * local_mask
1883718837
}
1883818838
}
1883918839

18840-
void ggml_threadpool_release(struct ggml_threadpool* threadpool) {
18840+
void ggml_threadpool_free(struct ggml_threadpool* threadpool) {
1884118841
if (!threadpool) return;
1884218842

1884318843
#ifndef GGML_USE_OPENMP
@@ -19254,7 +19254,7 @@ 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_threadpool * ggml_threadpool_create_impl(
19257+
static struct ggml_threadpool * ggml_threadpool_new_impl(
1925819258
struct ggml_threadpool_params * tpp,
1925919259
struct ggml_cgraph * cgraph,
1926019260
struct ggml_cplan * cplan) {
@@ -19320,8 +19320,8 @@ static struct ggml_threadpool * ggml_threadpool_create_impl(
1932019320
return threadpool;
1932119321
}
1932219322

19323-
struct ggml_threadpool * ggml_threadpool_create(struct ggml_threadpool_params * tpp) {
19324-
return ggml_threadpool_create_impl(tpp, NULL, NULL);
19323+
struct ggml_threadpool * ggml_threadpool_new(struct ggml_threadpool_params * tpp) {
19324+
return ggml_threadpool_new_impl(tpp, NULL, NULL);
1932519325
}
1932619326

1932719327
enum ggml_status ggml_graph_compute(struct ggml_cgraph * cgraph, struct ggml_cplan * cplan) {
@@ -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_threadpool_create_impl(&ttp, cgraph, cplan);
19342+
threadpool = ggml_threadpool_new_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_threadpool_release(threadpool);
19387+
ggml_threadpool_free(threadpool);
1938819388
}
1938919389

1939019390
return ret;

0 commit comments

Comments
 (0)