diff --git a/src/tools/OpenMP.cpp b/src/tools/OpenMP.cpp index e0a42d6a522ec4cd8070ec5eb961036d6a9b3967..353c515c4480997949d30c2a8108acc45717ea68 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 5b321752e8621c9bd62b61041241cad4fe2bfaed..644c8fec6cc044e2d2962dba2416c4b328cb1bbe 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();