diff options
author | Birte Kristina Friesel <birte.friesel@uos.de> | 2025-01-16 08:04:54 +0100 |
---|---|---|
committer | Birte Kristina Friesel <birte.friesel@uos.de> | 2025-01-16 08:04:54 +0100 |
commit | 4072fd2debd280cfa3401e193cf5ecc23a1dd4f3 (patch) | |
tree | a36f3fbe769e15ebe2ca6c1185fd8a6e76a7f24e | |
parent | 4afee0981b81b09104bba9745d09795b85957f27 (diff) |
BS baseline: Add valgrind-ws support
-rw-r--r-- | BS/baselines/cpu/Makefile | 9 | ||||
-rw-r--r-- | BS/baselines/cpu/bs_omp.c | 24 |
2 files changed, 31 insertions, 2 deletions
diff --git a/BS/baselines/cpu/Makefile b/BS/baselines/cpu/Makefile index 735fe84..4c30f65 100644 --- a/BS/baselines/cpu/Makefile +++ b/BS/baselines/cpu/Makefile @@ -1,10 +1,17 @@ +benchmark ?= 1 +debug ?= 0 native ?= 1 +nop_sync ?= 0 numa ?= 0 numa_memcpy ?= 0 CFLAGS = LDFLAGS = +ifeq (${debug}, 1) + CFLAGS += -g +endif + ifeq (${native}, 1) CFLAGS += -march=native endif @@ -17,7 +24,7 @@ endif all: bs_omp bs_omp: bs_omp.c - gcc -Wall -Wextra -pedantic -O3 ${CFLAGS} -DNUMA=${numa} -DNUMA_MEMCPY=${numa_memcpy} bs_omp.c -o bs_omp -fopenmp ${LDFLAGS} + gcc -Wall -Wextra -pedantic -O3 ${CFLAGS} -DNUMA=${numa} -DNUMA_MEMCPY=${numa_memcpy} -DNOP_SYNC=${nop_sync} -DWITH_BENCHMARK=${benchmark} bs_omp.c -o bs_omp -fopenmp ${LDFLAGS} bs_omp_O0: bs_omp.c gcc bs_omp.c -o bs_omp_O0 -fopenmp diff --git a/BS/baselines/cpu/bs_omp.c b/BS/baselines/cpu/bs_omp.c index d79ede8..871792d 100644 --- a/BS/baselines/cpu/bs_omp.c +++ b/BS/baselines/cpu/bs_omp.c @@ -7,7 +7,13 @@ #include <assert.h> #include <time.h> #include <stdint.h> + +#if WITH_BENCHMARK #include "timer.h" +#else +#define start(...) +#define stop(...) +#endif #if NUMA #include <numaif.h> @@ -92,7 +98,9 @@ uint64_t binarySearch(DTYPE * input, uint64_t input_size, DTYPE* querys, unsigne */ int main(int argc, char **argv) { (void)argc; +#if WITH_BENCHMARK Timer timer; +#endif uint64_t input_size = atol(argv[1]); uint64_t n_querys = atol(argv[2]); #if NUMA @@ -205,6 +213,12 @@ uint64_t binarySearch(DTYPE * input, uint64_t input_size, DTYPE* querys, unsigne } #endif +#if NOP_SYNC + for(int rep = 0; rep < 200000; rep++) { + asm volatile("nop" ::); + } +#endif + start(&timer, 0, 0); #if NUMA_MEMCPY result_host = binarySearch(input_local, input_size - 1, querys_local, n_querys); @@ -213,6 +227,12 @@ uint64_t binarySearch(DTYPE * input, uint64_t input_size, DTYPE* querys, unsigne #endif stop(&timer, 0); +#if NOP_SYNC + for(int rep = 0; rep < 200000; rep++) { + asm volatile("nop" ::); + } +#endif + #if NUMA_MEMCPY start(&timer, 3, 0); if (!numa_node_in_is_local) { @@ -222,12 +242,13 @@ uint64_t binarySearch(DTYPE * input, uint64_t input_size, DTYPE* querys, unsigne stop(&timer, 3); #endif + int status = (result_host); +#if WITH_BENCHMARK unsigned int nr_threads = 0; #pragma omp parallel #pragma omp atomic nr_threads++; - int status = (result_host); if (status) { #if NUMA_MEMCPY printf("[::] BS-CPU-MEMCPY | n_threads=%d e_type=%s n_elements=%lu" @@ -256,6 +277,7 @@ uint64_t binarySearch(DTYPE * input, uint64_t input_size, DTYPE* querys, unsigne } else { printf("[ERROR]\n"); } +#endif // WITH_BENCHMARK #if NUMA numa_free(input, input_size * sizeof(DTYPE)); |