Skip to content

Commit daa242d

Browse files
authored
common: fix return value check for setpriority (ggml-org#18412)
* common: fix return value check for setpriority * tools: add logging for process priority setting
1 parent e70e640 commit daa242d

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

common/common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ bool set_process_priority(enum ggml_sched_priority prio) {
251251
case GGML_SCHED_PRIO_REALTIME: p = -20; break;
252252
}
253253

254-
if (!setpriority(PRIO_PROCESS, 0, p)) {
254+
if (setpriority(PRIO_PROCESS, 0, p) != 0) {
255255
LOG_WRN("failed to set process priority %d : %s (%d)\n", prio, strerror(errno), errno);
256256
return false;
257257
}

tools/completion/completion.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@ int main(int argc, char ** argv) {
175175
struct ggml_threadpool_params tpp =
176176
ggml_threadpool_params_from_cpu_params(params.cpuparams);
177177

178-
set_process_priority(params.cpuparams.priority);
178+
if (!set_process_priority(params.cpuparams.priority)) {
179+
LOG_ERR("%s: error: failed to set process priority\n", __func__);
180+
return 1;
181+
}
179182

180183
struct ggml_threadpool * threadpool_batch = NULL;
181184
if (!ggml_threadpool_params_match(&tpp, &tpp_batch)) {

tools/llama-bench/llama-bench.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2037,7 +2037,10 @@ int main(int argc, char ** argv) {
20372037
llama_backend_init();
20382038
llama_numa_init(params.numa);
20392039

2040-
set_process_priority(params.prio);
2040+
if (!set_process_priority(params.prio)) {
2041+
fprintf(stderr, "%s: error: failed to set process priority\n", __func__);
2042+
return 1;
2043+
}
20412044

20422045
// initialize printer
20432046
std::unique_ptr<printer> p = create_printer(params.output_format);

0 commit comments

Comments
 (0)