Skip to content

Commit

Permalink
validate: implement query for benchmark configs
Browse files Browse the repository at this point in the history
  • Loading branch information
romnn committed Sep 7, 2023
1 parent 9eac2c9 commit addd677
Show file tree
Hide file tree
Showing 7 changed files with 312 additions and 73 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

- today:

- change bench configs to allow queries for benchmarks instead of input indices
- change lockstep tests to use bench configs
- check accelsim compat again

- use gpu_mem_alloc for the allocations but still allow smart comparision with play whose traces does not include allocations
- xtask task for converting traces? or do that in the validation component

Expand All @@ -26,6 +30,7 @@
- convert, match and plot statistics
- record mem fetch latency in playground and box

- DONE: rename translated address to either DRAMAddress or PhysicalAddress
- DONE: fix that cache index unwrapping design
- DONE: playground stats (should match accelsim)
- DONE: builder for mem access as well
Expand Down
2 changes: 1 addition & 1 deletion test-apps/test-apps-materialized.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
##
## AUTO GENERATED! DO NOT EDIT
##
## this configuration was materialized from /home/roman/dev/box/test-apps/test-apps.yml on 06/09/2023 20:34:21
## this configuration was materialized from /home/roman/dev/box/test-apps/test-apps.yml on 07/09/2023 12:42:48
##

config:
Expand Down
1 change: 1 addition & 0 deletions validate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ color-eyre = "0"
tokio = { version = "1", features = ["full"] }
dotenv = "0"
serde = { version = "1", features = ["derive"] }
serde_path_to_error = "0"
csv = "1"
serde_json = { version = "1", features = ["preserve_order"] }
serde_yaml = "0"
Expand Down
15 changes: 8 additions & 7 deletions validate/src/benchmark/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,20 +210,21 @@ impl Matrix {
}
}

#[macro_export]
macro_rules! yaml {
($($yaml:tt)+) => {{
let json = serde_json::json!($($yaml)+);
serde_json::from_value(json)?
}};
}

#[allow(clippy::unnecessary_wraps)]
#[cfg(test)]
mod tests {
use super::{Input, Matrix};
use color_eyre::eyre;
use pretty_assertions_sorted as diff;

macro_rules! yaml {
($($yaml:tt)+) => {{
let json = serde_json::json!($($yaml)+);
serde_json::from_value(json)?
}};
}

#[test]
fn parse_empty_matrix() -> eyre::Result<()> {
diff::assert_eq!(serde_yaml::from_str::<Matrix>(r#" "#)?, Matrix::default());
Expand Down
29 changes: 23 additions & 6 deletions validate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ use serde::{Deserialize, Serialize};
use smart_default::SmartDefault;
use std::path::{Path, PathBuf};

pub use crate::yaml as input;

#[derive(thiserror::Error, Debug)]
pub enum RunError {
#[error("benchmark skipped")]
Expand Down Expand Up @@ -57,6 +59,13 @@ pub fn bool_true() -> bool {
true
}

#[derive(thiserror::Error, Debug)]
#[error("failed to parse `{path:?}`")]
pub struct DeserializeError {
pub source: serde_yaml::Error,
pub path: Option<String>,
}

#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error(transparent)]
Expand All @@ -65,17 +74,19 @@ pub enum Error {
#[error(transparent)]
Fs(#[from] utils::fs::Error),

// #[error(transparent)]
// YAML(#[from] serde_yaml::Error),
#[error(transparent)]
YAML(#[from] serde_yaml::Error),
Deserialize(#[from] DeserializeError),

#[error(transparent)]
Template(#[from] template::Error),

#[error(transparent)]
Shell(#[from] benchmark::ShellParseError),

#[error("missing value: {0}")]
Missing(String),
#[error("could not resolve key: {key:?} for target {target:?}")]
Missing { target: String, key: String },

#[error("cannot use a relative base: {0:?}")]
RelativeBase(PathBuf),
Expand Down Expand Up @@ -278,9 +289,15 @@ impl Benchmarks {
Ok(benchmarks)
}

pub fn from_reader(reader: impl std::io::BufRead) -> Result<Self, Error> {
let benches = serde_yaml::from_reader(reader)?;
Ok(benches)
pub fn from_reader(reader: impl std::io::BufRead) -> Result<Self, DeserializeError> {
let deser = serde_yaml::Deserializer::from_reader(reader);
serde_path_to_error::deserialize(deser).map_err(|source| {
let path = source.path().to_string();
DeserializeError {
source: source.into_inner(),
path: Some(path),
}
})
}
}

Expand Down
Loading

0 comments on commit addd677

Please sign in to comment.