Scheduler.h
Go to the documentation of this file.
1 #ifndef art_Framework_EventProcessor_Scheduler_h
2 #define art_Framework_EventProcessor_Scheduler_h
3 
7 #include "fhiclcpp/types/Atom.h"
9 #include "fhiclcpp/types/Table.h"
11 
12 #include <string>
13 
14 namespace art {
15  class Scheduler {
16  public:
17  struct Config {
18  static constexpr unsigned
19  kb()
20  {
21  return 1024;
22  }
23  static constexpr unsigned
24  mb()
25  {
26  return kb() * kb();
27  }
28 
29  // FIXME: The defaults specified here should agree with those
30  // specified in the program-options handlers.
31  using Name = fhicl::Name;
35  1};
37  Name{"stack_size"},
38  Comment{"The stack size (in bytes) that the TBB scheduler will use for "
39  "its threads.\n"
40  "The default stack size TBB specifies is 1 MB, which can be "
41  "inadequate for\n"
42  "various workflows. Because of that, art picks a default of "
43  "10 MB, which\n"
44  "more closely approximates the stack size of the main thread."},
45  10 * mb()};
46  fhicl::Atom<bool> handleEmptyRuns{Name{"handleEmptyRuns"}, true};
47  fhicl::Atom<bool> handleEmptySubRuns{Name{"handleEmptySubRuns"}, true};
48  fhicl::Atom<bool> errorOnMissingConsumes{Name{"errorOnMissingConsumes"},
49  false};
50  fhicl::Atom<bool> errorOnSIGINT{Name{"errorOnSIGINT"}, true};
51  fhicl::Atom<bool> wantSummary{Name{"wantSummary"}, false};
52  fhicl::Atom<bool> pruneConfig{Name{"pruneConfig"}, true};
53  fhicl::Atom<bool> reportUnused{Name{"reportUnused"}, true};
55  {}};
56  struct DebugConfig {
60  };
62  Name{"debug"},
63  Comment{
64  "The entries in the 'debug' table below are filled whenever the\n"
65  "command-line program options are parsed. Any user-provided values\n"
66  "will be overriden by the command-line."}};
68  };
70  explicit Scheduler(Parameters const& p);
71 
72  ActionTable const&
73  actionTable() const noexcept
74  {
75  return actionTable_;
76  }
77 
78  unsigned
79  num_threads() const noexcept
80  {
81  return nThreads_;
82  }
84  num_schedules() const noexcept
85  {
86  return nSchedules_;
87  }
88  bool
90  {
91  return handleEmptyRuns_;
92  }
93  bool
95  {
96  return handleEmptySubRuns_;
97  }
98  bool
100  {
102  }
103  bool
104  wantSummary() const noexcept
105  {
106  return wantSummary_;
107  }
108  std::string const&
110  {
111  return dataDependencyGraph_;
112  }
113 
114  std::unique_ptr<GlobalTaskGroup> global_task_group();
115 
116  private:
117  // A table of responses to be taken on reception of thrown
118  // exceptions.
120  unsigned const nThreads_;
121  unsigned const nSchedules_;
122  unsigned const stackSize_;
123  bool const handleEmptyRuns_;
126  bool const wantSummary_;
128  };
129 }
130 
131 #endif /* art_Framework_EventProcessor_Scheduler_h */
132 
133 // Local Variables:
134 // mode: c++
135 // End:
ActionTable actionTable_
Definition: Scheduler.h:119
fhicl::Atom< bool > reportUnused
Definition: Scheduler.h:53
fhicl::Atom< unsigned > stack_size
Definition: Scheduler.h:36
std::unique_ptr< GlobalTaskGroup > global_task_group()
Definition: Scheduler.cc:66
unsigned num_threads() const noexcept
Definition: Scheduler.h:79
std::string const & dataDependencyGraph() const noexcept
Definition: Scheduler.h:109
bool handleEmptySubRuns() const noexcept
Definition: Scheduler.h:94
static constexpr unsigned mb()
Definition: Scheduler.h:24
ScheduleID::size_type num_schedules() const noexcept
Definition: Scheduler.h:84
std::string string
Definition: nybbler.cc:12
Scheduler(Parameters const &p)
Definition: Scheduler.cc:49
ChannelGroupService::Name Name
fhicl::TableFragment< ActionTable::Config > actionTable
Definition: Scheduler.h:67
fhicl::Atom< bool > wantSummary
Definition: Scheduler.h:51
fhicl::Atom< std::string > printMode
Definition: Scheduler.h:59
fhicl::Atom< ScheduleID::size_type > num_schedules
Definition: Scheduler.h:34
std::string const dataDependencyGraph_
Definition: Scheduler.h:127
bool handleEmptyRuns() const noexcept
Definition: Scheduler.h:89
bool wantSummary() const noexcept
Definition: Scheduler.h:104
fhicl::OptionalTable< DebugConfig > debug
Definition: Scheduler.h:61
fhicl::Atom< unsigned > num_threads
Definition: Scheduler.h:33
bool const wantSummary_
Definition: Scheduler.h:126
fhicl::Atom< bool > handleEmptySubRuns
Definition: Scheduler.h:47
static constexpr unsigned kb()
Definition: Scheduler.h:19
fhicl::Atom< bool > pruneConfig
Definition: Scheduler.h:52
ActionTable const & actionTable() const noexcept
Definition: Scheduler.h:73
fhicl::Atom< std::string > dataDependencyGraph
Definition: Scheduler.h:54
bool const errorOnMissingConsumes_
Definition: Scheduler.h:125
unsigned const stackSize_
Definition: Scheduler.h:122
unsigned const nSchedules_
Definition: Scheduler.h:121
bool const handleEmptySubRuns_
Definition: Scheduler.h:124
p
Definition: test.py:223
bool const handleEmptyRuns_
Definition: Scheduler.h:123
#define Comment
fhicl::Atom< bool > handleEmptyRuns
Definition: Scheduler.h:46
id_type size_type
Definition: ScheduleID.h:25
unsigned const nThreads_
Definition: Scheduler.h:120
bool errorOnMissingConsumes() const noexcept
Definition: Scheduler.h:99
fhicl::Atom< bool > errorOnSIGINT
Definition: Scheduler.h:50
fhicl::Atom< std::string > fileName
Definition: Scheduler.h:57
fhicl::Atom< bool > errorOnMissingConsumes
Definition: Scheduler.h:48
fhicl::Atom< std::string > option
Definition: Scheduler.h:58