23#include <unordered_map>
51namespace fs = std::filesystem;
53using PU = ParallelUtilities;
Shared declarations for MPI parallel execution: message tags, utilities, Fortran callbacks.
Static MPI utility functions — colored logging, Boost object serialization over MPI.
MPI server that manages the DET task queue and client dispatch.
void merge_outputs()
Merge per-rank Output/ directories into the shared project Output/.
bool dispatch_one_resume_task()
Dispatch the last task of resume_pending_ to a free client.
std::shared_ptr< TreeState > viz_state_
std::unordered_map< int, int > rank_current_sequence_
rank -> sequence_id being run
int next_candidate
Round-robin pointer (starts at rank 1)
bool stoppedAtCheckpoint() const
True when the run ended at a checkpoint (–checkpoint-stop, the interrupt menu's checkpoint option,...
void Shutdown()
Send client_shutdown to every client rank and stop the visualization server. Under –merge=now each cl...
std::queue< RestartTask > tasks_queue
Pending metadata-only restart tasks.
Server(int rank, int viz_port=0)
Set up the client table and, when viz_port is nonzero, start the visualization server; also runs Sche...
int rank
This process rank (always 0)
std::unique_ptr< DETCheckpoint > resume_ckpt_
Loaded –resume checkpoint (null in a fresh run)
int find_next_free_client_round_robin()
Claim the next free client, round-robin from next_candidate. The returned client is marked busy and n...
~Server()
Defined in Server.cpp (VisualizationServer complete type required)
int sequence_counter_
Next sequence ID to assign (0 is the initial sequence)
int find_free_client_except(int exclude_rank)
Claim the next free client via round-robin, skipping exclude_rank.
void Simulation()
Main server loop: poll for messages, dispatch tasks, until the tree is complete.
std::map< int, int > resume_source_refs_
Undispatched resume tasks per checkpoint source blob.
int num_queue
Unused (the queue depth is tasks_queue.size())
void dispatch_available_tasks()
Make one pass over the task queue.
int getSequencesCompleted() const
Number of sequences completed, including those restored from a resumed checkpoint.
int num_free_clients
Number of currently idle clients.
int last_busy_
last logged busy-worker count
std::ofstream occupancy_log_
double occupancy_t0_
MPI_Wtime() when the log was opened [s].
int last_queue_
last logged depth, to suppress no-op rows
bool stopped_at_checkpoint_
Run ended at a checkpoint: outputs are intermediate.
int last_checkpoint_seq_
Sequence count at the last checkpoint written from the message path (-1 = none)
void write_checkpoint()
Gather held branch data from every client and write <checkpoint_dir>/checkpoint_seq_<sequences_comple...
int sequences_completed_
Total sequences finished so far.
bool checkpoint_pending_
Checkpoint requested, waiting for clients to drain.
std::vector< PendingBranch > resume_pending_
Undispatched tasks; consumed from the back, index-aligned with resume_ckpt_->task_restart_states.
void dispatch_resume_tasks()
Load the –resume checkpoint and dispatch its pending tasks.
std::unique_ptr< int[]> clients_busy
Per-client busy flag (0=free, 1=busy)
std::unique_ptr< VisualizationServer > viz_server_
Lightweight HTTP server serving a D3.js DET visualization page. Runs in a background thread alongside...
Complete state of a dynamic event tree run at a sequence boundary.
One unexplored branch recorded in a checkpoint.
A metadata-only restart task: the data stays on the source client.
int sequence_id
Assigned sequence number.
int local_id
Rank-local branch-point ID, the key of the data held on the source client.
int parent_sequence_id
Sequence that branched to create this task.
int source_rank
Client that holds the branch data.
int branch_index
Which alternative branch to run (1..N-1)
Shared state between MPI server loop and visualization HTTP server.
int queue_depth
Queued metadata-only tasks.
std::map< int, SequenceOutputData > output_data
seq_id -> output data (PE events, end states)
int sequences_completed
Mirror of Server::sequences_completed_.
double start_time
MPI_Wtime() at server construction [s].
std::vector< SequenceReport > completed
One report per finished sequence, in arrival order.
int total_clients
Worker count (MPI size - 1)
long memory_mb
Server (rank 0) RSS [MB].
int num_free_clients
Idle workers.
std::mutex mu
Guards all other members.