TECA
teca_algorithm_executive.h
1 #ifndef teca_algorithm_executive_h
2 #define teca_algorithm_executive_h
3 
4 #include "teca_algorithm_executive_fwd.h"
5 #include "teca_metadata.h"
6 #include "teca_mpi.h"
7 
8 // base class and default implementation for executives. algorithm
9 // executives can control pipeline execution by providing a series
10 // of requests. this allows for the executive to act as a load
11 // balancer. the executive can for example partition requests across
12 // spatial data, time steps, or file names. in an MPI parallel
13 // setting the executive could coordinate this partitioning amongst
14 // the ranks. However, the only requirement of an algorithm executive
15 // is that it provide at least one non-empty request.
16 //
17 // the default implementation creates a single trivially non-empty
18 // request containing the key "__request_empty = 0". This will cause
19 // the pipeline to be executed once but will result in no data being
20 // requested. Therefore when the default implementation is used
21 // upstream algorithms must fill in the requests further to pull
22 // data as needed.
24  : public std::enable_shared_from_this<teca_algorithm_executive>
25 {
26 public:
27  static p_teca_algorithm_executive New()
28  { return p_teca_algorithm_executive(new teca_algorithm_executive); }
29 
30  virtual ~teca_algorithm_executive() {}
31 
32  // initialize requests from the given metadata object.
33  // this is a place where work partitioning across MPI
34  // ranks can occur
35  virtual int initialize(MPI_Comm comm, const teca_metadata &md);
36 
37  // get the next request until all requests have been
38  // processed. an empty request is returned.
39  virtual teca_metadata get_next_request();
40 
41  // set/get verbosity level
42  void set_verbose(int a_verbose) { this->verbose = a_verbose; }
43  int get_verbose() const { return this->verbose; }
44 
45 protected:
46  teca_algorithm_executive() : verbose(0) {}
49  teca_algorithm_executive &operator=(const teca_algorithm_executive &) = default;
50  teca_algorithm_executive &operator=(teca_algorithm_executive &&) = default;
51 
52 private:
53  int verbose;
54  teca_metadata m_request;
55 };
56 
57 #endif
teca_metadata
Definition: teca_metadata.h:17
teca_algorithm_executive
Definition: teca_algorithm_executive.h:25