Skip to content

Commit

Permalink
Add helper functions to run specifc profiling analysis, starting wth …
Browse files Browse the repository at this point in the history
…parallel scaling.
  • Loading branch information
micaeljtoliveira committed Feb 16, 2024
1 parent 59247a8 commit 3de72e6
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions om3utils/profiling_analyses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from pathlib import Path
import xarray as xr

from om3utils.payu_config_yaml import read_payu_config_yaml


def scaling_ncpus(run_dir):
config_file = Path(run_dir) / "config.yaml"
config = read_payu_config_yaml(config_file.as_posix())
return config["ncpus"]


def scaling_speedup(stats: xr.Dataset) -> xr.Dataset:
speedup = stats.tavg.sel(ncpus=stats["ncpus"].min()) / stats.tavg
speedup.name = "speedup"
return speedup


def scaling_efficiency(stats: xr.Dataset) -> xr.Dataset:
speedup = scaling_speedup(stats)
eff = speedup / speedup.ncpus * 100 * stats["ncpus"].min()
eff.name = "parallel efficiency [%]"
return eff

0 comments on commit 3de72e6

Please sign in to comment.