Skip to content

Commit

Permalink
ci: convert use upstream flag for accelsim into feature
Browse files Browse the repository at this point in the history
  • Loading branch information
romnn committed Jul 4, 2023
1 parent a788523 commit f40d3cf
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 33 deletions.
5 changes: 3 additions & 2 deletions accelsim/sim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ version = "0.1.0"
edition = "2021"

[features]
default = []
default = []
upstream = []

[package.metadata.cargo-feature-combinations]
denylist = ["default"]
Expand All @@ -22,5 +23,5 @@ accelsim = { path = "../" }

[build-dependencies]
color-eyre = "0"
# duct = "0"
duct = "0"
accelsim = { path = "../" }
7 changes: 5 additions & 2 deletions accelsim/sim/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,15 @@ make -j -C {src}",
fn main() -> eyre::Result<()> {
color_eyre::install()?;

println!("cargo:rerun-if-env-changed=USE_UPSTREAM_ACCELSIM");
println!("cargo:rerun-if-env-changed=FORCE");
println!("cargo:rerun-if-env-changed=BUILD");
println!("cargo:rerun-if-env-changed=build.rs");

let (_use_upstream, accel_path) = accelsim::locate()?;
let use_upstream = false;
#[cfg(feature = "upstream")]
let use_upstream = true;

let accel_path = accelsim::locate(use_upstream)?;
println!("cargo:rerun-if-changed={}", accel_path.display());

println!(
Expand Down
21 changes: 5 additions & 16 deletions accelsim/sim/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ fn locate_accelsim_bin(accel_path: &Path, profile: &str) -> eyre::Result<PathBuf
.join("playground")
} else {
accelsim::executable(accel_path)
// sim_root.join("bin").join(profile).join("accel-sim.out")
};
Ok(accelsim_bin)
}
Expand All @@ -27,33 +26,24 @@ async fn sim_trace(
config: SimConfig,
timeout: Option<Duration>,
) -> eyre::Result<std::process::Output> {
let (_is_upstream, accelsim_path) = accelsim::locate()?;
let profile = accelsim::profile();
let use_upstream = false;
#[cfg(feature = "upstream")]
let use_upstream = true;

// #[cfg(debug_assertions)]
// let profile = "debug";
// #[cfg(not(debug_assertions))]
// let profile = "release";
let accelsim_path = accelsim::locate(use_upstream)?;
let profile = accelsim::profile();

let accelsim_bin = locate_accelsim_bin(&accelsim_path, &profile)?;
let accelsim_bin = accelsim_bin
.canonicalize()
.wrap_err_with(|| format!("{} does not exist", accelsim_bin.display()))?;

// if !accelsim_bin.is_file() {
// eyre::bail!("missing {}", accelsim_bin.display());
// }

let sim_root = accelsim_path.join("gpu-simulator/");
let setup_env = sim_root.join("setup_environment.sh");
let setup_env = setup_env
.canonicalize()
.wrap_err_with(|| format!("{} does not exist", setup_env.display()))?;

// if !setup_env.is_file() {
// eyre::bail!("missing {}", setup_env.display());
// }

let mut tmp_sim_sh = vec!["set -e".to_string()];

// change current working dir
Expand Down Expand Up @@ -152,7 +142,6 @@ async fn main() -> eyre::Result<()> {
color_eyre::install()?;

let options = Options::parse();
// dbg!(&options.traces_dir);

let start = Instant::now();
let output = sim_trace(&options.traces_dir, options.sim_config, options.timeout).await?;
Expand Down
19 changes: 9 additions & 10 deletions accelsim/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ use color_eyre::{eyre, Section, SectionExt};
pub use options::{Options, SimConfig};
use std::path::{Path, PathBuf};

#[must_use]
pub fn use_upstream() -> bool {
let use_upstream = std::env::var("USE_UPSTREAM_ACCELSIM");
use_upstream.is_ok_and(|v| v.to_lowercase() == "yes")
}
// #[must_use]
// pub fn use_upstream() -> bool {
// let use_upstream = std::env::var("USE_UPSTREAM_ACCELSIM");
// use_upstream.is_ok_and(|v| v.to_lowercase() == "yes")
// }

#[must_use]
pub fn find_cuda() -> eyre::Result<PathBuf> {
Expand Down Expand Up @@ -59,8 +59,7 @@ pub fn cuda_candidates() -> Vec<PathBuf> {
valid_paths
}

pub fn locate() -> eyre::Result<(bool, PathBuf)> {
let use_upstream = use_upstream();
pub fn locate(use_upstream: bool) -> eyre::Result<PathBuf> {
let accelsim_path = build::manifest_path()?.join(if use_upstream {
"upstream/accel-sim-framework"
} else {
Expand All @@ -76,11 +75,11 @@ pub fn locate() -> eyre::Result<(bool, PathBuf)> {
};
repo.shallow_clone()?;
}
Ok((use_upstream, accelsim_path))
Ok(accelsim_path)
}

pub fn locate_nvbit_tracer() -> eyre::Result<PathBuf> {
let (_, accelsim_path) = locate()?;
pub fn locate_nvbit_tracer(use_upstream: bool) -> eyre::Result<PathBuf> {
let accelsim_path = locate(use_upstream)?;
let default_tracer_root = accelsim_path.join("util/tracer_nvbit/");
let tracer_root = if let Ok(path) = std::env::var("NVBIT_TRACER_ROOT") {
PathBuf::from(path)
Expand Down
7 changes: 5 additions & 2 deletions accelsim/trace/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,15 @@ fn build_accelsim_tracer_tool(
fn main() -> eyre::Result<()> {
color_eyre::install()?;

println!("cargo:rerun-if-env-changed=USE_UPSTREAM_ACCELSIM");
println!("cargo:rerun-if-env-changed=FORCE");
println!("cargo:rerun-if-env-changed=BUILD");
println!("cargo:rerun-if-env-changed=build.rs");

let (_use_upstream, accel_path) = accelsim::locate()?;
let use_upstream = false;
#[cfg(feature = "upstream")]
let use_upstream = true;

let accel_path = accelsim::locate(use_upstream)?;
println!("cargo:rerun-if-changed={}", accel_path.display());

println!(
Expand Down
6 changes: 5 additions & 1 deletion accelsim/trace/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ async fn run_trace(
exec_args: Vec<String>,
traces_dir: impl AsRef<Path>,
) -> eyre::Result<()> {
let nvbit_tracer_root = accelsim::locate_nvbit_tracer()?;
let use_upstream = false;
#[cfg(feature = "upstream")]
let use_upstream = true;

let nvbit_tracer_root = accelsim::locate_nvbit_tracer(use_upstream)?;
dbg!(&nvbit_tracer_root);
assert!(
nvbit_tracer_root.is_dir(),
Expand Down
3 changes: 3 additions & 0 deletions trace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ full = []
[package.metadata.cargo-feature-combinations]
denylist = ["default"]

[package.metadata.cargo-feature-combinations.matrix]
need_cuda = true

[dependencies]
thiserror = "1"
nvbit-rs = "0"
Expand Down
4 changes: 4 additions & 0 deletions trace/invoke/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ default = []
[package.metadata.cargo-feature-combinations]
denylist = ["default"]

[package.metadata.cargo-feature-combinations.matrix]
need_cuda = true

[dependencies]
anyhow = "1"
thiserror = "1"
tokio = { version = "1", features = ["full"] }
async-process = "1"

trace = { path = "../" }
3 changes: 3 additions & 0 deletions validate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ remote = ["dep:ssh_jumper"]
[package.metadata.cargo-feature-combinations]
denylist = ["default"]

[package.metadata.cargo-feature-combinations.matrix]
need_cuda = true

[dependencies]
thiserror = "1"
anyhow = "1"
Expand Down

0 comments on commit f40d3cf

Please sign in to comment.