From f898d43a53a5c9bee0cb49d63595917db2c043a3 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 23 Dec 2024 09:59:13 +0100 Subject: [PATCH] Remove code pertaining to the Micro Manager measuring memory consumption of the micro simulation --- micro_manager/config.py | 24 ------------------------ micro_manager/micro_manager.py | 24 ------------------------ 2 files changed, 48 deletions(-) diff --git a/micro_manager/config.py b/micro_manager/config.py index 26f99b3..4e2cc32 100644 --- a/micro_manager/config.py +++ b/micro_manager/config.py @@ -38,7 +38,6 @@ def __init__(self, config_file_name): self._diagnostics_data_names = dict() self._output_micro_sim_time = False - self._output_micro_mem_use = False self._interpolate_crash = False @@ -143,18 +142,6 @@ def _read_json(self, config_file_name): "Micro manager will not output time required to solve each micro simulation." ) - try: - if self._data["diagnostics"]["output_micro_sim_solve_mem_use"] == "True": - self._output_micro_mem_use = True - self._write_data_names["solve_mem_use"] = False - self._logger.log_info_one_rank( - "Calculating memory usage of the solve call of each micro micro simulation will slow down the Micro Manager. This option is intended for diagnostic purposes." - ) - except BaseException: - self._logger.log_info_one_rank( - "Micro manager will not output memory usage for solving each micro simulation." - ) - def read_json_micro_manager(self): """ Reads Micro Manager relevant information from JSON configuration file @@ -484,17 +471,6 @@ def write_micro_solve_time(self): """ return self._output_micro_sim_time - def write_micro_mem_use(self): - """ - Depending on user input, micro manager will calculate memory usage of solve() step of every micro simulation - - Returns - ------- - output_micro_mem_use : bool - True if micro simulation memory usage is required. - """ - return self._output_micro_mem_use - def turn_on_adaptivity(self): """ Boolean stating whether adaptivity is ot or not. diff --git a/micro_manager/micro_manager.py b/micro_manager/micro_manager.py index 1de1d4c..06b0fd2 100644 --- a/micro_manager/micro_manager.py +++ b/micro_manager/micro_manager.py @@ -75,11 +75,6 @@ def __init__(self, config_file: str) -> None: self._is_micro_solve_time_required = self._config.write_micro_solve_time() - self._is_micro_solve_mem_use_required = self._config.write_micro_mem_use() - - # if self._is_micro_solve_mem_use_required: - # tracemalloc = importlib.import_module("tracemalloc") - self._macro_mesh_name = self._config.get_macro_mesh_name() self._macro_bounds = self._config.get_macro_domain_bounds() @@ -649,27 +644,20 @@ def _solve_micro_simulations(self, micro_sims_input: list, dt: float) -> tuple: """ micro_sims_output: list[dict] = [None] * self._local_number_of_sims - tracemalloc.start() - for count, sim in enumerate(self._micro_sims): # If micro simulation has not crashed in a previous iteration, attempt to solve it if not self._has_sim_crashed[count]: # Attempt to solve the micro simulation try: - _, pre_peak = tracemalloc.get_traced_memory() start_time = time.process_time() micro_sims_output[count] = sim.solve(micro_sims_input[count], dt) end_time = time.process_time() - _, post_peak = tracemalloc.get_traced_memory() # Write solve time of the macro simulation if required and the simulation has not crashed if self._is_micro_solve_time_required: micro_sims_output[count]["solve_cpu_time"] = ( end_time - start_time ) - if self._is_micro_solve_mem_use_required: - micro_sims_output[count]["solve_mem_use"] = post_peak - pre_peak - # If simulation crashes, log the error and keep the output constant at the previous iteration's output except Exception as error_message: self._logger.log_error_any_rank( @@ -710,8 +698,6 @@ def _solve_micro_simulations(self, micro_sims_input: list, dt: float) -> tuple: micro_sims_input, micro_sims_output, unset_sim ) - tracemalloc.reset_peak() - return micro_sims_output, 0.0 def _solve_micro_simulations_with_adaptivity( @@ -765,24 +751,17 @@ def _solve_micro_simulations_with_adaptivity( if not self._has_sim_crashed[active_id]: # Attempt to solve the micro simulation try: - _, pre_peak = tracemalloc.get_traced_memory() start_time = time.process_time() micro_sims_output[active_id] = self._micro_sims[active_id].solve( micro_sims_input[active_id], dt ) end_time = time.process_time() - _, post_peak = tracemalloc.get_traced_memory() # Write solve time of the macro simulation if required and the simulation has not crashed if self._is_micro_solve_time_required: micro_sims_output[active_id]["solve_cpu_time"] = ( end_time - start_time ) - if self._is_micro_solve_mem_use_required: - micro_sims_output[active_id]["solve_mem_use"] = ( - post_peak - pre_peak - ) - # Mark the micro sim as active for export micro_sims_output[active_id]["active_state"] = 1 micro_sims_output[active_id][ @@ -849,9 +828,6 @@ def _solve_micro_simulations_with_adaptivity( if self._is_micro_solve_time_required: micro_sims_output[inactive_id]["solve_cpu_time"] = 0 - if self._is_micro_solve_mem_use_required: - micro_sims_output[inactive_id]["solve_mem_use"] = 0 - # Collect micro sim output for adaptivity calculation for i in range(self._local_number_of_sims): for name in self._adaptivity_micro_data_names: