From 70f093fd8cc26ccda0f35f98d44e480640de1c10 Mon Sep 17 00:00:00 2001 From: David Biancolin Date: Wed, 12 Dec 2018 02:08:33 -0800 Subject: [PATCH] [Driver] Properly invoke endpoint dtors --- sim/midas | 2 +- sim/src/main/cc/firesim/firesim_top.cc | 10 +++++----- sim/src/main/cc/firesim/firesim_top.h | 6 ++++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/sim/midas b/sim/midas index 3a1601fc..ccb02888 160000 --- a/sim/midas +++ b/sim/midas @@ -1 +1 @@ -Subproject commit 3a1601fcb254936f6bdfc22e246d2d0fa65eeae7 +Subproject commit ccb02888957ca79243b16f91cb0fcd04decef894 diff --git a/sim/src/main/cc/firesim/firesim_top.cc b/sim/src/main/cc/firesim/firesim_top.cc index 12c09d42..44f35e2e 100644 --- a/sim/src/main/cc/firesim/firesim_top.cc +++ b/sim/src/main/cc/firesim/firesim_top.cc @@ -348,7 +348,7 @@ uint64_t host_mem_offset = -0x80000000LL; bool firesim_top_t::simulation_complete() { bool is_complete = false; - for (auto e: endpoints) { + for (auto &e: endpoints) { is_complete |= e->terminate(); } return is_complete; @@ -362,7 +362,7 @@ uint64_t firesim_top_t::profile_models(){ } int firesim_top_t::exit_code(){ - for (auto e: endpoints) { + for (auto &e: endpoints) { if (e->exit_code()) return e->exit_code(); } @@ -371,11 +371,11 @@ int firesim_top_t::exit_code(){ void firesim_top_t::run() { - for (auto e: fpga_models) { + for (auto &e: fpga_models) { e->init(); } - for (auto e: endpoints) { + for (auto &e: endpoints) { e->init(); } @@ -394,7 +394,7 @@ void firesim_top_t::run() { run_scheduled_tasks(); step(get_largest_stepsize(), false); while(!done() && !simulation_complete()){ - for (auto e: endpoints) e->tick(); + for (auto &e: endpoints) e->tick(); } } diff --git a/sim/src/main/cc/firesim/firesim_top.h b/sim/src/main/cc/firesim/firesim_top.h index 69cd7b4d..f8ef3c14 100644 --- a/sim/src/main/cc/firesim/firesim_top.h +++ b/sim/src/main/cc/firesim/firesim_top.h @@ -1,6 +1,8 @@ #ifndef __FIRESIM_TOP_H #define __FIRESIM_TOP_H +#include + #include "simif.h" #include "endpoints/endpoint.h" #include "endpoints/fpga_model.h" @@ -16,12 +18,12 @@ class firesim_top_t: virtual simif_t, public systematic_scheduler_t protected: void add_endpoint(endpoint_t* endpoint) { - endpoints.push_back(endpoint); + endpoints.push_back(std::unique_ptr(endpoint)); } private: // Memory mapped endpoints bound to software models - std::vector endpoints; + std::vector > endpoints; // FPGA-hosted models with programmable registers & instrumentation std::vector fpga_models;