* Revert "common: share thread pools when `n_threads` differ (#27138)"
This reverts commit 04b569142d.
Co-authored-by: Max Krasnyansky <maxk@qti.qualcomm.com>
* common: add comment about inability to share threadpool
---------
Co-authored-by: Max Krasnyansky <maxk@qti.qualcomm.com>
This commit is contained in:
co-authored by
Max Krasnyansky
parent
7221e24f57
commit
3e7344670a
+3
-15
@@ -1750,18 +1750,6 @@ struct ggml_threadpool_params ggml_threadpool_params_from_cpu_params(const commo
|
|||||||
return tpp;
|
return tpp;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
bool can_share_threadpool(const ggml_threadpool_params & tpp1, const ggml_threadpool_params & tpp2) {
|
|
||||||
// n_threads does not matter -> we'll use what's larger
|
|
||||||
ggml_threadpool_params tpp_comparison = tpp1;
|
|
||||||
tpp_comparison.n_threads = tpp2.n_threads;
|
|
||||||
|
|
||||||
return ggml_threadpool_params_match(&tpp_comparison, &tpp2);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
common_threadpools::~common_threadpools() {
|
common_threadpools::~common_threadpools() {
|
||||||
if (!free_fn) {
|
if (!free_fn) {
|
||||||
return;
|
return;
|
||||||
@@ -1790,9 +1778,9 @@ void common_threadpools::init(llama_context * ctx, const common_params & params)
|
|||||||
struct ggml_threadpool_params tpp =
|
struct ggml_threadpool_params tpp =
|
||||||
ggml_threadpool_params_from_cpu_params(params.cpuparams);
|
ggml_threadpool_params_from_cpu_params(params.cpuparams);
|
||||||
|
|
||||||
if (can_share_threadpool(tpp, tpp_batch)) {
|
// each pool needs to match the respective n_threads exactly
|
||||||
tpp.n_threads = std::max(tpp.n_threads, tpp_batch.n_threads);
|
// see: https://github.com/ggml-org/llama.cpp/pull/27138#issuecomment-5332307332
|
||||||
} else {
|
if (!ggml_threadpool_params_match(&tpp, &tpp_batch)) {
|
||||||
threadpool_batch = ggml_threadpool_new_fn(&tpp_batch);
|
threadpool_batch = ggml_threadpool_new_fn(&tpp_batch);
|
||||||
if (!threadpool_batch) {
|
if (!threadpool_batch) {
|
||||||
COM_WRN("batch threadpool create failed : n_threads %d\n", tpp_batch.n_threads);
|
COM_WRN("batch threadpool create failed : n_threads %d\n", tpp_batch.n_threads);
|
||||||
|
|||||||
Reference in New Issue
Block a user