aboutsummaryrefslogtreecommitdiff
path: root/liblangdet
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-09-29 15:41:41 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-09-29 16:06:03 +0200
commit939b9a8deae07c2f06aa16c08f3ddad70f97b261 (patch)
tree00245f8e747349ddcca171be878e5ac19e8110a4 /liblangdet
parent91c6aa07597462705a7f30ee5b97e2c7943b5616 (diff)
downloadlangdet-master.tar.gz
langdet-master.zip
Add Linux OpenBLAS builds and Docker validationHEADmaster
Diffstat (limited to '')
-rw-r--r--liblangdet/langdet.c3
-rw-r--r--liblangdet/langdet.h2
-rw-r--r--liblangdet/threadpool.c3
3 files changed, 6 insertions, 2 deletions
diff --git a/liblangdet/langdet.c b/liblangdet/langdet.c
index 0fe5433..13a6359 100644
--- a/liblangdet/langdet.c
+++ b/liblangdet/langdet.c
@@ -143,8 +143,7 @@ int langdet_predict(langdet_t *d, const char *text, langdet_result_t *result,
if (!d || !text || !result)
return set_error(err, errlen, "Detector, text, and result must not be NULL");
- if (tp_num_threads() != d->n_threads)
- tp_set_threads(d->n_threads);
+ tp_set_threads(d->n_threads);
int count = 0;
int *ids = langdet_tokenize(d->tokenizer, text, &count);
if (!ids || count < 2) {
diff --git a/liblangdet/langdet.h b/liblangdet/langdet.h
index 22e0b64..d5cb9b3 100644
--- a/liblangdet/langdet.h
+++ b/liblangdet/langdet.h
@@ -28,6 +28,8 @@ typedef struct {
/* Load the model, tokenizer, classifier, and labels from model_dir.
* n_threads is 1..16, or 0 to detect the CPU count and cap it at 16.
+ * On macOS it sets kernel workers; Accelerate manages its own threads.
+ * On Linux it sets OpenBLAS threads; the auxiliary kernel pool stays serial.
* Return NULL on failure. An optional err[errlen] receives a NUL-terminated
* message on failure and is cleared on success. Model-file readers may also
* write diagnostics to stderr. */
diff --git a/liblangdet/threadpool.c b/liblangdet/threadpool.c
index 6cb4252..e0ffbc6 100644
--- a/liblangdet/threadpool.c
+++ b/liblangdet/threadpool.c
@@ -93,6 +93,9 @@ void tp_set_threads(int n) {
n = 1;
#endif
+ if (n == tp.n_threads)
+ return;
+
/* Shutdown existing workers */
if (tp.n_threads > 1) {
pthread_mutex_lock(&tp.mutex);