def reset(self): """ Resets the simulator to the initial state """ global controller #check if an exception has occurred in systemc... if controller.error == True: print "\n\nSimulation cannot be restarted since an exception has been thrown!\n\n" return # Stop simulation if (controller.has_started() and not controller.is_ended()): controller.stop_simulation() # Delete All self.__delete_all_helper() # Reset OSEmulation cm_wrapper.ConcurrencyEmulatorBase.resetCEBase() bfdwrapper.BFDWrapper.resetBFDWrapper() #trapwrapper.OSEmulatorBase.reset() # Reset component manager manager.reset() # Reset power framework import power power.reset() # Reset breakpoints import breakpoints breakpoints.reset() # Reset SystemC (tricky) scwrapper.sc_get_curr_simcontext().reset() # Reset controller controller.reset_controller() self.controller = None del globals()['controller'] for script in self.scripting_commands: del globals()[script.__name__] #instantiate a new controller and setup scripting commands (for simplicity all commands are restored...) self.setup_controller(self.interactive) self.setup_scripting_commands()
def cores_set(self, cores): """ Set Pool's cores Parameters: cores: Pool's cores """ old_cores = self.cores_get() # create a diff, create a list of cores that were removed from current pool removed_cores = [core for core in old_cores if core not in cores] # update pool with new core list Pool.pools[self.pool]['cores'] = cores # updated RDT configuration common.PQOS_API.alloc_assoc_set(cores, self.pool) # process list of removed cores # pylint: disable=consider-using-dict-items for pool_id in Pool.pools: if pool_id == self.pool: continue # check if cores were assigned to another pool, # if they were, remove them from that pool Pool.pools[pool_id]['cores'] = \ [core for core in Pool.pools[pool_id]['cores'] if core not in cores] # filter out cores assigned to other pools removed_cores = \ [core for core in removed_cores if core not in Pool.pools[pool_id]['cores']] # Finally assign removed cores back to COS0/"Default" Pool if removed_cores: log.debug(f"Cores assigned to COS#0 {removed_cores}") common.PQOS_API.release(removed_cores) # Reset power profile settings if caps.sstcp_enabled() and removed_cores: power.reset(removed_cores)
def test_reset(self): class CORE: def __init__(self, id): self.core_id = id self.commit = mock.MagicMock() CORES_LIST = [CORE(0), CORE(1), CORE(2), CORE(3), CORE(4)] for val in [[], None]: assert -1 == power.reset(val) with mock.patch("power_common.get_pwr_cores", return_value=CORES_LIST) as mock_get_cores: assert 0 == power.reset([0, 1, 2]) mock_get_cores.assert_called_once() for core in CORES_LIST: if core.core_id in [0, 1, 2]: core.commit.assert_called_once_with("default") else: core.commit.assert_not_called()