Skip to content

Commit

Permalink
Basic log parsing tool
Browse files Browse the repository at this point in the history
Add numpy to setup
  • Loading branch information
FlorianDeconinck committed Jul 31, 2023
1 parent f78e246 commit 91b64bb
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 27 deletions.
8 changes: 6 additions & 2 deletions geosongpu_ci/pipeline/held_suarez.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from geosongpu_ci.pipeline.geos import set_python_environment
from geosongpu_ci.pipeline.gtfv3_config import GTFV3Config
from geosongpu_ci.utils.progress import Progress
from geosongpu_ci.tools.benchmark import parse_geos_log, report
from geosongpu_ci.tools.benchmark.geos_log_parser import parse_geos_log
from geosongpu_ci.tools.benchmark.report import report
from typing import Dict, Any, Optional
import shutil
import os
Expand Down Expand Up @@ -361,10 +362,13 @@ def check(
bench_raw_data = []
for log in logs:
shutil.copy(log, benchmark_artifact)
if ".0.out" in log:
# Grab all rank 0 that are not caching runs
if ".0.out" in log and "cache" not in log:
bench_raw_data.append(parse_geos_log(log))
benchmark_report = report(bench_raw_data)
print(benchmark_report)
with open(f"{benchmark_artifact}/report_benchmark.out", "w") as f:
f.write(str(benchmark_report))

return True

Expand Down
2 changes: 0 additions & 2 deletions geosongpu_ci/tools/benchmark/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
from .geos_log_parser import geos_log_parser
from .report import report, BenchmarkReport
20 changes: 11 additions & 9 deletions geosongpu_ci/tools/benchmark/geos_log_parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from geosongpu_ci.tools.benchmark import BenchmarkRawData
from geosongpu_ci.tools.benchmark.raw_data import BenchmarkRawData
from typing import Iterable, Optional
import re

Expand Down Expand Up @@ -50,11 +50,12 @@ def parse_geos_log(filename: str) -> BenchmarkRawData:
benchmark.backend = "fortran"
else:
backend_pattern = "backend: "
benchmark.backend = (
_grep(filename, backend_pattern, exclude_pattern=True)[0]
.strip()
.replace("\n", "")
)
grepped = _grep(filename, backend_pattern, exclude_pattern=True)
if grepped == []:
benchmark.backend = "gtfv3 (details failed to parse)"
else:
backend = grepped[0].strip().replace("\n", "")
benchmark.backend = f"gtfv3: ({backend})"

# Get timings of FV
if is_gtfv3:
Expand Down Expand Up @@ -118,9 +119,10 @@ def parse_geos_log(filename: str) -> BenchmarkRawData:
end_pattern=superdyn_profiler_exit,
)
)
benchmark.fv_gridcomp_detailed_profiling.append(
(shortname, measures[4], parent)
)
if measures != []:
benchmark.fv_gridcomp_detailed_profiling.append(
(shortname, measures[4], parent)
)

# Model throughput
gloabl_profiler_entry = "profiler: Model Throughput"
Expand Down
15 changes: 15 additions & 0 deletions geosongpu_ci/tools/benchmark/raw_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from dataclasses import dataclass, field
from typing import Tuple, Iterable, List


@dataclass
class BenchmarkRawData:
backend: str = ""
grid_resolution: Tuple[int, int, int] = (0, 0, 0) # nx / ny / nz
node_setup: Tuple[int, int, int] = (0, 0, 0) # NX / NY / Total ranks used
global_run_time: float = 0 # seconds fort the global RUN
fv_dyncore_timings: Iterable[float] = field(default_factory=list) # seconds
inner_dycore_timings: Iterable[float] = field(default_factory=list) # seconds
fv_gridcomp_detailed_profiling: List[Tuple[str, float]] = field(
default_factory=list
)
16 changes: 2 additions & 14 deletions geosongpu_ci/tools/benchmark/report.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
import itertools
from typing import Any, Iterable, Tuple, List
from typing import Any, List
from dataclasses import dataclass, field
import numpy as np


@dataclass
class BenchmarkRawData:
backend: str = ""
grid_resolution: Tuple[int, int, int] = (0, 0, 0) # nx / ny / nz
node_setup: Tuple[int, int, int] = (0, 0, 0) # NX / NY / Total ranks used
global_run_time: float = 0 # seconds fort the global RUN
fv_dyncore_timings: Iterable[float] = field(default_factory=list) # seconds
inner_dycore_timings: Iterable[float] = field(default_factory=list) # seconds
fv_gridcomp_detailed_profiling: List[Tuple[str, float]] = field(
default_factory=list
)
from geosongpu_ci.tools.benchmark.raw_data import BenchmarkRawData


@dataclass
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
install_requires=[
"pyyaml",
"click",
"numpy",
],
data_files=[
("./geosongpu/experiments", ["./experiments/experiments.yaml"]),
Expand Down

0 comments on commit 91b64bb

Please sign in to comment.