Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
romnn committed Sep 3, 2023
1 parent ccc41c0 commit ee88939
Show file tree
Hide file tree
Showing 23 changed files with 95 additions and 120 deletions.
6 changes: 2 additions & 4 deletions accelsim/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,12 @@ pub fn parse_stats(
("L1_WR_ALLOC_R", "l1_write_alloc_read"),
("L2_WR_ALLOC_R", "l2_write_alloc_read"),
];
let outcome = vec![
("HIT", "hit"),
let outcome = [("HIT", "hit"),
("HIT_RESERVED", "hit_reserved"),
("MISS", "miss"),
("RESERVATION_FAIL", "reservation_fail"),
("SECTOR_MISS", "sector_miss"),
("MSHR_HIT", "mshr_hit"),
];
("MSHR_HIT", "mshr_hit")];
let mut l2_cache_stats: Vec<_> = mem_space
.iter()
.cartesian_product(outcome.iter())
Expand Down
40 changes: 14 additions & 26 deletions accelsim/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl std::fmt::Display for Stats {
stats.sort_keys();

let mut s = f.debug_struct("Stats");
for ((current_kernel, running_kcount, stat_name), value) in stats.iter() {
for ((current_kernel, running_kcount, stat_name), value) in &stats {
s.field(
&format!("{current_kernel} / {running_kcount} / {stat_name}"),
value,
Expand All @@ -81,36 +81,24 @@ macro_rules! key {
};
}

#[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)]
fn convert_cache_stats(cache_name: &str, stats: &Stats) -> stats::PerCache {
let mut cache_stats = stats::Cache::default();
for kind in AccessKind::iter() {
for reservation_failure in ReservationFailure::iter() {
let per_cache_stat = stats.get(&key!(format!(
"{cache_name}_{kind:?}_{reservation_failure:?}"
)));
// let per_core_stat = stats.get(&key!(format!(
// "total_core_cache_{kind:?}_{reservation_failure:?}"
// )));
cache_stats.accesses.insert(
Access((kind, AccessStat::ReservationFailure(reservation_failure))),
per_cache_stat
// .or(per_core_stat)
.copied()
.unwrap_or(0.0) as usize,
per_cache_stat.copied().unwrap_or(0.0) as usize,
);
}
for status in RequestStatus::iter() {
let per_cache_stat = stats.get(&key!(format!("{cache_name}_{kind:?}_{status:?}")));
// dbg!(format!("total_core_cache_{kind:?}_{status:?}"));
// dbg!(stats.get(&key!(format!("total_core_cache_{kind:?}_{status:?}"))));
// let per_core_stat = stats.get(&key!(format!("total_core_cache_{kind:?}_{status:?}")));

cache_stats.accesses.insert(
Access((kind, AccessStat::Status(status))),
per_cache_stat
// .or(per_core_stat)
.copied()
.unwrap_or(0.0) as usize,
per_cache_stat.copied().unwrap_or(0.0) as usize,
);
}
}
Expand Down Expand Up @@ -170,11 +158,11 @@ impl TryFrom<Stats> for stats::Stats {
// todo
let instructions = stats::InstructionCounts::default();

let l2d_stats = convert_cache_stats("l2_cache", &stats);
let l1i_stats = convert_cache_stats("l1_inst_cache", &stats);
let l1d_stats = convert_cache_stats("l1_data_cache", &stats);
let l1c_stats = convert_cache_stats("l1_const_cache", &stats);
let l1t_stats = convert_cache_stats("l1_tex_cache", &stats);
let l2_data_stats = convert_cache_stats("l2_cache", &stats);
let l1_inst_stats = convert_cache_stats("l1_inst_cache", &stats);
let l1_data_stats = convert_cache_stats("l1_data_cache", &stats);
let l1_const_stats = convert_cache_stats("l1_const_cache", &stats);
let l1_tex_stats = convert_cache_stats("l1_tex_cache", &stats);

let total_dram_reads = stats.get(&key!("total_dram_reads")).copied().unwrap_or(0.0) as u64;
let total_dram_writes = stats
Expand Down Expand Up @@ -206,11 +194,11 @@ impl TryFrom<Stats> for stats::Stats {
accesses: stats::Accesses(accesses),
dram,
instructions,
l1i_stats,
l1t_stats,
l1c_stats,
l1d_stats,
l2d_stats,
l1i_stats: l1_inst_stats,
l1t_stats: l1_tex_stats,
l1c_stats: l1_const_stats,
l1d_stats: l1_data_stats,
l2d_stats: l2_data_stats,
stall_dram_full: 0, // todo
})
}
Expand Down
10 changes: 6 additions & 4 deletions profile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pub mod nsight;
pub mod nvprof;

use color_eyre::{eyre, Section, SectionExt};
use color_eyre::{eyre, Section};
use serde::Deserialize;
use std::path::{Path, PathBuf};

Expand Down Expand Up @@ -76,7 +76,7 @@ impl Error {
};
eyre::Report::new(source)
.with_section(|| raw_log)
.with_section(|| format!("{:#?}", values))
.with_section(|| format!("{values:#?}"))
}
Self::Command(err) => err.into_eyre(),
err => err.into(),
Expand Down Expand Up @@ -143,12 +143,14 @@ pub enum Metrics {
}

/// Profile test application using either the nvprof or nsight compute profiler.
pub async fn nvprof<A>(executable: impl AsRef<Path>, args: A) -> Result<Metrics, Error>
#[allow(dead_code)]
#[allow(clippy::unused_async)]
pub async fn nvprof<A>(_executable: impl AsRef<Path>, _args: A) -> Result<Metrics, Error>
where
A: Clone + IntoIterator,
<A as IntoIterator>::Item: AsRef<std::ffi::OsStr>,
{
unimplemented!()
todo!()
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion profile/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async fn main() -> eyre::Result<()> {
Some(Command::Nvprof(nvprof_options)) => {
let output = profile::nvprof::nvprof(exec, exec_args, &nvprof_options.into())
.await
.map_err(|err| err.into_eyre())?;
.map_err(profile::Error::into_eyre)?;
profile::Metrics::Nvprof(output)
}
Some(Command::Nsight(_nsight_options)) => todo!(),
Expand Down
20 changes: 10 additions & 10 deletions profile/src/nvprof/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod metrics;

use indexmap::IndexMap;
use once_cell::sync::Lazy;
use regex::Regex;
use std::collections::HashMap;
Expand Down Expand Up @@ -67,7 +68,6 @@ where
let mut csv_reader = seek_to_csv(reader)?;
let mut records = csv_reader.deserialize();

use indexmap::IndexMap;
let mut entries = Vec::new();
let units: IndexMap<String, String> = records.next().ok_or(ParseError::MissingUnits)??;

Expand All @@ -76,23 +76,23 @@ where
let metrics: HashMap<String, Metric<String>> = units
.iter()
.zip(values.iter())
.flat_map(|((unit_metric, unit), (value_metric, value))| {
.map(|((unit_metric, unit), (value_metric, value))| {
assert_eq!(unit_metric, value_metric);
Some((
(
unit_metric.clone(),
Metric {
value: optional!(value).cloned(),
unit: optional!(unit).cloned(),
},
))
)
})
.collect();

{
let mut metrics: Vec<_> = metrics.clone().into_iter().collect();
metrics.sort_by_key(|(name, _value)| name.clone());

for (m, value) in metrics.iter() {
for (m, value) in &metrics {
log::trace!("{m}: {:?}", &value.value);
}
}
Expand Down Expand Up @@ -321,8 +321,8 @@ mod tests {
diff::assert_eq!(
have: metrics[0],
want: Command {
start: Metric::new(245729.104000, "us".to_string()),
duration: Metric::new(1.088000, "us".to_string()),
start: Metric::new(245_729.11, "us".to_string()),
duration: Metric::new(1.088, "us".to_string()),
grid_x: Metric::new(None, None),
grid_y: Metric::new(None, None),
grid_z: Metric::new(None, None),
Expand All @@ -333,7 +333,7 @@ mod tests {
static_shared_memory: Metric::new(None, "B".to_string()),
dynamic_shared_memory: Metric::new(None, "B".to_string()),
size: Metric::new(400.0, "B".to_string()),
throughput: Metric::new(350.615557, "MB/s".to_string()),
throughput: Metric::new(350.615_57, "MB/s".to_string()),
src_mem_type: Metric::new("Pageable".to_string(), None),
dest_mem_type: Metric::new("Device".to_string(), None),
device: Metric::new("NVIDIA GeForce GTX 1080 (0)".to_string(), None),
Expand All @@ -346,8 +346,8 @@ mod tests {
diff::assert_eq!(
have: metrics[3],
want: Command {
start: Metric::new(245767.824000, "us".to_string()),
duration: Metric::new(3.264000, "us".to_string()),
start: Metric::new(245_767.83, "us".to_string()),
duration: Metric::new(3.264, "us".to_string()),
grid_x: Metric::new(1, None),
grid_y: Metric::new(1, None),
grid_z: Metric::new(1, None),
Expand Down
2 changes: 1 addition & 1 deletion src/cache/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl crate::engine::cycle::Component for Base
/// Sends next request to top memory in the memory hierarchy.
fn cycle(&mut self, cycle: u64) {
let Some(ref top_level_memory_port) = self.top_port else {
panic!("missing top port");
// panic!("missing top port");
return;
};

Expand Down
2 changes: 1 addition & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl L1DCache {
}
}

/// CacheConfig configures a generic cache
/// `CacheConfig` configures a generic cache
#[derive(Debug)]
pub struct Cache {
pub kind: CacheKind,
Expand Down
4 changes: 2 additions & 2 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ pub enum FetchResponseTarget {
// type InterconnBuffer<T> = Arc<Mutex<VecDeque<(usize, T, u32)>>>;
type InterconnBuffer<T> = VecDeque<ic::Packet<(usize, T, u32)>>;

// pub struct CoreMemoryConnection<P> {
#[allow(clippy::module_name_repetitions)]
pub struct CoreMemoryConnection<C> {
pub config: Arc<config::GPU>,
pub stats: Arc<Mutex<stats::Stats>>,
Expand Down Expand Up @@ -1848,7 +1848,7 @@ where
fn init_warps_from_traces(&mut self, kernel: &Arc<Kernel>, start_warp: usize, end_warp: usize) {
debug_assert!(!self.warps.is_empty());
let selected_warps = &mut self.warps[start_warp..end_warp];
for warp in selected_warps.iter_mut() {
for warp in &mut *selected_warps {
let mut warp = warp.try_lock();
warp.trace_instructions.clear();
warp.kernel = Some(Arc::clone(kernel));
Expand Down
Loading

0 comments on commit ee88939

Please sign in to comment.