vyre_runtime/megakernel/execution/
readback_dispatch.rs1use super::{Megakernel, MegakernelDispatchStats};
2use crate::megakernel::readback::MegakernelReadback;
3use crate::PipelineError;
4use vyre_driver::backend::OutputBuffers;
5
6impl Megakernel {
7 pub fn dispatch_with_io_queue_readback(
15 &self,
16 control_bytes: Vec<u8>,
17 ring_bytes: Vec<u8>,
18 debug_log_bytes: Vec<u8>,
19 io_queue_bytes: Vec<u8>,
20 ) -> Result<MegakernelReadback, PipelineError> {
21 let outputs = self.dispatch_with_io_queue_borrowed(
22 &control_bytes,
23 &ring_bytes,
24 &debug_log_bytes,
25 &io_queue_bytes,
26 )?;
27 MegakernelReadback::from_outputs(outputs, self.slot_count)
28 }
29
30 pub fn dispatch_with_io_queue_readback_into(
37 &self,
38 control_bytes: Vec<u8>,
39 ring_bytes: Vec<u8>,
40 debug_log_bytes: Vec<u8>,
41 io_queue_bytes: Vec<u8>,
42 readback: &mut MegakernelReadback,
43 outputs: &mut OutputBuffers,
44 ) -> Result<MegakernelDispatchStats, PipelineError> {
45 self.dispatch_with_io_queue_readback_borrowed_into(
46 &control_bytes,
47 &ring_bytes,
48 &debug_log_bytes,
49 &io_queue_bytes,
50 readback,
51 outputs,
52 )
53 }
54
55 pub fn dispatch_with_io_queue_readback_borrowed(
62 &self,
63 control_bytes: &[u8],
64 ring_bytes: &[u8],
65 debug_log_bytes: &[u8],
66 io_queue_bytes: &[u8],
67 ) -> Result<MegakernelReadback, PipelineError> {
68 let outputs = self.dispatch_with_io_queue_borrowed(
69 control_bytes,
70 ring_bytes,
71 debug_log_bytes,
72 io_queue_bytes,
73 )?;
74 MegakernelReadback::from_outputs(outputs, self.slot_count)
75 }
76
77 pub fn dispatch_with_io_queue_readback_borrowed_observed(
84 &self,
85 control_bytes: &[u8],
86 ring_bytes: &[u8],
87 debug_log_bytes: &[u8],
88 io_queue_bytes: &[u8],
89 ) -> Result<(MegakernelReadback, MegakernelDispatchStats), PipelineError> {
90 let output = self.dispatch_with_io_queue_borrowed_observed(
91 control_bytes,
92 ring_bytes,
93 debug_log_bytes,
94 io_queue_bytes,
95 )?;
96 let stats = output.stats;
97 let readback = MegakernelReadback::from_outputs(output.buffers, self.slot_count)?;
98 Ok((readback, stats))
99 }
100
101 pub fn dispatch_with_io_queue_readback_borrowed_into(
109 &self,
110 control_bytes: &[u8],
111 ring_bytes: &[u8],
112 debug_log_bytes: &[u8],
113 io_queue_bytes: &[u8],
114 readback: &mut MegakernelReadback,
115 outputs: &mut OutputBuffers,
116 ) -> Result<MegakernelDispatchStats, PipelineError> {
117 let stats = self.dispatch_with_io_queue_borrowed_into(
118 control_bytes,
119 ring_bytes,
120 debug_log_bytes,
121 io_queue_bytes,
122 outputs,
123 )?;
124 MegakernelReadback::drain_outputs_into(outputs, self.slot_count, readback)?;
125 Ok(stats)
126 }
127}