Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions phlex/core/framework_graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace phlex::experimental {
template <typename... InitArgs>
auto fold(std::string name,
is_fold_like auto f,
concurrency c = concurrency::serial,
concurrency c,
std::string partition = "job",
InitArgs&&... init_args)
{
Expand All @@ -92,17 +92,21 @@ namespace phlex::experimental {
std::move(pred), std::move(unf), c, std::move(destination_data_layer));
}

auto observe(std::string name, is_observer_like auto f, concurrency c = concurrency::serial)
auto observe(std::string name, is_observer_like auto f, concurrency c = concurrency::unlimited)
{
return make_glue().observe(std::move(name), std::move(f), c);
}

auto predicate(std::string name, is_predicate_like auto f, concurrency c = concurrency::serial)
auto predicate(std::string name,
is_predicate_like auto f,
concurrency c = concurrency::unlimited)
{
return make_glue().predicate(std::move(name), std::move(f), c);
}

auto transform(std::string name, is_transform_like auto f, concurrency c = concurrency::serial)
auto transform(std::string name,
is_transform_like auto f,
concurrency c = concurrency::unlimited)
{
return make_glue().transform(std::move(name), std::move(f), c);
}
Expand Down
8 changes: 4 additions & 4 deletions phlex/core/glue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace phlex::experimental {
}

template <typename FT>
auto observe(std::string name, FT f, concurrency c)
auto observe(std::string name, FT f, concurrency c = concurrency::unlimited)
{
detail::verify_name(name, config_);
return make_registration<observer_node>(config_,
Expand All @@ -70,7 +70,7 @@ namespace phlex::experimental {
}

template <typename FT>
auto transform(std::string name, FT f, concurrency c)
auto transform(std::string name, FT f, concurrency c = concurrency::unlimited)
{
detail::verify_name(name, config_);
return make_registration<transform_node>(config_,
Expand All @@ -83,7 +83,7 @@ namespace phlex::experimental {
}

template <typename FT>
auto predicate(std::string name, FT f, concurrency c)
auto predicate(std::string name, FT f, concurrency c = concurrency::unlimited)
{
detail::verify_name(name, config_);
return make_registration<predicate_node>(config_,
Expand Down Expand Up @@ -124,7 +124,7 @@ namespace phlex::experimental {
std::move(destination_data_layer));
}

auto output(std::string name, is_output_like auto f, concurrency c = concurrency::serial)
auto output(std::string name, is_output_like auto f, concurrency c = concurrency::unlimited)
{
return output_api{nodes_.registrar_for<declared_output_ptr>(errors_),
config_,
Expand Down
21 changes: 11 additions & 10 deletions phlex/core/graph_proxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace phlex::experimental {
template <typename... InitArgs>
auto fold(std::string name,
is_fold_like auto f,
concurrency c = concurrency::serial,
concurrency c,
std::string partition = "job",
InitArgs&&... init_args)
{
Expand All @@ -57,37 +57,38 @@ namespace phlex::experimental {
std::forward<InitArgs>(init_args)...);
}

auto observe(std::string name, is_observer_like auto f, concurrency c = concurrency::serial)
auto observe(std::string name, is_observer_like auto f, concurrency c = concurrency::unlimited)
{
return create_glue().observe(std::move(name), std::move(f), c);
}

auto predicate(std::string name, is_predicate_like auto f, concurrency c = concurrency::serial)
auto predicate(std::string name,
is_predicate_like auto f,
concurrency c = concurrency::unlimited)
{
return create_glue().predicate(std::move(name), std::move(f), c);
}

auto transform(std::string name, is_transform_like auto f, concurrency c = concurrency::serial)
auto transform(std::string name,
is_transform_like auto f,
concurrency c = concurrency::unlimited)
{
return create_glue().transform(std::move(name), std::move(f), c);
}

template <typename Splitter>
auto unfold(std::string name,
is_predicate_like auto pred,
auto unf,
concurrency c = concurrency::serial)
auto unfold(std::string name, is_predicate_like auto pred, auto unf, concurrency c)
{
return create_glue(false).unfold(std::move(name), std::move(pred), std::move(unf), c);
}

template <typename Splitter>
auto unfold(is_predicate_like auto pred, auto unf, concurrency c = concurrency::serial)
auto unfold(is_predicate_like auto pred, auto unf, concurrency c)
{
return create_glue(false).unfold(std::move(pred), std::move(unf), c);
}

auto output(std::string name, is_output_like auto f, concurrency c = concurrency::serial)
auto output(std::string name, is_output_like auto f, concurrency c = concurrency::unlimited)
{
return create_glue().output(std::move(name), std::move(f), c);
}
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ add_catch_test(product_matcher LIBRARIES phlex::model)
add_catch_test(product_store LIBRARIES phlex::core)
add_catch_test(fold LIBRARIES phlex::core)
add_catch_test(replicated LIBRARIES TBB::tbb phlex::utilities spdlog::spdlog)
add_catch_test(repeater LIBRARIES TBB::tbb spdlog::spdlog)
add_catch_test(serializer LIBRARIES phlex::core TBB::tbb)
add_catch_test(specified_label LIBRARIES phlex::core)
add_catch_test(unfold LIBRARIES Boost::json phlex::core TBB::tbb)
Expand Down
6 changes: 2 additions & 4 deletions test/benchmarks/accept_even_ids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m, config)
{
m.predicate(
"accept_even_ids",
[](phlex::experimental::level_id const& id) { return id.number() % 2 == 0; },
phlex::experimental::concurrency::unlimited)
m.predicate("accept_even_ids",
[](phlex::experimental::level_id const& id) { return id.number() % 2 == 0; })
.input_family(config.get<std::string>("product_name"));
}
5 changes: 1 addition & 4 deletions test/benchmarks/accept_even_numbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m, config)
{
m.predicate(
"accept_even_numbers",
[](int i) { return i % 2 == 0; },
phlex::experimental::concurrency::unlimited)
m.predicate("accept_even_numbers", [](int i) { return i % 2 == 0; })
.input_family(config.get<std::string>("consumes"));
}
3 changes: 1 addition & 2 deletions test/benchmarks/accept_fibonacci_numbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m, config)
{
m.make<test::fibonacci_numbers>(config.get<int>("max_number"))
.predicate(
"accept", &test::fibonacci_numbers::accept, phlex::experimental::concurrency::unlimited)
.predicate("accept", &test::fibonacci_numbers::accept)
.input_family(config.get<std::string>("consumes"));
}
2 changes: 1 addition & 1 deletion test/benchmarks/last_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace {

PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m, config)
{
m.transform("last_index", last_index, concurrency::unlimited)
m.transform("last_index", last_index)
.input_family("id")
.output_products(config.get<std::string>("produces", "a"));
}
2 changes: 1 addition & 1 deletion test/benchmarks/plus_101.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ namespace {

PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m)
{
m.transform("plus_101", plus_101, concurrency::unlimited).input_family("a").output_products("c");
m.transform("plus_101", plus_101).input_family("a").output_products("c");
}
2 changes: 1 addition & 1 deletion test/benchmarks/plus_one.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ namespace {

PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m)
{
m.transform("plus_one", plus_one, concurrency::unlimited).input_family("a").output_products("b");
m.transform("plus_one", plus_one).input_family("a").output_products("b");
}
5 changes: 1 addition & 4 deletions test/benchmarks/read_id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@ namespace {
void read_id(phlex::experimental::level_id const&) {}
}

PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m)
{
m.observe("read_id", read_id, phlex::experimental::concurrency::unlimited).input_family("id");
}
PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m) { m.observe("read_id", read_id).input_family("id"); }
3 changes: 1 addition & 2 deletions test/benchmarks/read_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ namespace {

PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m, config)
{
m.observe("read_index", read_index, phlex::experimental::concurrency::unlimited)
.input_family(config.get<std::string>("consumes"));
m.observe("read_index", read_index).input_family(config.get<std::string>("consumes"));
}
3 changes: 1 addition & 2 deletions test/benchmarks/verify_difference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m, config)
{
m.observe(
"verify_difference",
[expected = config.get<int>("expected", 100)](int i, int j) { assert(j - i == expected); },
concurrency::unlimited)
[expected = config.get<int>("expected", 100)](int i, int j) { assert(j - i == expected); })
.input_family(config.get<std::string>("i", "b"), config.get<std::string>("j", "c"));
}
3 changes: 1 addition & 2 deletions test/benchmarks/verify_even_fibonacci_numbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ PHLEX_EXPERIMENTAL_REGISTER_ALGORITHMS(m, config)
{
using namespace test;
m.make<even_fibonacci_numbers>(config.get<int>("max_number"))
.observe(
"only_even", &even_fibonacci_numbers::only_even, phlex::experimental::concurrency::unlimited)
.observe("only_even", &even_fibonacci_numbers::only_even)
.input_family(config.get<std::string>("consumes"));
}
29 changes: 11 additions & 18 deletions test/cached_execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,36 +46,29 @@ TEST_CASE("Cached function calls", "[data model]")
{
framework_graph g{detail::create_next<cached_execution_source>()};

g.transform("A1", call_one, concurrency::unlimited)
.input_family("number"_in("run"))
.output_products("one");
g.transform("A2", call_one, concurrency::unlimited)
.input_family("one"_in("run"))
.output_products("used_one");
g.transform("A3", call_one, concurrency::unlimited)
.input_family("used_one"_in("run"))
.output_products("done_one");
g.transform("A1", call_one).input_family("number"_in("run")).output_products("one");
g.transform("A2", call_one).input_family("one"_in("run")).output_products("used_one");
g.transform("A3", call_one).input_family("used_one"_in("run")).output_products("done_one");

g.transform("B1", call_two, concurrency::unlimited)
g.transform("B1", call_two)
.input_family("one"_in("run"), "another"_in("subrun"))
.output_products("two");
g.transform("B2", call_two, concurrency::unlimited)
g.transform("B2", call_two)
.input_family("used_one"_in("run"), "two"_in("subrun"))
.output_products("used_two");

g.transform("C", call_two, concurrency::unlimited)
g.transform("C", call_two)
.input_family("used_two"_in("subrun"), "still"_in("event"))
.output_products("three");

g.execute();

// FIXME: Need to improve the synchronization to supply strict equality
CHECK(g.execution_counts("A1") >= n_runs);
CHECK(g.execution_counts("A2") >= n_runs);
CHECK(g.execution_counts("A3") >= n_runs);
CHECK(g.execution_counts("A1") == n_runs);
CHECK(g.execution_counts("A2") == n_runs);
CHECK(g.execution_counts("A3") == n_runs);

CHECK(g.execution_counts("B1") >= n_runs * n_subruns);
CHECK(g.execution_counts("B2") >= n_runs * n_subruns);
CHECK(g.execution_counts("B1") == n_runs * n_subruns);
CHECK(g.execution_counts("B2") == n_runs * n_subruns);

CHECK(g.execution_counts("C") == n_runs * n_subruns * n_events);
}
12 changes: 6 additions & 6 deletions test/class_registration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,37 +62,37 @@ TEST_CASE("Call non-framework functions", "[programming model]")
auto glueball = g.make<A>();
SECTION("No framework")
{
glueball.transform("no_framework", &A::no_framework, concurrency::unlimited)
glueball.transform("no_framework", &A::no_framework)
.input_family(product_names)
.output_products(oproduct_names);
}
SECTION("No framework, all references")
{
glueball.transform("no_framework_all_refs", &A::no_framework_all_refs, concurrency::unlimited)
glueball.transform("no_framework_all_refs", &A::no_framework_all_refs)
.input_family(product_names)
.output_products(oproduct_names);
}
SECTION("No framework, all pointers")
{
glueball.transform("no_framework_all_ptrs", &A::no_framework_all_ptrs, concurrency::unlimited)
glueball.transform("no_framework_all_ptrs", &A::no_framework_all_ptrs)
.input_family(product_names)
.output_products(oproduct_names);
}
SECTION("One framework argument")
{
glueball.transform("one_framework_arg", &A::one_framework_arg, concurrency::unlimited)
glueball.transform("one_framework_arg", &A::one_framework_arg)
.input_family(product_names)
.output_products(oproduct_names);
}
SECTION("All framework arguments")
{
glueball.transform("all_framework_args", &A::all_framework_args, concurrency::unlimited)
glueball.transform("all_framework_args", &A::all_framework_args)
.input_family(product_names)
.output_products(oproduct_names);
}

// The following is invoked for *each* section above
g.observe("verify_results", verify_results, concurrency::unlimited).input_family(product_names);
g.observe("verify_results", verify_results).input_family(product_names);

g.execute();
}
2 changes: 1 addition & 1 deletion test/demo-giantdata/unfold_transform_fold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ int main(int argc, char* argv[])
return demo::clampWaveforms(*hwf, run_id, subrun_id, spill_id, apa_id);
};

g.transform("clamp_node", wrapped_user_function, concurrency::unlimited)
g.transform("clamp_node", wrapped_user_function)
.input_family("waves_in_apa"_in("APA"))
.output_products("clamped_waves");

Expand Down
13 changes: 8 additions & 5 deletions test/different_hierarchies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,15 @@ TEST_CASE("Different hierarchies used with fold", "[graph]")
.output_products("run_sum");
g.fold("job_add", add, concurrency::unlimited).input_family("number").output_products("job_sum");

g.observe("verify_run_sum", [](unsigned int actual) { CHECK(actual == 10u); })
g.observe(
"verify_run_sum", [](unsigned int actual) { CHECK(actual == 10u); }, concurrency::serial)
.input_family("run_sum");
g.observe("verify_job_sum",
[](unsigned int actual) {
CHECK(actual == 20u + 45u); // 20u from events, 45u from trigger primitives
})
g.observe(
"verify_job_sum",
[](unsigned int actual) {
CHECK(actual == 20u + 45u); // 20u from events, 45u from trigger primitives
},
concurrency::serial)
.input_family("job_sum");

g.execute();
Expand Down
Loading
Loading