Skip to content

File utils.h

File List > kernel-sim > utils.h

Go to the documentation of this file

#pragma once

#include <fmt/format.h>
#include <simtix/system.h>
#include <toml++/toml.h>

#include <elfio/elfio.hpp>
#include <memory>
#include <optional>
#include <string>
#include <vector>

struct MemConfig {
  uint64_t addr;
  uint64_t size;
};

struct SimConfig {
  uint64_t max_ticks = -1;  // Inf
  std::optional<std::string> ktrace_path = std::nullopt;

  std::vector<MemConfig> print_mem;
  std::optional<std::string> print_mem_out = std::nullopt;

  std::string stat_path = "stat.toml";
  // System (Hardware) configurations
  simtix::system::SingleCoreSystem::Config sys_cfg;

  // Software configurations
  std::string elf_path;
  std::shared_ptr<ELFIO::elfio> elf;

  // Required flags
  std::array<bool, 3> has_kernel_info = {
      false, false, false};  // {dim, local_size, global_size}
  bool has_mmap = false;
};

std::optional<SimConfig> ParseArguments(int argc, char **argv);

toml::table SerializeConfig(const SimConfig &cfg);

void ReportConfig(const SimConfig &cfg);