mirror of
https://github.com/Zenithsiz/ftmemsim.git
synced 2026-02-03 17:52:16 +00:00
Added example single-page-rw to generate traces.
This commit is contained in:
parent
b821d234c0
commit
e3f78794c2
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -879,6 +879,10 @@ dependencies = [
|
||||
name = "simple-rw"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "single-page-rw"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "siphasher"
|
||||
version = "0.3.10"
|
||||
|
||||
@ -9,6 +9,7 @@ members = [
|
||||
"util/parse-lackey",
|
||||
"examples/simple-rw",
|
||||
"examples/random-rw",
|
||||
"examples/single-page-rw",
|
||||
]
|
||||
|
||||
[workspace.dependencies]
|
||||
|
||||
6
examples/single-page-rw/Cargo.toml
Normal file
6
examples/single-page-rw/Cargo.toml
Normal file
@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "single-page-rw"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
25
examples/single-page-rw/run.sh
Executable file
25
examples/single-page-rw/run.sh
Executable 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/single-page-rw" \
|
||||
|
|
||||
$parse_lackey
|
||||
35
examples/single-page-rw/src/main.rs
Normal file
35
examples/single-page-rw/src/main.rs
Normal file
@ -0,0 +1,35 @@
|
||||
//! Single page read-write test binary
|
||||
|
||||
// Imports
|
||||
use std::{hint, ptr};
|
||||
|
||||
// TODO: Make these runtime constants?
|
||||
const PASSES: usize = 10;
|
||||
const WRITES_PER_PASS: usize = 10000;
|
||||
const READS_PER_PASS: usize = 15000;
|
||||
|
||||
fn main() {
|
||||
// Note: We over-allocate to ensure the allocation goes through `mmap`.
|
||||
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 _ 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(v.as_mut_ptr(), hint::black_box(0));
|
||||
}
|
||||
}
|
||||
|
||||
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(v.as_ptr()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const PAGE_SIZE: usize = 4096;
|
||||
1
run.sh
1
run.sh
@ -14,6 +14,7 @@ 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"
|
||||
#TRACE_FILE="examples/random-rw/output.trace"
|
||||
#TRACE_FILE="examples/single-page-rw/output.trace"
|
||||
|
||||
OUTPUT_FILE="resources/data/output.bin.gz"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user