Skip to content

Commit b8d553c

Browse files
committed
fix: z01x sim tool build time parsing
Building z01x is logged with the same output as VCS (unlike running it) - so if we are not running explicitly, just defer to how the VCS tool parses the logs. To be able to tell what type of test we are running, expose the job specification to the sim tool when retrieving runtime information, as the underlying (sub)tools might be different for each phase. Signed-off-by: Alex Jones <[email protected]>
1 parent 3311a96 commit b8d553c

File tree

7 files changed

+36
-14
lines changed

7 files changed

+36
-14
lines changed

src/dvsim/launcher/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def _find_patterns(patterns: Sequence[str], line: str) -> Sequence[str] | None:
340340
plugin = get_sim_tool_plugin(tool=self.job_spec.tool.name)
341341

342342
try:
343-
time, unit = plugin.get_job_runtime(log_text=lines)
343+
time, unit = plugin.get_job_runtime(self.job_spec, log_text=lines)
344344

345345
except RuntimeError as e:
346346
log.warning(
@@ -353,7 +353,7 @@ def _find_patterns(patterns: Sequence[str], line: str) -> Sequence[str] | None:
353353

354354
if self.job_spec.job_type == "RunTest":
355355
try:
356-
time, unit = plugin.get_simulated_time(log_text=lines)
356+
time, unit = plugin.get_simulated_time(self.job_spec, log_text=lines)
357357
self.simulated_time.set(time, unit)
358358
except RuntimeError as e:
359359
log.debug("%s: %s", self.job_spec.full_name, str(e))

src/dvsim/runtime/backend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,15 +355,15 @@ def get_runtime_from_logs(self) -> tuple[JobTime | None, JobTime | None]:
355355

356356
runtime = None
357357
try:
358-
time, unit = plugin.get_job_runtime(log_text=lines)
358+
time, unit = plugin.get_job_runtime(self.spec, log_text=lines)
359359
runtime = JobTime(time, unit)
360360
except RuntimeError as e:
361361
log.warning("%s: %s", self.spec.full_name, str(e))
362362

363363
simulated_time = None
364364
if self.spec.job_type == "RunTest":
365365
try:
366-
time, unit = plugin.get_simulated_time(log_text=lines)
366+
time, unit = plugin.get_simulated_time(self.spec, log_text=lines)
367367
simulated_time = JobTime(time, unit)
368368
except RuntimeError as e:
369369
log.debug("%s: %s", self.spec.full_name, str(e))

src/dvsim/sim/tool/base.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from pathlib import Path
99
from typing import TYPE_CHECKING, Protocol, runtime_checkable
1010

11+
from dvsim.job.data import JobSpec
1112
from dvsim.sim.data import CoverageMetrics
1213

1314
if TYPE_CHECKING:
@@ -34,7 +35,7 @@ def get_cov_summary_table(cov_report_path: Path) -> tuple[Sequence[Sequence[str]
3435
...
3536

3637
@staticmethod
37-
def get_job_runtime(log_text: Sequence[str]) -> tuple[float, str]:
38+
def get_job_runtime(job: JobSpec, log_text: Sequence[str]) -> tuple[float, str]:
3839
"""Return the job runtime (wall clock time) along with its units.
3940
4041
EDA tools indicate how long the job ran in terms of CPU time in the log
@@ -43,6 +44,7 @@ def get_job_runtime(log_text: Sequence[str]) -> tuple[float, str]:
4344
units as a tuple.
4445
4546
Args:
47+
job: The job that was run.
4648
log_text: is the job's log file contents as a list of lines.
4749
4850
Returns:
@@ -55,7 +57,7 @@ def get_job_runtime(log_text: Sequence[str]) -> tuple[float, str]:
5557
...
5658

5759
@staticmethod
58-
def get_simulated_time(log_text: Sequence[str]) -> tuple[float, str]:
60+
def get_simulated_time(job: JobSpec, log_text: Sequence[str]) -> tuple[float, str]:
5961
"""Return the simulated time along with its units.
6062
6163
EDA tools indicate how long the design was simulated for in the log file.
@@ -64,6 +66,7 @@ def get_simulated_time(log_text: Sequence[str]) -> tuple[float, str]:
6466
units (typically, pico|nano|micro|milliseconds) as a tuple.
6567
6668
Args:
69+
job: The job that was run
6770
log_text: is the job's log file contents as a list of lines.
6871
6972
Returns:

src/dvsim/sim/tool/vcs.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from pathlib import Path
1010
from typing import TYPE_CHECKING
1111

12+
from dvsim.job.data import JobSpec
1213
from dvsim.sim.data import CodeCoverageMetrics, CoverageMetrics
1314

1415
if TYPE_CHECKING:
@@ -55,7 +56,7 @@ def get_cov_summary_table(cov_report_path: Path) -> tuple[Sequence[Sequence[str]
5556
raise RuntimeError(msg)
5657

5758
@staticmethod
58-
def get_job_runtime(log_text: Sequence[str]) -> tuple[float, str]:
59+
def get_job_runtime(_job: JobSpec, log_text: Sequence[str]) -> tuple[float, str]:
5960
"""Return the job runtime (wall clock time) along with its units.
6061
6162
EDA tools indicate how long the job ran in terms of CPU time in the log
@@ -64,6 +65,7 @@ def get_job_runtime(log_text: Sequence[str]) -> tuple[float, str]:
6465
units as a tuple.
6566
6667
Args:
68+
job: The job that was run.
6769
log_text: is the job's log file contents as a list of lines.
6870
6971
Returns:
@@ -82,7 +84,7 @@ def get_job_runtime(log_text: Sequence[str]) -> tuple[float, str]:
8284
raise RuntimeError(msg)
8385

8486
@staticmethod
85-
def get_simulated_time(log_text: Sequence[str]) -> tuple[float, str]:
87+
def get_simulated_time(_job: JobSpec, log_text: Sequence[str]) -> tuple[float, str]:
8688
"""Return the simulated time along with its units.
8789
8890
EDA tools indicate how long the design was simulated for in the log file.
@@ -91,6 +93,7 @@ def get_simulated_time(log_text: Sequence[str]) -> tuple[float, str]:
9193
units (typically, pico|nano|micro|milliseconds) as a tuple.
9294
9395
Args:
96+
job: The job that was run
9497
log_text: is the job's log file contents as a list of lines.
9598
9699
Returns:

src/dvsim/sim/tool/xcelium.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pathlib import Path
1111
from typing import TYPE_CHECKING
1212

13+
from dvsim.job.data import JobSpec
1314
from dvsim.sim.data import CodeCoverageMetrics, CoverageMetrics
1415

1516
if TYPE_CHECKING:
@@ -83,7 +84,7 @@ def get_cov_summary_table(cov_report_path: Path) -> tuple[Sequence[Sequence[str]
8384
raise RuntimeError(msg)
8485

8586
@staticmethod
86-
def get_job_runtime(log_text: Sequence[str]) -> tuple[float, str]:
87+
def get_job_runtime(_job: JobSpec, log_text: Sequence[str]) -> tuple[float, str]:
8788
"""Return the job runtime (wall clock time) along with its units.
8889
8990
EDA tools indicate how long the job ran in terms of CPU time in the log
@@ -92,6 +93,7 @@ def get_job_runtime(log_text: Sequence[str]) -> tuple[float, str]:
9293
units as a tuple.
9394
9495
Args:
96+
job: The job that was run.
9597
log_text: is the job's log file contents as a list of lines.
9698
9799
Returns:
@@ -111,7 +113,7 @@ def get_job_runtime(log_text: Sequence[str]) -> tuple[float, str]:
111113
raise RuntimeError(msg)
112114

113115
@staticmethod
114-
def get_simulated_time(log_text: Sequence[str]) -> tuple[float, str]:
116+
def get_simulated_time(_job: JobSpec, log_text: Sequence[str]) -> tuple[float, str]:
115117
"""Return the simulated time along with its units.
116118
117119
EDA tools indicate how long the design was simulated for in the log file.
@@ -120,6 +122,7 @@ def get_simulated_time(log_text: Sequence[str]) -> tuple[float, str]:
120122
units (typically, pico|nano|micro|milliseconds) as a tuple.
121123
122124
Args:
125+
job: The job that was run
123126
log_text: is the job's log file contents as a list of lines.
124127
125128
Returns:

src/dvsim/sim/tool/z01x.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from collections.abc import Sequence
88
from typing import TYPE_CHECKING
99

10+
from dvsim.job.data import JobSpec
1011
from dvsim.sim.tool.vcs import VCS
1112

1213
if TYPE_CHECKING:
@@ -45,7 +46,7 @@ def _get_execution_summary(log_text: Sequence[str]) -> list[str]:
4546
raise RuntimeError(msg)
4647

4748
@staticmethod
48-
def get_job_runtime(log_text: Sequence[str]) -> tuple[float, str]:
49+
def get_job_runtime(job: JobSpec, log_text: Sequence[str]) -> tuple[float, str]:
4950
"""Return the job runtime (wall clock time) along with its units.
5051
5152
EDA tools indicate how long the job ran in terms of CPU time in the log
@@ -54,6 +55,7 @@ def get_job_runtime(log_text: Sequence[str]) -> tuple[float, str]:
5455
units as a tuple.
5556
5657
Args:
58+
job: The job that was run.
5759
log_text: is the job's log file contents as a list of lines.
5860
5961
Returns:
@@ -63,6 +65,9 @@ def get_job_runtime(log_text: Sequence[str]) -> tuple[float, str]:
6365
RuntimeError: exception if the search pattern is not found.
6466
6567
"""
68+
if job.target != "run":
69+
return VCS.get_job_runtime(job, log_text)
70+
6671
summary_totals = Z01X._get_execution_summary(log_text)
6772
if len(summary_totals) < Z01X.REQUIRED_COLS:
6873
msg = f"Summary table contained less columns ({len(summary_totals)}) than expected"
@@ -75,7 +80,7 @@ def get_job_runtime(log_text: Sequence[str]) -> tuple[float, str]:
7580
raise RuntimeError(msg) from e
7681

7782
@staticmethod
78-
def get_simulated_time(log_text: Sequence[str]) -> tuple[float, str]:
83+
def get_simulated_time(job: JobSpec, log_text: Sequence[str]) -> tuple[float, str]:
7984
"""Return the simulated time along with its units.
8085
8186
EDA tools indicate how long the design was simulated for in the log file.
@@ -84,6 +89,7 @@ def get_simulated_time(log_text: Sequence[str]) -> tuple[float, str]:
8489
units (typically, pico|nano|micro|milliseconds) as a tuple.
8590
8691
Args:
92+
job: The job that was run
8793
log_text: is the job's log file contents as a list of lines.
8894
8995
Returns:
@@ -93,6 +99,9 @@ def get_simulated_time(log_text: Sequence[str]) -> tuple[float, str]:
9399
RuntimeError: exception if the search pattern is not found.
94100
95101
"""
102+
if job.target != "run":
103+
return VCS.get_job_runtime(job, log_text)
104+
96105
summary_totals = Z01X._get_execution_summary(log_text)
97106
if len(summary_totals) < Z01X.REQUIRED_COLS:
98107
msg = f"Summary table contained less columns ({len(summary_totals)}) than expected"

tests/tool/test_vcs.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
"""Test the VCS tool plugin."""
66

77
from collections.abc import Sequence
8+
from pathlib import Path
89

910
import pytest
1011
from hamcrest import assert_that, equal_to
1112

1213
from dvsim.tool.utils import get_sim_tool_plugin
14+
from tests.test_scheduler import job_spec_factory
1315

1416
__all__ = ("TestVCSToolPlugin",)
1517

@@ -40,16 +42,18 @@ class TestVCSToolPlugin:
4042
(5.5134, "PS"),
4143
],
4244
)
43-
def test_get_simulated_time(time: int, units: str) -> None:
45+
def test_get_simulated_time(tmp_path: Path, time: int, units: str) -> None:
4446
"""Test that sim plugins can be retrieved correctly."""
4547
plugin = get_sim_tool_plugin("vcs")
48+
mock_job_spec = job_spec_factory(tmp_path)
4649

4750
assert_that(
4851
plugin.get_simulated_time(
52+
mock_job_spec,
4953
log_text=fake_log(
5054
sim_time=time,
5155
sim_time_units=units,
52-
)
56+
),
5357
),
5458
equal_to((time, units.lower())),
5559
)

0 commit comments

Comments
 (0)