From: Georgi Gerganov Date: Sat, 24 Jun 2023 16:39:32 +0000 (+0300) Subject: tests : allow to set threads to test-grad0 X-Git-Tag: upstream/0.0.1642~1391 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=b10834c90e0a59427378436df8900bd7217e67bf;p=pkg%2Fggml%2Fsources%2Fggml tests : allow to set threads to test-grad0 --- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 070783c9..8332deff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/tests/test-grad0.c b/tests/test-grad0.c index b6371395..b5a499c1 100644 --- a/tests/test-grad0.c +++ b/tests/test-grad0.c @@ -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);