Skip to content
This repository was archived by the owner on May 25, 2025. It is now read-only.

Commit b10834c

Browse files
committed
tests : allow to set threads to test-grad0
1 parent c1bb712 commit b10834c

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ jobs:
2222
steps:
2323
- uses: actions/checkout@v2
2424

25-
- name: Set GGML_NTHREADS for Ubuntu
26-
run: echo "GGML_NTHREADS=2" >> $GITHUB_ENV
25+
- name: Set GGML_N_THREADS for Ubuntu
26+
run: echo "GGML_N_THREADS=2" >> $GITHUB_ENV
2727
if: matrix.os == 'ubuntu-latest'
2828

29-
- name: Set GGML_NTHREADS for MacOS
30-
run: echo "GGML_NTHREADS=3" >> $GITHUB_ENV
29+
- name: Set GGML_N_THREADS for MacOS
30+
run: echo "GGML_N_THREADS=2" >> $GITHUB_ENV
3131
if: matrix.os == 'macos-latest'
3232

3333
- name: Create Build Environment

tests/test-grad0.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,23 @@ bool check_gradient(
202202
float max_error_abs,
203203
float max_error_rel) {
204204

205+
static int n_threads = -1;
206+
if (n_threads < 0) {
207+
n_threads = GGML_DEFAULT_N_THREADS;
208+
209+
const char *env = getenv("GGML_N_THREADS");
210+
if (env) {
211+
n_threads = atoi(env);
212+
}
213+
214+
printf("GGML_N_THREADS = %d\n", n_threads);
215+
}
216+
205217
struct ggml_cgraph gf = ggml_build_forward (f);
218+
gf.n_threads = n_threads;
219+
206220
struct ggml_cgraph gb = ggml_build_backward(ctx0, &gf, false);
221+
gb.n_threads = n_threads;
207222

208223
ggml_graph_compute(ctx0, &gf);
209224
ggml_graph_reset (&gf);

0 commit comments

Comments
 (0)