summaryrefslogtreecommitdiff
path: root/GEMV/baselines
diff options
context:
space:
mode:
Diffstat (limited to 'GEMV/baselines')
-rw-r--r--GEMV/baselines/cpu/Makefile27
-rw-r--r--GEMV/baselines/cpu/gemv_openmp.c64
-rwxr-xr-xGEMV/baselines/cpu/run.sh13
3 files changed, 74 insertions, 30 deletions
diff --git a/GEMV/baselines/cpu/Makefile b/GEMV/baselines/cpu/Makefile
index c779651..6f369a7 100644
--- a/GEMV/baselines/cpu/Makefile
+++ b/GEMV/baselines/cpu/Makefile
@@ -1,7 +1,26 @@
-all:
- gcc -o gemv -fopenmp gemv_openmp.c
+.PHONY: all
+all: gemv
-clean:
- rm gemv
+gemv: gemv_openmp.c
+ gcc -O2 -o gemv -fopenmp gemv_openmp.c
+
+gemv_O0: gemv_openmp.c
+ gcc -o gemv_O0 -fopenmp gemv_openmp.c
+
+gemv_O2: gemv_openmp.c
+ gcc -O2 -o gemv_O2 -fopenmp gemv_openmp.c
+
+.PHONY: run run_O0 run_O2
+run: gemv
+ ./gemv
+run_O0: gemv_O0
+ ./gemv_O0
+
+run_O2: gemv_O2
+ ./gemv_O2
+
+.PHONY: clean
+clean:
+ rm -f gemv gemv_O0 gemv_O2
diff --git a/GEMV/baselines/cpu/gemv_openmp.c b/GEMV/baselines/cpu/gemv_openmp.c
index 307e03b..69c3ae1 100644
--- a/GEMV/baselines/cpu/gemv_openmp.c
+++ b/GEMV/baselines/cpu/gemv_openmp.c
@@ -5,43 +5,55 @@
int main(int argc, char *argv[])
{
- const size_t rows = 20480;
- const size_t cols = 8192;
+ const size_t rows = 20480;
+ const size_t cols = 8192;
- double **A, *b, *x;
+ double **A, *b, *x;
- b = (double*) malloc(sizeof(double)*rows);
- x = (double*) malloc(sizeof(double)*cols);
+ b = (double*) malloc(sizeof(double)*rows);
+ x = (double*) malloc(sizeof(double)*cols);
- allocate_dense(rows, cols, &A);
+ allocate_dense(rows, cols, &A);
- make_hilbert_mat(rows,cols, &A);
+ make_hilbert_mat(rows,cols, &A);
+
+ Timer timer;
+ for (int i = 0; i < 100; i++) {
#pragma omp parallel
- {
+ {
#pragma omp for
- for (size_t i = 0; i < cols; i++) {
- x[i] = (double) i+1 ;
- }
+ for (size_t i = 0; i < cols; i++) {
+ x[i] = (double) i+1 ;
+ }
#pragma omp for
- for (size_t i = 0; i < rows; i++) {
- b[i] = (double) 0.0;
- }
- }
-
- Timer timer;
- start(&timer, 0, 0);
-
-
- gemv(A, x, rows, cols, &b);
-
- stop(&timer, 0);
+ for (size_t i = 0; i < rows; i++) {
+ b[i] = (double) 0.0;
+ }
+ }
+ unsigned int nr_threads = 0;
+#pragma omp parallel
+#pragma omp atomic
+ nr_threads++;
+
+ start(&timer, 0, 0);
+ gemv(A, x, rows, cols, &b);
+ stop(&timer, 0);
+ printf("[::] n_threads=%d e_type=%s n_elements=%d "
+ "| throughput_cpu_omp_MBps=%f\n",
+ nr_threads, "double", rows * cols,
+ rows * cols * sizeof(double) / timer.time[0]);
+ printf("[::] n_threads=%d e_type=%s n_elements=%d "
+ "| throughput_cpu_omp_MOpps=%f\n",
+ nr_threads, "double", rows * cols,
+ rows * cols / timer.time[0]);
+ printf("[::] n_threads=%d e_type=%s n_elements=%d |",
+ nr_threads, "double", rows * cols);
+ printall(&timer, 0);
+ }
- printf("Kernel ");
- print(&timer, 0, 1);
- printf("\n");
#if 0
print_vec(x, rows);
diff --git a/GEMV/baselines/cpu/run.sh b/GEMV/baselines/cpu/run.sh
new file mode 100755
index 0000000..8f936a3
--- /dev/null
+++ b/GEMV/baselines/cpu/run.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+set -e
+
+echo "prim-benchmarks GEMV 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
+ OMP_NUM_THREADS=${nr_threads} timeout --foreground -k 1m 30m ./gemv || true
+done