summaryrefslogtreecommitdiff
path: root/BS
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2023-05-25 15:27:21 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2023-05-25 15:27:21 +0200
commit9be82d39101398116c0974fd26a63956631df57b (patch)
treede330acec4e4739852b1766219c780885258c692 /BS
parent5c008581ebb873b04e68b38cdec619600b4bcb5d (diff)
port BS CPU to dfatool
Diffstat (limited to 'BS')
-rw-r--r--BS/baselines/cpu/Makefile27
-rw-r--r--BS/baselines/cpu/bs_omp.c18
-rwxr-xr-xBS/baselines/cpu/run.sh17
-rwxr-xr-xBS/baselines/cpu/timer.h7
-rwxr-xr-xBS/support/timer.h7
5 files changed, 70 insertions, 6 deletions
diff --git a/BS/baselines/cpu/Makefile b/BS/baselines/cpu/Makefile
index e907fc8..1b0ceb5 100644
--- a/BS/baselines/cpu/Makefile
+++ b/BS/baselines/cpu/Makefile
@@ -1,4 +1,25 @@
-all:
- gcc bs_omp.c -o bs_omp -fopenmp
-run:
+.PHONY: all
+all: bs_omp
+
+bs_omp: bs_omp.c
+ gcc -O2 bs_omp.c -o bs_omp -fopenmp
+
+bs_omp_O0: bs_omp.c
+ gcc bs_omp.c -o bs_omp_O0 -fopenmp
+
+bs_omp_O2: bs_omp.c
+ gcc -O2 bs_omp.c -o bs_omp_O2 -fopenmp
+
+.PHONY: run run_O0 run_O2
+run: bs_omp
./bs_omp 262144 16777216
+
+run_O0: bs_omp_O0
+ ./bs_omp_O0 262144 16777216
+
+run_O2: bs_omp_O2
+ ./bs_omp_O2 262144 16777216
+
+.PHONY: clean
+clean:
+ rm -f bs_omp bs_omp_O0 bs_omp_O2
diff --git a/BS/baselines/cpu/bs_omp.c b/BS/baselines/cpu/bs_omp.c
index 3ad83ed..b8b3023 100644
--- a/BS/baselines/cpu/bs_omp.c
+++ b/BS/baselines/cpu/bs_omp.c
@@ -93,12 +93,24 @@ uint64_t binarySearch(DTYPE * input, uint64_t input_size, DTYPE* querys, unsigne
result_host = binarySearch(input, input_size - 1, querys, n_querys);
stop(&timer, 0);
+ unsigned int nr_threads = 0;
+#pragma omp parallel
+#pragma omp atomic
+ nr_threads++;
int status = (result_host);
if (status) {
- printf("[OK] Execution time: ");
- print(&timer, 0, 1);
- printf("ms.\n");
+ printf("[::] n_threads=%d e_type=%s n_elements=%d "
+ "| throughput_cpu_omp_MBps=%f\n",
+ nr_threads, "uint64_t", input_size,
+ n_querys * sizeof(DTYPE) / timer.time[0]);
+ printf("[::] n_threads=%d e_type=%s n_elements=%d "
+ "| throughput_cpu_omp_MOpps=%f\n",
+ nr_threads, "uint64_t", input_size,
+ n_querys / timer.time[0]);
+ printf("[::] n_threads=%d e_type=%s n_elements=%d |",
+ nr_threads, "uint64_t", input_size);
+ printall(&timer, 0);
} else {
printf("[ERROR]\n");
}
diff --git a/BS/baselines/cpu/run.sh b/BS/baselines/cpu/run.sh
new file mode 100755
index 0000000..80c596c
--- /dev/null
+++ b/BS/baselines/cpu/run.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+set -e
+
+echo "prim-benchmarks BS CPU (dfatool edition)"
+echo "Started at $(date)"
+echo "Revision $(git describe --always)"
+
+make
+
+for nr_threads in 1 2 4 6 8 12 16 20 24 32; do
+ for vs in 262144 524288 1048576 2097152; do
+ for i in `seq 1 20`; do
+ OMP_NUM_THREADS=${nr_threads} timeout --foreground -k 1m 30m ./bs_omp ${vs} 16777216 || true
+ done
+ done
+done
diff --git a/BS/baselines/cpu/timer.h b/BS/baselines/cpu/timer.h
index 969ef97..08027af 100755
--- a/BS/baselines/cpu/timer.h
+++ b/BS/baselines/cpu/timer.h
@@ -57,3 +57,10 @@ void stop(Timer *timer, int i) {
}
void print(Timer *timer, int i, int REP) { printf("%f\t", timer->time[i] / (1000 * REP)); }
+
+void printall(Timer *timer, int maxt) {
+ for (int i = 0; i <= maxt; i++) {
+ printf(" timer%d_us=%f", i, timer->time[i]);
+ }
+ printf("\n");
+}
diff --git a/BS/support/timer.h b/BS/support/timer.h
index 969ef97..08027af 100755
--- a/BS/support/timer.h
+++ b/BS/support/timer.h
@@ -57,3 +57,10 @@ void stop(Timer *timer, int i) {
}
void print(Timer *timer, int i, int REP) { printf("%f\t", timer->time[i] / (1000 * REP)); }
+
+void printall(Timer *timer, int maxt) {
+ for (int i = 0; i <= maxt; i++) {
+ printf(" timer%d_us=%f", i, timer->time[i]);
+ }
+ printf("\n");
+}