Skip to content

Commit

Permalink
++
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipDeegan committed Dec 8, 2024
1 parent 2176713 commit aa3b325
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 25 deletions.
2 changes: 2 additions & 0 deletions phlop/app/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
phlop.app.cmake
phlop.app.test_cases
phlop.app.git
phlop.app.nvidia
phlop.app.pfm
phlop.app.perf"""

print(available_modules)
12 changes: 12 additions & 0 deletions phlop/app/nvidia/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
#
#
#
#


available_modules = """Available:
phlop.app.nvidia.csan
phlop.app.nvidia.ncucsan"""

print(available_modules)
18 changes: 10 additions & 8 deletions phlop/app/nvidia/csan.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
# compute-sanitizer --tool racecheck [sanitizer_options] app_name [app_options]
#
#
#

import os

from phlop.dict import ValDict
from phlop.proc import run, run_mp
from phlop.proc import run

metrics = [
"all",
Expand All @@ -20,13 +20,15 @@
]


def run(exe, events, output_file=None):
env = {}
cmd = f""
return run(record_cmd(exe, events, output_file), check=True)
def build_command(cli_args):
return f"compute-sanitizer --tool {cli_args.tool} {cli_args.remaining}"


def exec(cli_args):
return run(build_command(cli_args), check=True)


def cli_args_parser(description="Perf tool"):
def cli_args_parser(description="compute-sanitizer tool"):
import argparse

_help = ValDict(
Expand All @@ -45,7 +47,7 @@ def cli_args_parser(description="Perf tool"):
parser.add_argument("-d", "--dir", default=".", help=_help.dir)
parser.add_argument("-i", "--infiles", default=None, help=_help.infiles)
parser.add_argument("-o", "--outfile", default=None, help=_help.outfile)
parser.add_argument("-t", "--tool", default="stat", help=_help.tool)
parser.add_argument("-t", "--tool", default="memcheck", help=_help.tool)
parser.add_argument("--logging", type=int, default=1, help=_help.logging)
parser.add_argument("-e", "--extra", type=str, default="", help=_help.extra)

Expand Down
19 changes: 10 additions & 9 deletions phlop/app/nvidia/ncu.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# https://docs.nvidia.com/nsight-compute/ProfilingGuide/index.html

## samples
# ncu --help
# ncu --metrics all
# ncu --metrics l1tex__data_bank_conflicts_pipe_lsu_mem_shared_op_st.sum
#
# ncu --target-processes all -o <report-name> mpirun [mpi arguments] <app> [app arguments]
#

import os

from phlop.dict import ValDict
from phlop.proc import run, run_mp
from phlop.proc import run

metrics = [
"all",
Expand All @@ -20,14 +20,15 @@
]


def run(exe, events, output_file=None):
env = {}
cmd = f""
# ncu --target-processes all -o <report-name> mpirun [mpi arguments] <app> [app arguments]
return run(cmd, check=True)
def build_command(cli_args):
return f"ncu {cli_args.remaining}"


def exec(cli_args):
return run(build_command(cli_args), check=True)


def cli_args_parser(description="Perf tool"):
def cli_args_parser(description="ncu tool"):
import argparse

_help = ValDict(
Expand Down
12 changes: 12 additions & 0 deletions phlop/app/pfm/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
#
#
#
#


available_modules = """Available:
phlop.app.pfm.check_events
phlop.app.pfm.showevtinfo"""

print(available_modules)
27 changes: 23 additions & 4 deletions phlop/app/pfm/showevtinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


import logging
from dataclasses import dataclass, field, as_dict
from dataclasses import asdict, dataclass, field
from pathlib import Path

from phlop.os import pushd
Expand All @@ -32,7 +32,26 @@ class EVTInfo:
pmu: str
name: str
umask: dict = field(default_factory=lambda: {})
ect: dict = field(default_factory=lambda: {})
etc: dict = field(default_factory=lambda: {})


@dataclass
class EVTInfos:
data: list = field(default_factory=lambda: [])

def __iter__(self):
return self.data.__iter__()

def umasks(self):
return EVTInfos(data=[d for d in self.data if d.umask])

def umasks_in(self, needle):
return EVTInfos(
data=[d for d in self.data if any(needle in k for k in d.umask)]
)

def append(self, ev: EVTInfo):
self.data.append(ev)


def _parse_evtinfo(bits_list):
Expand All @@ -57,7 +76,7 @@ def parse_evtinfo_output(lines):
if line.strip() == EVTINFO_delimiter:
break

bits_list, results = [], []
bits_list, results = [], EVTInfos()
for line in lines[start_idx:]:
if line == EVTINFO_delimiter:
results.append(_parse_evtinfo(bits_list))
Expand All @@ -80,4 +99,4 @@ def get_evt_info():
if __name__ == "__main__":
import json

print(json.dumps(as_dict(get_evt_info()), tabs=2))
print(json.dumps(asdict(get_evt_info()), tabs=2))
7 changes: 3 additions & 4 deletions sh/clean.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/usr/bin/env bash
set -e
CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$CWD"/..
set -ex
CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" && cd "$CWD"/..

RM_RF=(
__pycache__
__pycache__ .ruff_cache phlop.egg-info dist
)

for RM in ${RM_RF[@]}; do
Expand Down

0 comments on commit aa3b325

Please sign in to comment.