Skip to content

Commit

Permalink
Change simulation logging to debug level
Browse files Browse the repository at this point in the history
  • Loading branch information
vtangTT committed Dec 3, 2024
1 parent 1d8c9dd commit cf40208
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions device/simulation/tt_simulation_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ void print_flatbuffer(const DeviceRequestResponse* buf) {
std::stringstream ss;
ss << std::hex << reinterpret_cast<uintptr_t>(addr);
std::string addr_hex = ss.str();
log_info(tt::LogEmulationDriver, "{} bytes @ address {} in core ({}, {})", size, addr_hex, core.x, core.y);

std::stringstream data_ss;
for (int i = 0; i < data_vec.size(); i++) {
std::ios_base::fmtflags save = std::cout.flags();
std::cout << "0x" << std::hex << std::setw(8) << std::setfill('0') << data_vec[i] << " ";
std::cout.flags(save);
data_ss << "0x" << std::hex << std::setw(8) << std::setfill('0') << data_vec[i] << " ";
}
std::cout << std::endl;
std::string data_hex = data_ss.str();

log_debug(tt::LogEmulationDriver, "{} bytes @ address {} in core ({}, {})", size, addr_hex, core.x, core.y);
log_debug(tt::LogEmulationDriver, "Data: {}", data_hex);
}

tt_SimulationDevice::tt_SimulationDevice(const std::string& sdesc_path) : tt_device() {
Expand Down Expand Up @@ -156,7 +158,13 @@ void tt_SimulationDevice::close_device() {
// Runtime Functions
void tt_SimulationDevice::write_to_device(
const void* mem_ptr, uint32_t size_in_bytes, tt_cxy_pair core, uint64_t addr, const std::string& tlb_to_use) {
log_info(tt::LogEmulationDriver, "Device writing");
log_info(
tt::LogEmulationDriver,
"Device writing {} bytes to addr {} in core ({}, {})",
size_in_bytes,
addr,
core.x,
core.y);
std::vector<std::uint32_t> data((uint32_t*)mem_ptr, (uint32_t*)mem_ptr + size_in_bytes / sizeof(uint32_t));
auto wr_buffer = create_flatbuffer(DEVICE_COMMAND_WRITE, data, core, addr);
uint8_t* wr_buffer_ptr = wr_buffer.GetBufferPointer();
Expand All @@ -178,10 +186,11 @@ void tt_SimulationDevice::read_from_device(
size_t rd_rsp_sz = host.recv_from_device(&rd_resp);

auto rd_resp_buf = GetDeviceRequestResponse(rd_resp);
if (addr != 0x40) {
log_info(tt::LogEmulationDriver, "Device reading vec");
print_flatbuffer(rd_resp_buf); // 0x40 is host polling device, don't print since it'll spam
}

// Debug level polling as Metal will constantly poll the device, spamming the logs
log_debug(tt::LogEmulationDriver, "Device reading vec");
print_flatbuffer(rd_resp_buf);

std::memcpy(mem_ptr, rd_resp_buf->data()->data(), rd_resp_buf->data()->size() * sizeof(uint32_t));
nng_free(rd_resp, rd_rsp_sz);
}
Expand Down

0 comments on commit cf40208

Please sign in to comment.