Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 : Copyright (c) 2014-2018 The plumed team
3 : (see the PEOPLE file at the root of the distribution for a list of names)
4 :
5 : See http://www.plumed.org for more information.
6 :
7 : This file is part of plumed, version 2.
8 :
9 : plumed is free software: you can redistribute it and/or modify
10 : it under the terms of the GNU Lesser General Public License as published by
11 : the Free Software Foundation, either version 3 of the License, or
12 : (at your option) any later version.
13 :
14 : plumed is distributed in the hope that it will be useful,
15 : but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : GNU Lesser General Public License for more details.
18 :
19 : You should have received a copy of the GNU Lesser General Public License
20 : along with plumed. If not, see <http://www.gnu.org/licenses/>.
21 : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
22 :
23 : #include "OpenMP.h"
24 : #include "Tools.h"
25 : #include <cstdlib>
26 : #if defined(_OPENMP)
27 : #include <omp.h>
28 : #endif
29 :
30 : namespace PLMD {
31 :
32 38458 : unsigned OpenMP::getCachelineSize() {
33 : static unsigned cachelineSize=512;
34 38458 : if(std::getenv("PLUMED_CACHELINE_SIZE")) Tools::convert(std::getenv("PLUMED_CACHELINE_SIZE"),cachelineSize);
35 38458 : return cachelineSize;
36 : }
37 :
38 183110 : unsigned OpenMP::getNumThreads() {
39 : static unsigned numThreads=1;
40 183110 : if(std::getenv("PLUMED_NUM_THREADS")) Tools::convert(std::getenv("PLUMED_NUM_THREADS"),numThreads);
41 183110 : return numThreads;
42 : }
43 :
44 1247872 : unsigned OpenMP::getThreadNum() {
45 : #if defined(_OPENMP)
46 1247872 : return omp_get_thread_num();
47 : #else
48 : return 0;
49 : #endif
50 : }
51 :
52 :
53 :
54 2523 : }
55 :
56 :
57 :
|