Skip to content

Commit

Permalink
cleaned up logs
Browse files Browse the repository at this point in the history
  • Loading branch information
SJulianS committed May 28, 2024
1 parent a3f322c commit c72abb4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 66 deletions.
59 changes: 11 additions & 48 deletions plugins/hawkeye/src/candidate_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,8 @@ namespace hal
return ERR("netlist is a nullptr");
}

log_info("hawkeye", "start traversing netlist to determine flip-flop dependencies...");
auto global_start = std::chrono::system_clock::now();
auto start = global_start;
log_info("hawkeye", "start detecting state register candidates...");
auto start = std::chrono::system_clock::now();

const auto nl_dec = NetlistTraversalDecorator(*nl);
std::map<Gate*, std::set<Gate*>> ff_map;
Expand All @@ -336,12 +335,6 @@ namespace hal
}
}

auto duration_in_seconds = std::chrono::duration<double>(std::chrono::system_clock::now() - start).count();
log_info("hawkeye", "successfully traversed netlist in {:.2f} seconds", duration_in_seconds);

log_info("hawkeye", "start constructing empty netlist graph...");
start = std::chrono::system_clock::now();

auto res = graph_algorithm::NetlistGraph::from_netlist_no_edges(nl, start_gates);
if (res.is_error())
{
Expand All @@ -356,23 +349,9 @@ namespace hal
}
auto start_vertices = start_vertices_res.get();

duration_in_seconds = std::chrono::duration<double>(std::chrono::system_clock::now() - start).count();
log_info("hawkeye", "successfully created empty netlist graph in {:.2f} seconds", duration_in_seconds);

log_info("hawkeye", "start candidate identification using {} configurations...", configs.size());
start = std::chrono::system_clock::now();

std::set<RegisterCandidate> candidates;
for (const auto& config : configs)
{
log_info("hawkeye",
"start filling netlist graph with configuration [timeout={}, min_register_size={}, control={}, components={}]...",
config.timeout,
config.min_register_size,
enum_to_string(config.control),
enum_to_string(config.components));
auto start_inner = std::chrono::system_clock::now();

auto tmp_graph_res = base_graph->copy();
if (tmp_graph_res.is_error())
{
Expand Down Expand Up @@ -479,17 +458,6 @@ namespace hal
return ERR(edge_res.get_error());
}

duration_in_seconds = std::chrono::duration<double>(std::chrono::system_clock::now() - start_inner).count();
log_info("hawkeye", "successfully filled netlist graph in {:.2f} seconds", duration_in_seconds);

log_info("hawkeye",
"start neighborhood discovery with configuration [timeout={}, min_register_size={}, control={}, components={}]...",
config.timeout,
config.min_register_size,
enum_to_string(config.control),
enum_to_string(config.components));
start_inner = std::chrono::system_clock::now();

igraph_vector_int_t in_set, out_set;
if (const auto res = igraph_vector_int_init(&in_set, 0); res != IGRAPH_SUCCESS)
{
Expand Down Expand Up @@ -618,17 +586,8 @@ namespace hal
}
}
}

duration_in_seconds = std::chrono::duration<double>(std::chrono::system_clock::now() - start_inner).count();
log_info("hawkeye", "successfully completed neighborhood discovery in {:.2f} seconds", duration_in_seconds);
}

duration_in_seconds = std::chrono::duration<double>(std::chrono::system_clock::now() - start).count();
log_info("hawkeye", "successfully completed candidate identification in {:.2f} seconds", duration_in_seconds);

log_info("hawkeye", "start reducing candidates...", configs.size());
start = std::chrono::system_clock::now();

std::set<const RegisterCandidate*> candidates_to_delete;
for (auto outer_it = candidates.begin(); outer_it != candidates.end(); outer_it++)
{
Expand All @@ -652,11 +611,15 @@ namespace hal
candidates.erase(*c);
}

duration_in_seconds = std::chrono::duration<double>(std::chrono::system_clock::now() - start).count();
log_info("hawkeye", "successfully completed reducing candidates in {:.2f} seconds", duration_in_seconds);

