From c07c6098c4fbe3a643d4124a0e5239c719fac468 Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Tue, 20 Jun 2017 11:21:27 +0200
Subject: [PATCH] omp

---
 src/tools/OpenMP.cpp | 12 ++++++++++++
 src/tools/OpenMP.h   |  3 +++
 2 files changed, 15 insertions(+)

diff --git a/src/tools/OpenMP.cpp b/src/tools/OpenMP.cpp
index e0a42d6a5..353c515c4 100644
--- a/src/tools/OpenMP.cpp
+++ b/src/tools/OpenMP.cpp
@@ -23,6 +23,9 @@
 #include "OpenMP.h"
 #include "Tools.h"
 #include <cstdlib>
+#if defined(_OPENMP)
+#include <omp.h>
+#endif
 
 namespace PLMD {
 
@@ -38,6 +41,15 @@ unsigned OpenMP::getNumThreads() {
   return numThreads;
 }
 
+unsigned OpenMP::getThreadNum() {
+#if defined(_OPENMP)
+  return omp_get_thread_num();
+#else
+  return 0;
+#endif
+}
+
+
 
 }
 
diff --git a/src/tools/OpenMP.h b/src/tools/OpenMP.h
index 5b321752e..644c8fec6 100644
--- a/src/tools/OpenMP.h
+++ b/src/tools/OpenMP.h
@@ -33,6 +33,9 @@ public:
 /// Get number of threads that can be used by openMP
   static unsigned getNumThreads();
 
+/// Returns a unique thread identification number within the current team
+  static unsigned getThreadNum();
+
 /// get cacheline size
   static unsigned getCachelineSize();
 
-- 
GitLab