From d0e1fb1bd8272cd02db913807f216773bf215bcb Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Thu, 28 Jun 2012 12:58:31 +0200
Subject: [PATCH] [file SimpleTests/MatrixTests/MatMult.cpp] - analyse work per
 core employing OpenMP

---
 SimpleTests/MatrixTests/MatMult.cpp | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/SimpleTests/MatrixTests/MatMult.cpp b/SimpleTests/MatrixTests/MatMult.cpp
index 5b51b579f25..9b1dc8fb162 100644
--- a/SimpleTests/MatrixTests/MatMult.cpp
+++ b/SimpleTests/MatrixTests/MatMult.cpp
@@ -123,6 +123,27 @@ int main(int argc, char *argv[])
 	unsigned nnz(iA[n]);
 	INFO("\tParameters read: n=%d, nnz=%d", n, nnz);
 
+#ifdef _OPENMP
+	omp_set_num_threads(n_threads);
+	unsigned *mat_entries_per_core(new unsigned[n_threads]);
+	for (unsigned k(0); k<n_threads; k++) {
+		mat_entries_per_core[k] = 0;
+	}
+
+	OPENMP_LOOP_TYPE i;
+	{
+#pragma omp parallel for
+		for (i = 0; i < n; i++) {
+			mat_entries_per_core[omp_get_thread_num()] += iA[i + 1] - iA[i];
+		}
+	}
+
+	INFO("*** work per core ***");
+	for (unsigned k(0); k<n_threads; k++) {
+		INFO("\t%d\t%d", k, mat_entries_per_core[k]);
+	}
+#endif
+
 #ifdef _OPENMP
 	omp_set_num_threads(n_threads);
 	MathLib::CRSMatrixOpenMP<double, unsigned> mat (n, iA, jA, A);
-- 
GitLab