From c104caa1a6a7ee701fbc0e745eaf4ab01cd5cf63 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 16 Nov 2022 17:50:41 +0100 Subject: [PATCH] Use `THREAD_COUNT` instead of a fixed amount of threads --- OpenMP/linear-algebra/kernels/atax/Makefile | 2 ++ OpenMP/linear-algebra/kernels/atax/atax.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/OpenMP/linear-algebra/kernels/atax/Makefile b/OpenMP/linear-algebra/kernels/atax/Makefile index 96c7b77..b499897 100644 --- a/OpenMP/linear-algebra/kernels/atax/Makefile +++ b/OpenMP/linear-algebra/kernels/atax/Makefile @@ -13,6 +13,8 @@ CFLAGS+= -Wextra CFLAGS+= -O3 # -g3 enables some useful debug things CFLAGS+= -g3 +# -DTHREAD_COUNT allows us to alter the number of threads used in the whole file +CFLAGS+= -DTHREAD_COUNT=4 # Disable make output MAKEFLAGS+= --silent diff --git a/OpenMP/linear-algebra/kernels/atax/atax.c b/OpenMP/linear-algebra/kernels/atax/atax.c index 84fde91..787db79 100644 --- a/OpenMP/linear-algebra/kernels/atax/atax.c +++ b/OpenMP/linear-algebra/kernels/atax/atax.c @@ -25,7 +25,7 @@ static void init_array(int nx, int ny, int i, j; /// Initialize the `x` array with PI and its multiples. - #pragma omp parallel for num_threads(4) schedule(static) + #pragma omp parallel for num_threads(THREAD_COUNT) schedule(static) for (i = 0; i < ny; i++) { x[i] = i * M_PI; } @@ -64,7 +64,7 @@ static void kernel_atax(int nx, int ny, { int i, j; - #pragma omp parallel for num_threads(4) schedule(static) + #pragma omp parallel for num_threads(THREAD_COUNT) schedule(static) for (i = 0; i < _PB_NY; i++) y[i] = 0;