PURIFY
Next-generation radio interferometric imaging
cpp
benchmarks
main.cc
Go to the documentation of this file.
1
#include "purify/config.h"
2
#include <benchmark/benchmark.h>
3
#include "
purify/logging.h
"
4
#include <sopt/logging.h>
5
#include <sopt/mpi/communicator.h>
6
#include <sopt/mpi/session.h>
7
8
// This reporter does nothing.
9
// We can use it to disable output from all but the root process
10
class
NullReporter
:
public
::benchmark::BenchmarkReporter {
11
public
:
12
NullReporter
() {}
13
virtual
bool
ReportContext
(
const
Context &) {
return
true
; }
14
virtual
void
ReportRuns
(
const
std::vector<Run> &) {}
15
virtual
void
Finalize
() {}
16
};
17
18
// The main is rewritten to allow for MPI initializing and for selecting a
19
// reporter according to the process rank
20
int
main
(
int
argc,
char
const
**argv) {
21
sopt::logging::set_level
(
"info"
);
22
purify::logging::set_level
(
"debug"
);
23
24
#ifdef PURIFY_MPI
25
auto
const
session = sopt::mpi::init(argc, argv);
26
auto
const
world = sopt::mpi::Communicator::World();
27
PURIFY_LOW_LOG
(
"MPI initialized"
);
28
#endif
29
::benchmark::Initialize(&argc,
const_cast<
char
**
>
(argv));
30
31
#ifdef PURIFY_MPI
32
if
(world.is_root())
33
// root process will use a reporter from the usual set provided by
34
// ::benchmark
35
::benchmark::RunSpecifiedBenchmarks();
36
else
{
37
// reporting from other processes is disabled by passing a custom reporter
38
NullReporter
null
;
39
::benchmark::RunSpecifiedBenchmarks(&
null
);
40
}
41
#endif
42
return
0;
43
}
main
int main(int argc, char const **argv)
Definition:
main.cc:20
NullReporter
Definition:
main.cc:10
NullReporter::NullReporter
NullReporter()
Definition:
main.cc:12
NullReporter::Finalize
virtual void Finalize()
Definition:
main.cc:15
NullReporter::ReportRuns
virtual void ReportRuns(const std::vector< Run > &)
Definition:
main.cc:14
NullReporter::ReportContext
virtual bool ReportContext(const Context &)
Definition:
main.cc:13
logging.h
PURIFY_LOW_LOG
#define PURIFY_LOW_LOG(...)
Low priority message.
Definition:
logging.h:207
purify::logging::set_level
void set_level(const std::string &level)
Method to set the logging level of the default Log object.
Definition:
logging.h:137
Generated by
1.9.1