Configure number of iterations

This commit is contained in:
Raph Levien 2021-11-11 07:26:32 -08:00
parent a0648a2153
commit 7a021793ee
4 changed files with 14 additions and 10 deletions

View file

@ -43,14 +43,12 @@ pub struct ClearBinding {
pub unsafe fn run_clear_test(runner: &mut Runner, config: &Config) -> TestResult { pub unsafe fn run_clear_test(runner: &mut Runner, config: &Config) -> TestResult {
let mut result = TestResult::new("clear buffers"); let mut result = TestResult::new("clear buffers");
// This will be configurable.
let n_elements: u64 = config.size.choose(1 << 12, 1 << 20, 1 << 24); let n_elements: u64 = config.size.choose(1 << 12, 1 << 20, 1 << 24);
let out_buf = runner.buf_down(n_elements * 4); let out_buf = runner.buf_down(n_elements * 4);
let code = ClearCode::new(runner); let code = ClearCode::new(runner);
let stage = ClearStage::new_with_value(runner, n_elements, 0x42); let stage = ClearStage::new_with_value(runner, n_elements, 0x42);
let binding = stage.bind(runner, &code, &out_buf.dev_buf); let binding = stage.bind(runner, &code, &out_buf.dev_buf);
// Also will be configurable of course. let n_iter = config.n_iter;
let n_iter = 1000;
let mut total_elapsed = 0.0; let mut total_elapsed = 0.0;
for i in 0..n_iter { for i in 0..n_iter {
let mut commands = runner.commands(); let mut commands = runner.commands();
@ -79,10 +77,7 @@ impl ClearCode {
let code = include_shader!(&runner.session, "../shader/gen/Clear"); let code = include_shader!(&runner.session, "../shader/gen/Clear");
let pipeline = runner let pipeline = runner
.session .session
.create_compute_pipeline( .create_compute_pipeline(code, &[BindType::BufReadOnly, BindType::Buffer])
code,
&[BindType::BufReadOnly, BindType::Buffer],
)
.unwrap(); .unwrap();
ClearCode { pipeline } ClearCode { pipeline }
} }

View file

@ -21,6 +21,7 @@ use clap::ArgMatches;
pub struct Config { pub struct Config {
pub groups: Groups, pub groups: Groups,
pub size: Size, pub size: Size,
pub n_iter: u64,
} }
pub struct Groups(String); pub struct Groups(String);
@ -35,7 +36,15 @@ impl Config {
pub fn from_matches(matches: &ArgMatches) -> Config { pub fn from_matches(matches: &ArgMatches) -> Config {
let groups = Groups::from_str(matches.value_of("groups").unwrap_or("all")); let groups = Groups::from_str(matches.value_of("groups").unwrap_or("all"));
let size = Size::from_str(matches.value_of("size").unwrap_or("m")); let size = Size::from_str(matches.value_of("size").unwrap_or("m"));
Config { groups, size } let n_iter = matches
.value_of("n_iter")
.and_then(|s| s.parse().ok())
.unwrap_or(1000);
Config {
groups,
size,
n_iter,
}
} }
} }

View file

@ -69,7 +69,7 @@ pub unsafe fn run_prefix_test(runner: &mut Runner, config: &Config) -> TestResul
let stage = PrefixStage::new(runner, &code, n_elements); let stage = PrefixStage::new(runner, &code, n_elements);
let binding = stage.bind(runner, &code, &data_buf, &out_buf.dev_buf); let binding = stage.bind(runner, &code, &data_buf, &out_buf.dev_buf);
// Also will be configurable of course. // Also will be configurable of course.
let n_iter = 1000; let n_iter = config.n_iter;
let mut total_elapsed = 0.0; let mut total_elapsed = 0.0;
for i in 0..n_iter { for i in 0..n_iter {
let mut commands = runner.commands(); let mut commands = runner.commands();

View file

@ -57,7 +57,7 @@ pub unsafe fn run_prefix_test(runner: &mut Runner, config: &Config) -> TestResul
let stage = PrefixTreeStage::new(runner, n_elements); let stage = PrefixTreeStage::new(runner, n_elements);
let binding = stage.bind(runner, &code, &out_buf.dev_buf); let binding = stage.bind(runner, &code, &out_buf.dev_buf);
// Also will be configurable of course. // Also will be configurable of course.
let n_iter = 1000; let n_iter = config.n_iter;
let mut total_elapsed = 0.0; let mut total_elapsed = 0.0;
for i in 0..n_iter { for i in 0..n_iter {
let mut commands = runner.commands(); let mut commands = runner.commands();