-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathadd_and_verify.cpp
More file actions
33 lines (26 loc) · 1003 Bytes
/
add_and_verify.cpp
File metadata and controls
33 lines (26 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "my_add.hpp"
#include "my_geometry.hpp"
#include "phlex/module.hpp"
#include <cassert>
namespace {
// An algorithm that uses a data product from the job and another from a different layer
void verify_sum(examples::geometry const& geom, int const sum)
{
auto const [minimum, maximum] = geom.x_bounds();
assert(minimum < sum);
assert(sum < maximum);
assert(sum == 0);
}
}
PHLEX_REGISTER_ALGORITHMS(m, config)
{
using namespace phlex;
auto const layer = config.get<std::string>("layer");
m.transform("add", examples::add, concurrency::unlimited)
.input_family(product_selector{.creator = "input", .layer = layer, .suffix = "i"},
product_selector{.creator = "input", .layer = layer, .suffix = "j"})
.output_product_suffixes("sum");
m.observe("verify", verify_sum, concurrency::unlimited)
.input_family(product_selector{.creator = "input", .layer = "job"},
product_selector{.creator = "add", .layer = layer});
}