| 243 | } |
| 244 | |
| 245 | fn fetch_fp32(&mut self, idx: u32) -> Option<Vec<f32>> { |
| 246 | // Drain any completions that arrived since last prefetch/fetch. |
| 247 | self.drain_completions(); |
| 248 | |
| 249 | // Happy path: pre-fetch already landed. |
| 250 | if let Some(v) = self.completed.remove(&idx) { |
| 251 | return Some(v); |
| 252 | } |
| 253 | |
| 254 | // If still in-flight, wait for it specifically. |
| 255 | if self.pending.contains_key(&idx) { |
| 256 | // Wait until at least one completion arrives and drain. |
| 257 | let _ = self.ring.submit_and_wait(1); |
| 258 | self.drain_completions(); |
| 259 | if let Some(v) = self.completed.remove(&idx) { |
| 260 | return Some(v); |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | // Fallback: index was never pre-fetched (entry-point seed). |
| 265 | if idx < self.layout.num_nodes as u32 { |
| 266 | return self.read_sync(idx); |
| 267 | } |
| 268 | |
| 269 | None |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | /// Round `value` up to the next multiple of `align` (must be a power of two). |