reprospect.tools.nsys module

class reprospect.tools.nsys.Cacher(*, directory: str | Path | None = None)View on GitHub

Bases: Cacher

Cacher tailored to nsys results.

nsys runs require quite some time to acquire results.

On a cache hit, the cacher will serve:

  • .nsys-rep file

  • .sqlite file

On a cache miss, nsys is launched and the cache entry populated accordingly.

Note

It is assumed that hashing is faster than running nsys itself.

Warning

The cache should not be shared between machines, since there may be differences between machines that influence the results but are not included in the hashing.

TABLE: ClassVar[str] = 'nsys'

Name of the table.

__init__(*, directory: str | Path | None = None)View on GitHub
static export_to_sqlite(command: Command, entry: Entry, **kwargs) PathView on GitHub

Export report to .sqlite.

hash(**kwargs) blake3View on GitHub
hash_impl(*, command: Command) blake3View on GitHub

Hash based on:

  • nsys version

  • nsys options (but not the output files)

  • executable content

  • executable arguments

  • linked libraries

  • environment

populate(directory: Path, **kwargs) NoneView on GitHub

When there is a cache miss, call reprospect.tools.nsys.Session.run(). Fill the directory with the artifacts.

run(command: Command, **kwargs) EntryView on GitHub

On a cache hit, copy files from the cache entry.

class reprospect.tools.nsys.Command(*, executable: str | Path, output: Path, opts: tuple[str, ...] = (), nvtx_capture: str | None = None, capture_range_end: str = 'stop', args: tuple[str | Path, ...] | None = None, env: Mapping[str, str] | None = None)View on GitHub

Bases: object

Run a nsys command line.

__init__(*, executable: str | Path, output: Path, opts: tuple[str, ...] = (), nvtx_capture: str | None = None, capture_range_end: str = 'stop', args: tuple[str | Path, ...] | None = None, env: Mapping[str, str] | None = None) None

Method generated by attrs for class Command.

args: tuple[str | Path, ...] | None

Arguments to pass to the executable.

capture_range_end: str

NVTX capture range end.

cmd: tuple[str | Path, ...]
env: Mapping[str, str] | None

Mapping used to update the environment before running, see run().

executable: str | Path

Executable to run.

nvtx_capture: str | None

NVTX capture string.

opts: tuple[str, ...]

Options that do not involve paths.

output: Path

Report file.

run(*, cwd: Path | None = None, env: MutableMapping[str, str] | None = None) intView on GitHub
class reprospect.tools.nsys.Report(*, db: Path)View on GitHub

Bases: object

Helper for reading the SQLite export of a nsys report.

__enter__() SelfView on GitHub
__exit__(*args, **kwargs) NoneView on GitHub
__init__(*, db: Path) NoneView on GitHub
classmethod get_correlated_row(*, src: DataFrame | Series, dst: DataFrame, selector: Callable[[DataFrame], Series] | None = None, correlation_src: str = 'correlationId', correlation_dst: str = 'correlationId') SeriesView on GitHub

Select a row from src, and return the row from dst that matches by correlation ID.

classmethod get_correlated_rows(*, src: DataFrame | Series, dst: DataFrame, selector: Callable[[DataFrame], Series] | None = None, correlation_src: str = 'correlationId', correlation_dst: str = 'correlationId') DataFrameView on GitHub

Similar to get_correlated_row(), but may match more than one row.

get_events(table: str, accessors: Sequence[str], stringids: str | None = 'nameId') DataFrameView on GitHub

Query all rows in table that happen between the start/end time points of the nested NVTX range matching accessors.

Parameters:

stringids – Some tables have a column to be correlated with the StringIds table.

Note

This replaces nsys stats whose –filter-nvtx is not powerful enough, as of CUDA 13.0.0.

property nvtx_events: ReportNvtxEventsView on GitHub

Get all NVTX events from the NVTX_EVENTS table.

Add a children column that contains for each event a list of child indices, preserving the hierarchy of the nested NVTX ranges.

Add a level column, starting from 0 for the root events.

Note

Nesting is determined based on start and end time points.

Note

Events recorded with registered strings will have there text field set to NULL, and its textId field set.

We correlate the textId with the StringIds if need be.

static single_row(*, data: DataFrame) SeriesView on GitHub

Check that data has one row, and squeeze it.

table(*, name: str, **kwargs) DataFrameView on GitHub

Get a table from the report.

property tables: list[str]View on GitHub

Tables in the report.

class reprospect.tools.nsys.ReportNvtxEvents(events: DataFrame)View on GitHub

Bases: TreeMixin

__init__(events: DataFrame) NoneView on GitHub
get(accessors: Sequence[str]) DataFrameView on GitHub

Find all nested NVTX events matching accessors.

to_tree() TreeView on GitHub
class reprospect.tools.nsys.ReportPatternSelector(pattern: str | Pattern[str], column: str = 'Name')View on GitHub

Bases: object

A pandas.DataFrame selector that returns which rows match a regex pattern in a specific column.

__init__(pattern: str | Pattern[str], column: str = 'Name') None
column: str
pattern: str | Pattern[str]
class reprospect.tools.nsys.Session(command: Command)View on GitHub

Bases: object

Nsight Systems session interface.

__init__(command: Command) None
command: Command
export_to_sqlite(cwd: Path | None = None) PathView on GitHub

Export report to .sqlite.

extract_statistical_report(report: str = 'cuda_api_sum', filter_nvtx: str | None = None, cwd: Path | None = None) DataFrameView on GitHub

Extract report, filtering the database with filter_nvtx.

run(cwd: Path | None = None, env: MutableMapping[str, str] | None = None) NoneView on GitHub

Run nsys using command.

reprospect.tools.nsys.strip_cuda_api_suffix(call: str) strView on GitHub

Strip suffix like _v10000 or _ptsz from a CUDA API call.