Skip to content

Commit

Permalink
Log total run time in minutes.
Browse files Browse the repository at this point in the history
  • Loading branch information
lohedges committed Nov 1, 2024
1 parent e681e58 commit 9104f54
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
10 changes: 10 additions & 0 deletions src/somd2/runner/_repex.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,14 @@ def run(self):
"""

from math import ceil
from time import time

from concurrent.futures import ThreadPoolExecutor as _ThreadPoolExecutor
from itertools import repeat as _repeat

# Record the start time.
start = time()

# Work out the number of repex cycles.
cycles = ceil(self._config.runtime / self._config.energy_frequency)

Expand Down Expand Up @@ -407,6 +411,12 @@ def run(self):
if is_checkpoint:
block += 1

# Record the end time.
end = time()

# Log the run time in minutes.
_logger.success(f"Simulation finished. Run time: {(end - start) / 60:.2f} minutes")

def _run_block(
self, index, lambdas, is_checkpoint, is_final_block, block, num_blocks
):
Expand Down
19 changes: 9 additions & 10 deletions src/somd2/runner/_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,12 @@ def _zero_gpu_devices(devices):
def run(self):
"""
Use concurrent.futures to run lambda windows in parallel
"""

Returns
--------
from time import time

results : [bool]
List of simulation results. (Currently whether the simulation finished
successfully or not.)
"""
results = self._manager.list()
# Record the start time.
start = time()

# Create shared resources.
self._create_shared_resources()
Expand Down Expand Up @@ -184,16 +181,18 @@ def run(self):
_logger.error(
f"Exception raised for {_lam_sym} = {lambda_value}: {e}"
)
with self._lock:
results.append(result)

# Kill all current and future jobs if keyboard interrupt.
except KeyboardInterrupt:
_logger.error("Cancelling job...")
for pid in executor._processes:
executor._processes[pid].terminate()

return results
# Record the end time.
end = time()

# Log the run time in minutes.
_logger.success(f"Simulation finished. Run time: {(end - start) / 60:.2f} minutes")

def run_window(self, index):
"""
Expand Down

0 comments on commit 9104f54

Please sign in to comment.