Added example simple-rw to generate traces.

This commit is contained in:
Filipe Rodrigues 2023-06-14 14:52:11 +01:00
parent d7e521e31d
commit 2f621c7a1c
6 changed files with 81 additions and 1 deletions

4
Cargo.lock generated
View File

@ -847,6 +847,10 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "simple-rw"
version = "0.1.0"
[[package]]
name = "siphasher"
version = "0.3.10"

View File

@ -2,7 +2,13 @@
[workspace]
resolver = "2"
members = ["ftmemsim", "ftmemsim-util", "ftmemsim-graphs", "util/parse-lackey"]
members = [
"ftmemsim",
"ftmemsim-util",
"ftmemsim-graphs",
"util/parse-lackey",
"examples/simple-rw",
]
[workspace.dependencies]

View File

@ -0,0 +1,6 @@
[package]
name = "simple-rw"
version = "0.1.0"
edition = "2021"
[dependencies]

25
examples/simple-rw/run.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/env bash
# Prepare the `lackey` parser
# Note: We always compile the `lackey` parser in release, as it might be too slow otherwise
cargo build --manifest-path "../../Cargo.toml" --release --package "parse-lackey"
parse_lackey="../../target/release/parse-lackey"
# Profile to run the example
#PROFILE="dev"
#PROFILE_PATH="debug"
PROFILE="release"
PROFILE_PATH="release"
# Compile the example
cargo build --profile "$PROFILE"
# Then run valgrind on the example and pipe it to the `lackey` parser
valgrind \
--tool=lackey \
--trace-mem=yes \
--log-fd=1 \
"../../target/$PROFILE_PATH/simple-rw" \
|
$parse_lackey

View File

@ -0,0 +1,38 @@
//! Simple read-write test binary
// Imports
use std::{hint, ptr};
// TODO: Make these runtime constants?
const PASSES: usize = 2;
const WRITES_PER_PASS: usize = 100;
const READS_PER_PASS: usize = 150;
fn main() {
let mut v = vec![0u8; 128 * PAGE_SIZE];
// Note: We `step_by` the page size because we only care about initializing a single page.
for _ in 0..PASSES {
for x in v.iter_mut().step_by(PAGE_SIZE) {
for _ in 0..WRITES_PER_PASS {
// SAFETY: Target is valid for writes.
// Note: We simply want to avoid the write being elided
unsafe {
ptr::write_volatile(x, hint::black_box(0));
}
}
}
for x in v.iter().step_by(PAGE_SIZE) {
for _ in 0..READS_PER_PASS {
// SAFETY: Target is valid for writes.
// Note: We simply want to avoid the write being elided
unsafe {
hint::black_box(ptr::read_volatile(x));
}
}
}
}
}
const PAGE_SIZE: usize = 4096;

1
run.sh
View File

@ -12,6 +12,7 @@ PROFILE="release"
#TRACE_FILE="resources/traces/bfs.g15.n15.trace"
TRACE_FILE="resources/traces/bfs.g17.n100.t1.trace"
#TRACE_FILE="resources/traces/bc.g18.n100.t1.trace"
#TRACE_FILE="examples/simple-rw/output.trace"
OUTPUT_FILE="resources/data/output.bin.gz"