duration_in_seconds = std::chrono::duration<double>(std::chrono::system_clock::now() - global_start).count();
log_info("hawkeye", "overall runtime: {} seconds", duration_in_seconds);
auto duration_in_seconds = std::chrono::duration<double>(std::chrono::system_clock::now() - start).count();
if (candidates.size() == 1)
{
log_info("hawkeye", "detected {} state register candidate in {} seconds", candidates.size(), duration_in_seconds);
}
else
{
log_info("hawkeye", "detected {} state register candidates in {} seconds", candidates.size(), duration_in_seconds);
}

return OK(std::vector<RegisterCandidate>(candidates.begin(), candidates.end()));
}
Expand Down
18 changes: 3 additions & 15 deletions plugins/hawkeye/src/round_candidate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace hal
std::set<Gate*> state_logic;
std::set<Net*> state_inputs, state_outputs, control_inputs, other_inputs;

log_info("hawkeye", "start isolating state logic...");
log_info("hawkeye", "start constructing round function candidate from state register candidate...");
auto start = std::chrono::system_clock::now();

const auto& state_input_reg = candidate->get_input_reg();
Expand Down Expand Up @@ -140,12 +140,6 @@ namespace hal
}
}

auto duration_in_seconds = std::chrono::duration<double>(std::chrono::system_clock::now() - start).count();
log_info("hawkeye", "successfully isolated state logic in {:.2f} seconds", duration_in_seconds);

log_info("hawkeye", "start identifying inputs...");
start = std::chrono::system_clock::now();

std::set<Net*> visited;
for (auto* gate : state_logic)
{
Expand Down Expand Up @@ -187,13 +181,7 @@ namespace hal
}
}

duration_in_seconds = std::chrono::duration<double>(std::chrono::system_clock::now() - start).count();
log_info("hawkeye", "successfully identified inputs in {:.2f} seconds", duration_in_seconds);

// copy partial netlist
log_info("hawkeye", "start creating sub-circuit netlist...");
start = std::chrono::system_clock::now();

auto round_cand = std::make_unique<RoundCandidate>();
round_cand->m_netlist = std::move(netlist_factory::create_netlist(candidate->get_netlist()->get_gate_library()));
auto* copied_nl = round_cand->m_netlist.get();
Expand Down Expand Up @@ -345,8 +333,8 @@ namespace hal
round_cand->m_longest_distance_to_gate[distance].insert(gate);
}

duration_in_seconds = std::chrono::duration<double>(std::chrono::system_clock::now() - start).count();
log_info("hawkeye", "successfully created sub-circuit netlist in {:.2f} seconds", duration_in_seconds);
auto duration_in_seconds = std::chrono::duration<double>(std::chrono::system_clock::now() - start).count();
log_info("hawkeye", "successfully constructed round function candidate from state register candidate in {:.2f} seconds", duration_in_seconds);

return OK(std::move(round_cand));
}
Expand Down
6 changes: 3 additions & 3 deletions plugins/hawkeye/src/sbox_lookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace hal
{
Result<std::vector<SBoxCandidate>> locate_sboxes(const RoundCandidate* candidate)
{
log_info("hawkeye", "start locating S-boxes within round candidate now...");
log_info("hawkeye", "start locating S-boxes within round function candidate...");
auto start = std::chrono::system_clock::now();

const auto* nl = candidate->get_netlist();
Expand Down Expand Up @@ -268,14 +268,14 @@ namespace hal
}

auto duration_in_seconds = std::chrono::duration<double>(std::chrono::system_clock::now() - start).count();
log_info("hawkeye", "located {} S-box candidates within round candidate in {:.2f} seconds", res.size(), duration_in_seconds);
log_info("hawkeye", "located {} S-box candidates within round function candidate in {:.2f} seconds", res.size(), duration_in_seconds);

return OK(res);
}

Result<std::string> identify_sbox(const SBoxCandidate& sbox_candidate, const SBoxDatabase& db)
{
log_info("hawkeye", "start identifying S-box candidate now...");
log_info("hawkeye", "start identifying S-box candidate...");
auto start = std::chrono::system_clock::now();

std::string sbox_name;
Expand Down

0 comments on commit c72abb4

Please sign in to comment.