QMCPACK
Info.hpp
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source
3 // License. See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2020 QMCPACK developers.
6 //
7 // File developed by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab
8 // Ye Luo, yeluo@anl.gov, Argonne National Laboratory
9 //
10 // File created by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab
11 ////////////////////////////////////////////////////////////////////////////////
12 
13 
14 #ifndef QMCPLUSPLUS_CONCURRENCY_INFO_HPP
15 #define QMCPLUSPLUS_CONCURRENCY_INFO_HPP
16 /** @file
17  * @brief Abstraction of information on executor environments
18  */
19 
20 #include "OpenMP.h"
21 
22 #ifdef QMC_EXP_THREADING
23 #include <thread>
24 #endif
25 
26 namespace qmcplusplus
27 {
28 enum class Executor
29 {
30  OPENMP,
31 #ifdef QMC_EXP_THREADING
32  STD_THREADS
33 #endif
34 };
35 
36 namespace Concurrency
37 {
39 
40 template<Executor TT = Executor::OPENMP>
41 unsigned int maxCapacity();
42 
43 template<>
44 inline unsigned int maxCapacity<Executor::OPENMP>()
45 {
46  return omp_get_max_threads();
47 }
48 
49 template<Executor TT = Executor::OPENMP>
50 unsigned int getWorkerId();
51 
52 template<>
53 inline unsigned int getWorkerId<Executor::OPENMP>()
54 {
55  return omp_get_thread_num();
56 }
57 
58 #ifdef QMC_EXP_THREADING
59 template<>
60 inline unsigned int maxCapacity<Executor::STD_THREADS>()
61 {
62  // Does taskset fix what this reports? i.e. deal with binding to socket properly
63  return std::thread::hardware_concurrency();
64 }
65 #endif
66 
67 } // namespace Concurrency
68 } // namespace qmcplusplus
69 #endif
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
omp_int_t omp_get_thread_num()
Definition: OpenMP.h:25
omp_int_t omp_get_max_threads()
Definition: OpenMP.h:26
unsigned int getWorkerId()
unsigned int maxCapacity()