Skip to content
Snippets Groups Projects
Commit 480ee424 authored by carlocamilloni's avatar carlocamilloni
Browse files

Merge branch 'v2.4' into v2.5

parents 9b443c39 318174e6
No related branches found
No related tags found
No related merge requests found
...@@ -203,6 +203,9 @@ For users: ...@@ -203,6 +203,9 @@ For users:
## Version 2.4.4 (to be released) ## Version 2.4.4 (to be released)
For users:
- Fix some performances regression issue with OpenMP
For developers: For developers:
- Small fix in LDFLAGS when enabling coverage. - Small fix in LDFLAGS when enabling coverage.
...@@ -29,16 +29,37 @@ ...@@ -29,16 +29,37 @@
namespace PLMD { namespace PLMD {
struct OpenMPVars {
unsigned cacheline_size=512;
bool cache_set=false;
unsigned num_threads=1;
bool nt_env_set=false;
};
static OpenMPVars & getOpenMPVars() {
static OpenMPVars vars;
return vars;
}
void OpenMP::setNumThreads(const unsigned nt) {
getOpenMPVars().num_threads=nt;
}
unsigned OpenMP::getCachelineSize() { unsigned OpenMP::getCachelineSize() {
static unsigned cachelineSize=512; if(!getOpenMPVars().cache_set) {
if(std::getenv("PLUMED_CACHELINE_SIZE")) Tools::convert(std::getenv("PLUMED_CACHELINE_SIZE"),cachelineSize); if(std::getenv("PLUMED_CACHELINE_SIZE")) Tools::convert(std::getenv("PLUMED_CACHELINE_SIZE"),getOpenMPVars().cacheline_size);
return cachelineSize; getOpenMPVars().cache_set = true;
}
return getOpenMPVars().cacheline_size;
} }
unsigned OpenMP::getNumThreads() { unsigned OpenMP::getNumThreads() {
static unsigned numThreads=1; if(!getOpenMPVars().nt_env_set) {
if(std::getenv("PLUMED_NUM_THREADS")) Tools::convert(std::getenv("PLUMED_NUM_THREADS"),numThreads); if(std::getenv("PLUMED_NUM_THREADS")) Tools::convert(std::getenv("PLUMED_NUM_THREADS"),getOpenMPVars().num_threads);
return numThreads; getOpenMPVars().nt_env_set = true;
}
return getOpenMPVars().num_threads;
} }
unsigned OpenMP::getThreadNum() { unsigned OpenMP::getThreadNum() {
......
...@@ -30,6 +30,9 @@ class OpenMP { ...@@ -30,6 +30,9 @@ class OpenMP {
public: public:
/// Set number of threads that can be used by openMP
static void setNumThreads(const unsigned nt);
/// Get number of threads that can be used by openMP /// Get number of threads that can be used by openMP
static unsigned getNumThreads(); static unsigned getNumThreads();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment