]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
test-barrier : do not use more threads than physically available (#16389)
authorSigbjørn Skjæret <redacted>
Thu, 2 Oct 2025 18:10:12 +0000 (20:10 +0200)
committerGitHub <redacted>
Thu, 2 Oct 2025 18:10:12 +0000 (20:10 +0200)
* do not use more threads than physically available

* ensure n_threads > 0

Co-authored-by: Jeff Bolz <redacted>
---------

Co-authored-by: Jeff Bolz <redacted>
tests/test-barrier.cpp

index d85bf912b22e22a3f1a5da5459c5bb41cf165ccb..04c27761dc871d16da8e116b7bde63c4fb5417c3 100644 (file)
@@ -1,6 +1,5 @@
 #include "ggml.h"
 #include "ggml-cpu.h"
-#include "ggml-backend.h"
 
 #include <chrono>
 #include <iostream>
@@ -8,12 +7,13 @@
 #include <cstdlib>
 #include <cassert>
 #include <vector>
+#include <thread>
 
 #define MAX_NARGS 2
 
 int main(int argc, char *argv[]) {
 
-    int n_threads = 4;
+    int n_threads = std::max(1, std::min(4, (int) std::thread::hardware_concurrency()));
     int n_rounds  = 100;
 
     if (argc > 1) {