Skip to content

Commit

Permalink
Remove code pertaining to the Micro Manager measuring memory consumpt…
Browse files Browse the repository at this point in the history
…ion of the micro simulation
  • Loading branch information
IshaanDesai committed Dec 23, 2024
1 parent 9e18be2 commit f898d43
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 48 deletions.
24 changes: 0 additions & 24 deletions micro_manager/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
24 changes: 0 additions & 24 deletions micro_manager/micro_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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][
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit f898d43

Please sign in to comment.