STRA-338 size: cuda-driver OriginalMmqCopySchedule::stream_launch <= 30 lines
This commit is contained in:
@@ -319,19 +319,14 @@ impl<'ctx> OriginalMmqCopySchedule<'ctx> {
|
||||
) -> Result<()> {
|
||||
use crate::ffi::original_stager::Api as StagerApi;
|
||||
let (copied, used, starts) = Self::split_events(&events, ring);
|
||||
let topup = Self::prefill_topup();
|
||||
let copy = self.copy.as_mut().ok_or(Error::ContextPoisoned)?.with_enqueue(Ok)?;
|
||||
// the copies must follow everything the compute path queued so far on its own streams
|
||||
self.context.synchronize()?;
|
||||
let context_token = StagerApi::context_token(self.context.handle.ok_or(Error::ContextPoisoned)?);
|
||||
let topup = Self::prefill_topup();
|
||||
match ChunkStream::start(api, copy, first, entries, targets, copied, used, starts, topup, context_token) {
|
||||
Ok(stream) => {
|
||||
// from here the compute path's drains stop waiting for the copy stream (end_prompt_stream restores them)
|
||||
crate::compute_drain::set_background(copy);
|
||||
self.stream_started = Some(std::time::Instant::now());
|
||||
self.stream = Some(stream);
|
||||
self.stream_bank = Some(Rc::clone(bank));
|
||||
self.stream_events = events;
|
||||
self.adopt_stream(stream, bank, events, copy);
|
||||
Ok(())
|
||||
}
|
||||
Err(primary) => {
|
||||
@@ -341,6 +336,21 @@ impl<'ctx> OriginalMmqCopySchedule<'ctx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn adopt_stream(
|
||||
&mut self,
|
||||
stream: ChunkStream,
|
||||
bank: &Rc<crate::MappedExpertBank<'ctx>>,
|
||||
events: Vec<usize>,
|
||||
copy: usize,
|
||||
) {
|
||||
// from here the compute path's drains stop waiting for the copy stream (end_prompt_stream restores them)
|
||||
crate::compute_drain::set_background(copy);
|
||||
self.stream_started = Some(std::time::Instant::now());
|
||||
self.stream = Some(stream);
|
||||
self.stream_bank = Some(Rc::clone(bank));
|
||||
self.stream_events = events;
|
||||
}
|
||||
|
||||
/// The `copied`, `used` and `start` blocks of the event list.
|
||||
fn split_events(events: &[usize], ring: usize) -> (Vec<usize>, Vec<usize>, Vec<usize>) {
|
||||
(events[..ring].to_vec(), events[ring..2 * ring].to_vec(), events[2 * ring..].to_vec())
|
||||
|
||||
Reference in New Issue
Block a user