Fleet  0.0.9
Inference in the LOT
MPIInferenceInterface.h
Go to the documentation of this file.
1 #pragma once
2 
10 template<typename T>
12 
13  virtual generator<X&> mpi_run_head() {
14  TopN<MyHypothesis> top(TopN<MyHypothesis>::MAX_N); // take union of all
15  // we will read back a bunch of tops
16  for(auto& t: mpi_gather<TopN<MyHypothesis>>()) {
17  top << t;
18  }
19  for(auto& x: top) {
20  co_yield x;
21  }
22  }
23 
24  virtual void mpi_run_worker(Control ctl){
25 
26  // defaultly we will store stuff in a top
28 
29  auto h0 = MyHypothesis::sample();
30 
31  // and run parallel tempering
33  for(auto& h : samp.run(ctl, 100, 30000) | top) { }
34 
35  // CERR "WORKER DONE " TAB mpi_rank() TAB top.best().string() ENDL;
36  mpi_return(top);
37  }
38 
39  generator<X&> mpi_run(Control ctl, Args... args) {
40 
41  // here we split control into head, which aggregates, and the rest
42  if(is_mpi_head()) {
43 
44  }
45  else { // I am a worker
46 
47 
48 
49  }
50 
51  }
52 };
generator< HYP & > run(Control ctl)
Definition: ParallelTempering.h:170
void mpi_return(T &x)
Return my results via MPI.
Definition: MPI.h:35
static MyHypothesis sample()
Static function for making a hypothesis. Be careful using this with references because they may not f...
Definition: MCMCable.h:29
Definition: TopN.h:25
Definition: Control.h:23
Definition: ParallelTempering.h:26
Definition: generator.hpp:21
bool is_mpi_head()
Definition: MPI.h:25
size_t nchains
Definition: FleetArgs.h:21
Definition: MPIInferenceInterface.h:11
std::vector< T > mpi_gather()
Reads all the MPI returns from mpi_return. NOTE that the output does not come with any order guarante...
Definition: MPI.h:52
MyHypothesis::data_t mydata
Definition: Main.cpp:69