Skip to content

Commit

Permalink
tests : allow to set threads to test-grad0
Browse files Browse the repository at this point in the history
  • Loading branch information
ggerganov committed Jun 24, 2023
1 parent c1bb712 commit b10834c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ jobs:
steps:
- uses: actions/checkout@v2

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

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

- name: Create Build Environment
Expand Down
15 changes: 15 additions & 0 deletions tests/test-grad0.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,23 @@ bool check_gradient(
float max_error_abs,
float max_error_rel) {

static int n_threads = -1;
if (n_threads < 0) {
n_threads = GGML_DEFAULT_N_THREADS;

const char *env = getenv("GGML_N_THREADS");
if (env) {
n_threads = atoi(env);
}

printf("GGML_N_THREADS = %d\n", n_threads);
}

struct ggml_cgraph gf = ggml_build_forward (f);
gf.n_threads = n_threads;

struct ggml_cgraph gb = ggml_build_backward(ctx0, &gf, false);
gb.n_threads = n_threads;

ggml_graph_compute(ctx0, &gf);
ggml_graph_reset (&gf);
Expand Down

0 comments on commit b10834c

Please sign in to comment.