QMCPACK
ParallelExecutor.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 #ifndef QMCPLUSPLUS_PARALLELEXECUTOR_HPP
14 #define QMCPLUSPLUS_PARALLELEXECUTOR_HPP
15 
16 #include "Concurrency/Info.hpp"
17 
18 namespace qmcplusplus
19 {
20 /** Abstraction for running concurrent tasks in parallel by an executor
21  * executor workers can be OpenMP threads, std::thread
22  *
23  * Note: it is not related to the executor that C++ standard is working on currently.
24  *
25  * Construct with num_tasks to run
26  * then call operator(F, args...)
27  * F is lambda or function with form
28  * void F(int task_id, args...)
29  * [](int task_id, args...){...}
30  *
31  * This has not been tested for nested threading with openmp
32  * It is not intended for use below the top level of openmp threading.
33  */
34 template<Executor TT = Executor::OPENMP>
36 {
37 public:
38  /** Concurrently execute an arbitrary function/kernel with task id and arbitrary args
39  *
40  * ie each task will run f(int task_id, Args... args)
41  */
42  template<typename F, typename... Args>
43  void operator()(int num_tasks, F&& f, Args&&... args);
44 };
45 
46 } // namespace qmcplusplus
47 
48 // Implementation includes must follow functor declaration
50 #ifdef QMC_EXP_THREADING
52 #endif
53 // Additional implementations enabled by cmake options would go here
54 #endif
implementation of std::thread specialization of ParallelExecutor
Abstraction of information on executor environments.
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
Abstraction for running concurrent tasks in parallel by an executor executor workers can be OpenMP th...
void operator()(int num_tasks, F &&f, Args &&... args)
Concurrently execute an arbitrary function/kernel with task id and arbitrary args.
implementation of openmp specialization of ParallelExecutor