Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ dependencies = [
"gitpython>=3.1.45",
"hjson>=3.1.0",
"jinja2>=3.1.6",
"kaleido>=1.2.0",
"plotly>=6.7.0",
"psutil>=7.2.2",
"pydantic>=2.9.2",
"pyyaml>=6.0.2",
Expand Down
11 changes: 10 additions & 1 deletion src/dvsim/instrumentation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
JobMetrics,
SchedulerMetrics,
)
from dvsim.instrumentation.runtime import flush, get, set_instrumentation, set_report_path
from dvsim.instrumentation.runtime import (
flush,
gen_html_report,
get,
get_report,
set_instrumentation,
set_report_path,
)

__all__ = (
"InstrumentationAggregator",
Expand All @@ -23,7 +30,9 @@
"SchedulerInstrumentation",
"SchedulerMetrics",
"flush",
"gen_html_report",
"get",
"get_report",
"set_instrumentation",
"set_report_path",
)
2 changes: 2 additions & 0 deletions src/dvsim/instrumentation/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def get_job_data(self) -> Mapping[str, JobInstrumentationMetadata]:
job_type=spec.job_type,
target=spec.target,
tool=spec.tool.name,
block=spec.block.name,
block_variant=spec.block.variant,
backend=spec.backend,
dependencies=list(spec.dependencies),
status=status_str,
Expand Down
37 changes: 37 additions & 0 deletions src/dvsim/instrumentation/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
)

__all__ = (
"ConcreteJobTimingMetrics",
"InstrumentationMetrics",
"InstrumentationResults",
"JobComputeMetrics",
Expand Down Expand Up @@ -52,6 +53,8 @@ class JobInstrumentationMetadata(JobMetrics):
job_type: str
target: str
tool: str
block: str
block_variant: str | None
backend: str | None
dependencies: list[str]
status: str
Expand Down Expand Up @@ -112,6 +115,16 @@ def drop_computed_fields(cls, data: Any) -> Any: # noqa: ANN401
return data


class ConcreteJobTimingMetrics(JobMetrics):
"""Concrete job timing information with all known fields populated."""

model_config = ConfigDict(frozen=True, extra="ignore")

start_time: float
end_time: float
duration: float


# Compute Resource Metrics


Expand Down Expand Up @@ -178,3 +191,27 @@ class InstrumentationResults(BaseModel):

scheduler: SchedulerInstrumentationResults
jobs: dict[str, JobInstrumentationResults] = Field(default_factory=dict)

def job_timings(self) -> dict[str, ConcreteJobTimingMetrics]:
"""Get any job timing information that exists in the instrumentation report."""
return {
job_id: ConcreteJobTimingMetrics(
start_time=results.timing.start_time,
end_time=results.timing.end_time,
duration=(results.timing.end_time - results.timing.start_time),
)
for job_id, results in self.jobs.items()
if results.timing is not None
and results.timing.start_time is not None
and results.timing.end_time is not None
}

def get_run_time_info(self) -> tuple[float, float]:
"""Get the overall time, using job timing as a fallback if scheduler info is missing."""
timing = self.scheduler.timing
if timing is None or timing.start_time is None or timing.end_time is None:
job_timings = self.job_timings()
start_time = min((time.start_time for time in job_timings.values()), default=0.0)
end_time = max((time.end_time for time in job_timings.values()), default=0.0)
return start_time, end_time
return timing.start_time, timing.end_time
19 changes: 19 additions & 0 deletions src/dvsim/instrumentation/report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright lowRISC contributors (OpenTitan project).
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

"""DVSim Scheduler Instrumentation report."""

from dvsim.instrumentation.report.base import (
InstrumentationVisualizer,
RenderProfile,
render_html_report,
)
from dvsim.instrumentation.report.registry import ReportVisualizationRegistry

__all__ = (
"InstrumentationVisualizer",
"RenderProfile",
"ReportVisualizationRegistry",
"render_html_report",
)
Loading
Loading