summaryrefslogtreecommitdiff
path: root/MLP/baselines/cpu/mlp_openmp.c
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2023-05-26 11:01:30 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2023-05-26 11:01:30 +0200
commit158bed0f093357150e80861eb731e6bc8fa77bdf (patch)
treefb9f87e6149b09f7b936f0ec2d7b6c7d4634ea20 /MLP/baselines/cpu/mlp_openmp.c
parent03b2d28986e0425c896ae99c196678107be7c222 (diff)
port MLP cpu baseline to dfatool
Diffstat (limited to 'MLP/baselines/cpu/mlp_openmp.c')
-rw-r--r--MLP/baselines/cpu/mlp_openmp.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/MLP/baselines/cpu/mlp_openmp.c b/MLP/baselines/cpu/mlp_openmp.c
index ef478c1..8f95e7c 100644
--- a/MLP/baselines/cpu/mlp_openmp.c
+++ b/MLP/baselines/cpu/mlp_openmp.c
@@ -14,6 +14,9 @@
#include "../../support/timer.h"
#include "../../support/common.h"
+#define XSTR(x) STR(x)
+#define STR(x) #x
+
T** A;
T* B;
T* C;
@@ -136,12 +139,31 @@ void usage() {
B = malloc(m_size*sizeof(unsigned int));
C = malloc(m_size*sizeof(unsigned int));
- // Create an input file with arbitrary data.
- init_data(A, B, m_size, n_size);
-
- start(&timer, 0, 1);
- mlp_host(C, A, B, n_size, m_size);
- stop(&timer, 0);
+ for (int i = 0; i < 100; i++) {
+ // Create an input file with arbitrary data.
+ init_data(A, B, m_size, n_size);
+
+ start(&timer, 0, 0);
+ mlp_host(C, A, B, n_size, m_size);
+ stop(&timer, 0);
+
+ unsigned int nr_threads = 0;
+#pragma omp parallel
+#pragma omp atomic
+ nr_threads++;
+
+ printf("[::] n_threads=%d e_type=%s n_elements=%lu "
+ "| throughput_cpu_omp_MBps=%f\n",
+ nr_threads, XSTR(T), n_size * m_size,
+ n_size * m_size * sizeof(T) / timer.time[0]);
+ printf("[::] n_threads=%d e_type=%s n_elements=%lu "
+ "| throughput_cpu_omp_MOpps=%f\n",
+ nr_threads, XSTR(T), n_size * m_size,
+ n_size * m_size / timer.time[0]);
+ printf("[::] n_threads=%d e_type=%s n_elements=%lu |",
+ nr_threads, XSTR(T), n_size * m_size);
+ printall(&timer, 0);
+ }
uint32_t sum = mlp_host_sum(n_size, m_size);