mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rohit Jain <rohit.k.jain@oracle.com>
To: linux-kernel@vger.kernel.org
Cc: peterz@infradead.org, mingo@redhat.com
Subject: [PATCH 2/2] tools/testing: Adding tests to showcase the efficacy of IAS
Date: Fri, 12 May 2017 11:04:27 -0700	[thread overview]
Message-ID: <1494612267-29465-3-git-send-email-rohit.k.jain@oracle.com> (raw)
In-Reply-To: <1494612267-29465-1-git-send-email-rohit.k.jain@oracle.com>

This is a simple OpenMP program which does a barrier sync at the end of
each parallel for loop section.

Signed-off-by: Rohit Jain <rohit.k.jain@oracle.com>
---
 tools/testing/selftests/openmp_barrier/Makefile  |  6 +++++
 tools/testing/selftests/openmp_barrier/barrier.c | 29 ++++++++++++++++++++++++
 2 files changed, 35 insertions(+)
 create mode 100644 tools/testing/selftests/openmp_barrier/Makefile
 create mode 100644 tools/testing/selftests/openmp_barrier/barrier.c

diff --git a/tools/testing/selftests/openmp_barrier/Makefile b/tools/testing/selftests/openmp_barrier/Makefile
new file mode 100644
index 0000000..a6b4455
--- /dev/null
+++ b/tools/testing/selftests/openmp_barrier/Makefile
@@ -0,0 +1,6 @@
+CFLAGS += -m64 $(BUILD_FLAGS)
+LDFLAGS += -O -fopenmp
+
+TEST_GEN_PROGS = barrier
+
+include ../lib.mk
diff --git a/tools/testing/selftests/openmp_barrier/barrier.c b/tools/testing/selftests/openmp_barrier/barrier.c
new file mode 100644
index 0000000..6dccd24
--- /dev/null
+++ b/tools/testing/selftests/openmp_barrier/barrier.c
@@ -0,0 +1,29 @@
+#include <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#define TV2NS(tv)	((tv).tv_sec * 1000000000L + (tv).tv_usec * 1000L)
+
+void work(void)
+{
+	int i;
+	volatile int *p = &i;
+	for (*p = 0; *p < 1000000; (*p)++)
+		;
+}
+
+int main(int argc, char *argv[])
+{
+	struct timeval t1, t2;
+	long i, j, elapsed;
+	int n = (argc > 1 ? atoi(argv[1]) : 1000);
+	int nt = atoi(getenv("OMP_NUM_THREADS"));
+	gettimeofday(&t1, 0);
+
+	for (i = 0; i < n; i++)
+		#pragma omp parallel for
+		for (j = 0; j < nt; j++)
+			work();
+	gettimeofday(&t2, 0);
+	elapsed = TV2NS(t2) - TV2NS(t1);
+	printf("%.2f iters/sec\n", n / (elapsed / 1e9));
+}
-- 
2.7.4

      parent reply	other threads:[~2017-05-12 18:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-12 18:04 [PATCH 0/2] Interrupt Aware Scheduler Rohit Jain
2017-05-12 18:04 ` [PATCH 1/2] sched: " Rohit Jain
2017-05-12 19:46   ` Peter Zijlstra
2017-05-12 20:19     ` Rohit Jain
2017-05-17  7:52       ` Vincent Guittot
2017-05-18 17:24         ` Rohit Jain
2017-05-12 18:04 ` Rohit Jain [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1494612267-29465-3-git-send-email-rohit.k.jain@oracle.com \
    --to=rohit.k.jain@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®