Skip to content
Open
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
10 changes: 9 additions & 1 deletion htsim/sim/logsim-interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "lgs/TimelineVisualization.hpp"
#include "lgs/cmdline.h"
#include <chrono>
#include <cmath>
#include <algorithm>
#include <filesystem>
#include <fstream>
#include <functional>
Expand Down Expand Up @@ -222,6 +224,11 @@ void LogSimInterface::htsim_simulate_until(int64_t until) {
//printf("Running HTSIM Simulate Until %lu - HtSime Time is %lu\n", until, htsim_api->getGlobalTimeNs());

if (until != -1) {
// Clamp to at least current HTSIM time to avoid scheduling in the past
int64_t htsim_now_ns = static_cast<int64_t>(htsim_api->getGlobalTimeNs());
if (until < htsim_now_ns) {
until = htsim_now_ns;
}
compute_started++;
null_events_handler->setCompute(until);
}
Expand Down Expand Up @@ -656,7 +663,8 @@ int start_lgs(std::string filename_goal, LogSimInterface &lgs) {
int updated_size = (num_packets+1) * 4160; // Parameterize this. This accounts for the header size
elem.size = updated_size;

uint64_t bandwidth_cost2 = static_cast<uint64_t>((elem.size) * G);
uint64_t bandwidth_cost2 = std::max(static_cast<uint64_t>(1),
static_cast<uint64_t>(std::ceil((double)(elem.size) * G)));
nextgs[elem.host][elem.nic] = elem.time + g + bandwidth_cost2;
can_simulate_until = nextgs[elem.host][elem.nic];

Expand Down
7 changes: 6 additions & 1 deletion htsim/sim/null_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ void NullEvent::doNextEvent() {
}

void NullEvent::setCompute(simtime_picosec computation_time) {
eventlist().sourceIsPendingRel(*this, computation_time * 1000 - eventlist().now()); // ns to ps
simtime_picosec target_ps = computation_time * 1000; // ns to ps
simtime_picosec now_ps = eventlist().now();
// Guard against truncation from ns/ps round-trip: if target is at or
// before current time, schedule immediately instead of underflowing.
simtime_picosec rel = (target_ps > now_ps) ? (target_ps - now_ps) : 0;
eventlist().sourceIsPendingRel(*this, rel);
}

void NullEvent::startComputations() { eventlist().doNextEvent(); }
Loading