Fleet
0.0.9
Inference in the LOT
src
Inference
MPIInferenceInterface.h
Go to the documentation of this file.
1
#pragma once
2
10
template
<
typename
T>
11
class
MPIInferenceInterface
{
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
27
TopN<MyHypothesis>
top;
28
29
auto
h0 =
MyHypothesis::sample
();
30
31
// and run parallel tempering
32
ParallelTempering
samp(h0, &
mydata
,
FleetArgs::nchains
, 10.0);
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
};
ParallelTempering::run
generator< HYP & > run(Control ctl)
Definition:
ParallelTempering.h:170
mpi_return
void mpi_return(T &x)
Return my results via MPI.
Definition:
MPI.h:35
MCMCable< MyHypothesis, defaultdatum_t< BindingTree *, std::string > >::sample
static MyHypothesis sample()
Static function for making a hypothesis. Be careful using this with references because they may not f...
Definition:
MCMCable.h:29
TopN
Definition:
TopN.h:25
Control
Definition:
Control.h:23
ParallelTempering
Definition:
ParallelTempering.h:26
cppcoro::generator
Definition:
generator.hpp:21
is_mpi_head
bool is_mpi_head()
Definition:
MPI.h:25
FleetArgs::nchains
size_t nchains
Definition:
FleetArgs.h:21
MPIInferenceInterface
Definition:
MPIInferenceInterface.h:11
mpi_gather
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
mydata
MyHypothesis::data_t mydata
Definition:
Main.cpp:69
Generated by
1.8.13