Skip to content

Commit

Permalink
validate: profile CUDA commands using nvprof
Browse files Browse the repository at this point in the history
  • Loading branch information
romnn committed Sep 1, 2023
1 parent 4bbe88f commit 7e979f5
Show file tree
Hide file tree
Showing 33 changed files with 1,242 additions and 185 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ matplotlib = "*"
numpy = "*"
scipy = "*"
pandas = "*"
jupyterlab = "*"
wasabi = "*"
click = "*"

[dev-packages]
invoke = "*"
flake8 = "*"
black = "*"
jupyterlab = "*"
mypy = "*"
11 changes: 3 additions & 8 deletions WIP.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#### TODO

- notes

- l2 cache is shared in sub partitions, we get different l2 metrics
- l1i are the same always, as they are local to the core

- today:

- record mem fetch latency in playground and box
- write trait for tag array
- convert, match and plot statistics
- rename crates and github repo
- publish to crates.io
- record mem fetch latency in playground and box
- DONE: write trait for tag array

- TODO:

Expand All @@ -21,7 +17,6 @@
- use traits for common components
- record mem fetch latency
- add a few more stats
- plot statistics
- publish python package to pip

- tomorrow:
Expand Down
12 changes: 7 additions & 5 deletions accelsim/src/stats.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use color_eyre::eyre;
use std::collections::HashMap;
use utils::box_slice;

pub type Stat = (String, u16, String);
pub type Map = indexmap::IndexMap<Stat, f64>;
Expand Down Expand Up @@ -102,7 +103,7 @@ impl TryFrom<Stats> for stats::Stats {
.into_iter()
.collect();

let mut l2d_stats = stats::PerCache(vec![stats::Cache::default(); 1].into_boxed_slice());
let mut l2d_stats = stats::PerCache(box_slice![stats::Cache::default(); 1]);
let l2d_total = &mut l2d_stats[0];
for kind in AccessKind::iter() {
for reservation_failure in ReservationFailure::iter() {
Expand Down Expand Up @@ -160,10 +161,11 @@ impl TryFrom<Stats> for stats::Stats {
},
accesses: stats::Accesses(accesses),
dram: stats::DRAM {
bank_writes: vec![vec![vec![total_dram_writes]]],
bank_reads: vec![vec![vec![total_dram_reads]]],
total_bank_writes: vec![vec![total_dram_writes]],
total_bank_reads: vec![vec![total_dram_reads]],
bank_writes: box_slice![box_slice![box_slice![total_dram_writes]]],
bank_reads: box_slice![box_slice![box_slice![total_dram_reads]]],
total_bank_writes: box_slice![box_slice![total_dram_writes]],
total_bank_reads: box_slice![box_slice![total_dram_reads]],
..stats::DRAM::default()
},
instructions: stats::InstructionCounts::default(),
l1i_stats: stats::PerCache::new(0),
Expand Down
4 changes: 2 additions & 2 deletions benches/vectoradd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ pub fn box_benchmark(c: &mut Criterion) {
}

criterion::criterion_group!(benches, box_benchmark, play_benchmark, accelsim_benchmark);
// criterion::criterion_main!(benches);
criterion::criterion_main!(benches);

#[allow(dead_code)]
fn main() -> eyre::Result<()> {
fn main_other() -> eyre::Result<()> {
use itertools::Itertools;
#[allow(unused_imports)]
use std::io::Write;
Expand Down
3 changes: 3 additions & 0 deletions gpucachesim/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from pathlib import Path

ROOT_DIR = Path(__file__).parent
42 changes: 42 additions & 0 deletions gpucachesim/benchmarks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import click
import yaml
from pathlib import Path
from os import PathLike
from typing import Optional

from gpucachesim import ROOT_DIR

REPO_ROOT_DIR = ROOT_DIR.parent
DEFAULT_BENCH_FILE = REPO_ROOT_DIR / "test-apps/test-apps-materialized.yml"


class Benchmarks:
def __init__(self, path: PathLike) -> None:
"""load the materialized benchmark config"""

with open(path or DEFAULT_BENCH_FILE, "rb") as f:
benchmarks = yaml.safe_load(f)

self.benchmarks = benchmarks["benchmarks"]

def __getitem__(self, bench_name: str):
return self.benchmarks[bench_name]

def get_bench_config(self, bench_name: str, input_idx: int):
return self.benchmarks[bench_name][input_idx]


@click.command()
@click.option("--path", default=DEFAULT_BENCH_FILE, help="Path to materialized benchmark config")
def main(path):
from pprint import pprint

print(path)
b = Benchmarks(path)

benchmark_names = list(b.benchmarks.keys())
pprint(benchmark_names)


if __name__ == "__main__":
main()
27 changes: 27 additions & 0 deletions gpucachesim/stats/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import click

import gpucachesim.stats.stats as stats
import gpucachesim.stats.native as native
from gpucachesim.benchmarks import Benchmarks


@click.command()
@click.option("--path", help="Path to materialized benchmark config")
@click.option("--bench", help="Benchmark name")
@click.option("--input", default=0, help="Input index")
def main(path, bench, input):
from pprint import pprint

b = Benchmarks(path)
if bench is None:
raise NotImplemented
print(bench, input)
bench_config = b.get_bench_config(bench, input)
# pprint(bench_config)

our_stats = stats.Stats(bench_config["simulate"])
native_stats = native.Stats(bench_config["simulate"])


if __name__ == "__main__":
main()
2 changes: 2 additions & 0 deletions gpucachesim/stats/accelsim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class AccelsimStats:
pass
6 changes: 6 additions & 0 deletions gpucachesim/stats/native.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from os import PathLike


class Stats:
def __init__(self, result_dir: PathLike) -> None:
self.path = result_dir
6 changes: 6 additions & 0 deletions gpucachesim/stats/stats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from os import PathLike


class Stats:
def __init__(self, result_dir: PathLike) -> None:
self.path = result_dir
Loading

0 comments on commit 7e979f5

Please sign in to comment.