Skip to content

Commit

Permalink
Add test for dry runs
Browse files Browse the repository at this point in the history
  • Loading branch information
facuMH committed Jul 20, 2022
1 parent b7713e8 commit 84b8b2c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ namespace detail {

bool is_dry_run() const { return cfg->is_dry_run().value_or(false); }

int get_command_count() const;

private:
inline static bool mpi_initialized = false;
inline static bool mpi_finalized = false;
Expand Down
2 changes: 2 additions & 0 deletions src/runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -283,5 +283,7 @@ namespace detail {
if(done) { active_flushes.pop_front(); }
}

int runtime::get_command_count() const { return cdag->command_count(); }

} // namespace detail
} // namespace celerity
33 changes: 33 additions & 0 deletions test/runtime_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -992,5 +992,38 @@ namespace detail {
});
}

void dry_run_with_nodes(const int nodes) {
const std::string dryrun_envvar_name = "CELERITY_DRYRUN_NODES";
setenv(dryrun_envvar_name.c_str(), std::to_string(nodes).c_str(), 1);

distr_queue q;

auto& rt = runtime::get_instance();
auto& tm = rt.get_task_manager();
tm.set_horizon_step(2);

CHECK(rt.is_dry_run());

buffer<int, 1> buff{nodes * 2};
q.submit([=](handler& cgh) {
accessor acc{buff, cgh, celerity::access::one_to_one{}, write_only};
cgh.parallel_for<class UKN(dryrun)>(buff.get_range(), [=](item<1> item) { acc[item.get_id()] = item.get_id(); });
});
q.slow_full_sync();

// (intial epoch + task + sync epoch) per node.
CHECK(rt.get_command_count() == 3 * nodes);
test_utils::maybe_print_graph(tm);
}

TEST_CASE_METHOD(test_utils::runtime_fixture, "dry run", "[dryrun]") {
SECTION("with 2 nodes") { dry_run_with_nodes(2); }
SECTION("with 8 nodes") { dry_run_with_nodes(8); }
SECTION("with 16 nodes") { dry_run_with_nodes(16); }
SECTION("with 32 nodes") { dry_run_with_nodes(32); }
SECTION("with 64 nodes") { dry_run_with_nodes(64); }
SECTION("with 128 nodes") { dry_run_with_nodes(128); }
}

} // namespace detail
} // namespace celerity

0 comments on commit 84b8b2c

Please sign in to comment.