Skip to content

Commit 57921ca

Browse files
Freed-Wuggerganov
andauthored
common : n_threads == -1 uses std::thread::hardware_concurrency() (#2347)
* Fix #2345, fix incorrect n_threads * Update examples/common.cpp --------- Co-authored-by: Georgi Gerganov <[email protected]>
1 parent 3602ac4 commit 57921ca

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

examples/common.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
117117
break;
118118
}
119119
params.n_threads = std::stoi(argv[i]);
120+
if (params.n_threads <= 0) {
121+
params.n_threads = std::thread::hardware_concurrency();
122+
}
120123
} else if (arg == "-p" || arg == "--prompt") {
121124
if (++i >= argc) {
122125
invalid_param = true;

0 commit comments

Comments
 (0)