Skip to content

Commit

Permalink
merian-nodes: GraphRun: Provide access to total iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
LDAP committed Aug 13, 2024
1 parent f732082 commit 968f59e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/merian-nodes/graph/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ class Graph : public std::enable_shared_from_this<Graph<RING_SIZE>> {

run.reset(run_iteration, run_iteration % RING_SIZE, profiler, cmd_pool,
resource_allocator, time_delta, duration_elapsed,
duration_elapsed_since_connect);
duration_elapsed_since_connect, total_iteration);

// While preprocessing nodes can signalize that they need to reconnect as well
{
Expand Down
21 changes: 18 additions & 3 deletions include/merian-nodes/graph/graph_run.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,26 @@ class GraphRun {
submit_callbacks.push_back(callback);
}

void request_reconnect() {
void request_reconnect() noexcept {
needs_reconnect = true;
}

// increases with each run, resets at rebuild
// Number of iterations since connect.
// Use get_total_iteration() for iterations since graph initialization.
//
// Iterations are 0-indexed.
const uint64_t& get_iteration() const noexcept {
return iteration;
}

// Number of iterations since graph initialization.
// Use get_iteration() for iterations since connect.
//
// Iterations are 0-indexed.
const uint64_t& get_total_iteration() const noexcept {
return total_iteration;
}

// returns the current in-flight index i, with 0 <= i < get_ring_size().
// It is guaranteed that processing of the last iteration with that index has finished.
const uint32_t& get_in_flight_index() const noexcept {
Expand Down Expand Up @@ -111,6 +122,7 @@ class GraphRun {
}

// Returns the profiler that is attached to this run.
//
// Can be nullptr if profiling is disabled!
const ProfilerHandle& get_profiler() const {
return profiler;
Expand Down Expand Up @@ -166,14 +178,16 @@ class GraphRun {
const ResourceAllocatorHandle& allocator,
const std::chrono::nanoseconds time_delta,
const std::chrono::nanoseconds elapsed,
const std::chrono::nanoseconds elapsed_run) {
const std::chrono::nanoseconds elapsed_run,
const uint64_t total_iterations) {
this->iteration = iteration;
this->in_flight_index = in_flight_index;
this->cmd_pool = cmd_pool;
this->allocator = allocator;
this->time_delta = time_delta;
this->elapsed = elapsed;
this->elapsed_since_connect = elapsed_run;
this->total_iteration = total_iterations;
wait_semaphores.clear();
wait_stages.clear();
wait_values.clear();
Expand Down Expand Up @@ -204,6 +218,7 @@ class GraphRun {

bool needs_reconnect = false;
uint64_t iteration;
uint64_t total_iteration;
uint32_t in_flight_index;
std::chrono::nanoseconds time_delta;
std::chrono::nanoseconds elapsed;
Expand Down

0 comments on commit 968f59e

Please sign in to comment.