Skip to content

Commit 4423e63

Browse files
authored
Do not checkpoint adaptivity and fix output of memory usage (#166)
* Do not checkpoint adaptivity and fix output of memory usage * Remove checkpointing completely * Add CHANGELOG entry
1 parent 3ad8c1b commit 4423e63

File tree

4 files changed

+10
-54
lines changed

4 files changed

+10
-54
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## latest
44

5+
- Remove checkpointing of adaptivity and fix output of memory usage https://github.com/precice/micro-manager/pull/166
56
- Performance improvements: restricting data types, in-place modifications https://github.com/precice/micro-manager/pull/162
67
- Handle adaptivity case when deactivation and activation happens in the same time window https://github.com/precice/micro-manager/pull/165
78
- Add command line input argument to set log file https://github.com/precice/micro-manager/pull/163

micro_manager/adaptivity/global_adaptivity.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -234,27 +234,6 @@ def log_metrics(self, n: int) -> None:
234234
)
235235
)
236236

237-
def write_checkpoint(self) -> None:
238-
"""
239-
Write checkpoint.
240-
"""
241-
self._similarity_dists_cp = np.copy(self._similarity_dists)
242-
self._is_sim_active_cp = np.copy(self._is_sim_active)
243-
self._sim_is_associated_to_cp = np.copy(self._sim_is_associated_to)
244-
245-
def read_checkpoint(self) -> None:
246-
"""
247-
Read checkpoint.
248-
"""
249-
self._similarity_dists = np.copy(self._similarity_dists_cp)
250-
del self._similarity_dists_cp
251-
252-
self._is_sim_active = np.copy(self._is_sim_active_cp)
253-
del self._is_sim_active_cp
254-
255-
self._sim_is_associated_to = np.copy(self._sim_is_associated_to_cp)
256-
del self._sim_is_associated_to_cp
257-
258237
def _communicate_micro_output(
259238
self,
260239
micro_output: list,

micro_manager/adaptivity/local_adaptivity.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,22 +179,6 @@ def log_metrics(self, n: int) -> None:
179179
)
180180
)
181181

182-
def write_checkpoint(self) -> None:
183-
"""
184-
Write checkpoint.
185-
"""
186-
self._similarity_dists_cp = np.copy(self._similarity_dists)
187-
self._is_sim_active_cp = np.copy(self._is_sim_active)
188-
self._sim_is_associated_to_cp = np.copy(self._sim_is_associated_to)
189-
190-
def read_checkpoint(self) -> None:
191-
"""
192-
Read checkpoint.
193-
"""
194-
self._similarity_dists = np.copy(self._similarity_dists_cp)
195-
self._is_sim_active = np.copy(self._is_sim_active_cp)
196-
self._sim_is_associated_to = np.copy(self._sim_is_associated_to_cp)
197-
198182
def _update_inactive_sims(self, micro_sims: list) -> None:
199183
"""
200184
Update set of inactive micro simulations. Each inactive micro simulation is compared to all active ones

micro_manager/micro_manager.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,6 @@ def solve(self) -> None:
212212
self._data_for_adaptivity,
213213
)
214214

215-
# Only checkpoint the adaptivity configuration if adaptivity is computed
216-
# once in every time window
217-
self._adaptivity_controller.write_checkpoint()
218-
219215
active_sim_ids = self._adaptivity_controller.get_active_sim_ids()
220216

221217
for active_id in active_sim_ids:
@@ -272,11 +268,6 @@ def solve(self) -> None:
272268
t = t_checkpoint
273269
first_iteration = False
274270

275-
# If adaptivity is computed only once per time window, the states of sims need to be reset too
276-
if self._is_adaptivity_on:
277-
if not self._adaptivity_in_every_implicit_step:
278-
self._adaptivity_controller.read_checkpoint()
279-
280271
if (
281272
self._participant.is_time_window_complete()
282273
): # Time window has converged, now micro output can be generated
@@ -294,14 +285,15 @@ def solve(self) -> None:
294285

295286
self._logger.log_info_rank_zero("Time window {} converged.".format(n))
296287

297-
mem_usage_output_file = (
298-
self._output_dir + "mem_usage_" + str(self._rank) + ".csv"
299-
)
300-
with open(mem_usage_output_file, mode="w", newline="") as file:
301-
writer = csv.writer(file)
302-
writer.writerow(["Time window", "RSS (MB)"])
303-
for i, rss_mb in enumerate(mem_usage):
304-
writer.writerow([i, rss_mb])
288+
if self._output_memory_usage:
289+
mem_usage_output_file = (
290+
self._output_dir + "mem_usage_" + str(self._rank) + ".csv"
291+
)
292+
with open(mem_usage_output_file, mode="w", newline="") as file:
293+
writer = csv.writer(file)
294+
writer.writerow(["Time window", "RSS (MB)"])
295+
for i, rss_mb in enumerate(mem_usage):
296+
writer.writerow([i, rss_mb])
305297

306298
self._participant.finalize()
307299

0 commit comments

Comments
 (0)