harness: every workload command buffer carries a scheduled and a completed handler, as the consumer's do
The consumer adds a scheduled handler and a completed handler to every command buffer, so a runtime's cost of carrying and running them, and of waking the thread that runs them, is part of every command buffer it runs. The harness's workload rows committed bare command buffers, and only frame, frame_5cb and long_4cb had a completed handler (the commit-to-complete timer), so the burst rows timed a shape the consumer never runs. Now commit_run adds both to every command buffer of a run, in both runtimes: rt's add_scheduled_handler and the old runtime's submission handler, the point its consumer takes as a command buffer is scheduled. The handlers do nothing but run. To be verified by a table of the rows beside the parent's, both runtimes, on NVIDIA first.
This commit is contained in:
1 parent
34b58e591b
commit
ff4ce943c2
4 files changed
+30
-7
No files matched your search
@@ -21,6 +21,9 @@
|
||||
//! each cover a 512 by 512 target, and 2,000 that each cover a 16 by 16 one; `bind_2000` is
|
||||
//! `draw_2000` with a vertex buffer and a fragment texture set before each draw, each alternating
|
||||
//! between two objects.
|
||||
//! Every command buffer of a workload's runs carries a scheduled handler (on the old runtime, its
|
||||
//! submission handler) and a completed handler, as the consumer's command buffers do, so the times
|
||||
//! hold what the runtimes do to run them.
|
||||
//! A [`run::Session`] makes its objects, checks the first run, then times the rest. The authored
|
||||
//! workloads ([`authored`]) are MSL kernels committed as public fixtures
|
||||
//! (`crates/metal2vulkan-validation/fixtures/public/harness/workloads.metal`, compiled by
|
||||
@@ -400,6 +403,10 @@ pub trait CommandBuffer<D: ComputeDevice> {
|
||||
/// `addCompletedHandler:`, with a handler given how late it runs: from the command buffer's
|
||||
/// `GPUEndTime` to the handler's start, both on the runtime's host clock, in microseconds.
|
||||
fn add_completed_handler(&self, handler: Box<dyn FnOnce(f64) + Send>) -> Result<()>;
|
||||
|
||||
/// `addScheduledHandler:`; on the old runtime its submission handler, the point its consumer
|
||||
/// takes as a command buffer is scheduled.
|
||||
fn add_scheduled_handler(&self, handler: Box<dyn FnOnce() + Send>) -> Result<()>;
|
||||
}
|
||||
|
||||
/// `MTLBlitCommandEncoder`.
|
||||
|
||||
@@ -348,6 +348,13 @@ impl crate::CommandBuffer<runtime::Device> for runtime::CommandBuffer {
|
||||
}),
|
||||
)?)
|
||||
}
|
||||
|
||||
fn add_scheduled_handler(&self, handler: Box<dyn FnOnce() + Send>) -> Result<()> {
|
||||
Ok(runtime::CommandBuffer::add_submission_handler(
|
||||
self,
|
||||
Box::new(move |_| handler()),
|
||||
)?)
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::BlitCommandEncoder<runtime::Device> for runtime::BlitCommandEncoder {
|
||||
|
||||
@@ -681,6 +681,10 @@ impl crate::CommandBuffer<Device> for rt::CommandBuffer {
|
||||
})
|
||||
.map_err(error)
|
||||
}
|
||||
|
||||
fn add_scheduled_handler(&self, handler: Box<dyn FnOnce() + Send>) -> Result<()> {
|
||||
rt::CommandBuffer::add_scheduled_handler(self, move |_| handler()).map_err(error)
|
||||
}
|
||||
}
|
||||
|
||||
/// A copy between a buffer and a texture as the runtime takes it: the buffer's layout, the
|
||||
|
||||
@@ -651,8 +651,9 @@ impl<D: ComputeDevice> Harness<D> {
|
||||
}
|
||||
|
||||
/// A run of `plan`, committed: its command buffers in order, `per_command_buffer`
|
||||
/// dispatches each (or all in one), with no wait between. Where `completions` is given, each
|
||||
/// takes a completed handler that reports its commit-to-complete time there, with its place.
|
||||
/// dispatches each (or all in one), with no wait between. Each takes a scheduled handler and
|
||||
/// a completed handler, as the consumer's command buffers do. Where `completions` is given,
|
||||
/// the completed handler reports its commit-to-complete time there, with its place.
|
||||
fn commit_run(
|
||||
&self,
|
||||
plan: &Plan,
|
||||
@@ -668,11 +669,15 @@ impl<D: ComputeDevice> Harness<D> {
|
||||
.enumerate()
|
||||
.map(|(place, range)| {
|
||||
let command_buffer = self.encode(plan, made, range)?;
|
||||
if let Some(completions) = completions {
|
||||
let (completions, committed) = (Arc::clone(completions), Instant::now());
|
||||
command_buffer.add_completed_handler(Box::new(move |late_us| {
|
||||
completions.ran(place, committed.elapsed(), late_us);
|
||||
}))?;
|
||||
command_buffer.add_scheduled_handler(Box::new(|| {}))?;
|
||||
match completions {
|
||||
Some(completions) => {
|
||||
let (completions, committed) = (Arc::clone(completions), Instant::now());
|
||||
command_buffer.add_completed_handler(Box::new(move |late_us| {
|
||||
completions.ran(place, committed.elapsed(), late_us);
|
||||
}))?;
|
||||
}
|
||||
None => command_buffer.add_completed_handler(Box::new(|_| {}))?,
|
||||
}
|
||||
command_buffer.commit()?;
|
||||
Ok(command_buffer)
|
||||
|
||||
Reference in new issue
Block a user