diff --git a/crates/metal2vulkan-runtime/src/copied.rs b/crates/metal2vulkan-runtime/src/copied.rs index 9af6b855d..7ad3ddf93 100644 --- a/crates/metal2vulkan-runtime/src/copied.rs +++ b/crates/metal2vulkan-runtime/src/copied.rs @@ -1533,7 +1533,12 @@ fn split( let runs = Mutex::new(tags.chunks_mut(each).enumerate()); let tallies = Mutex::new(Vec::with_capacity(threads)); let pull = || { - while let Some((index, run)) = lock(&runs).next() { + loop { + // The lock is let go before the run's work: a `while let` would hold it throughout. + let next = lock(&runs).next(); + let Some((index, run)) = next else { + return; + }; let tally = work(first + index * each, run); lock(&tallies).push((index, tally)); } diff --git a/docs/API.md b/docs/API.md index 6762de598..1c49fadeb 100644 --- a/docs/API.md +++ b/docs/API.md @@ -3392,7 +3392,8 @@ bound. room, else in host memory (`copied_base_host_bytes`, `copied_base_device_bytes`); a block whose tag agrees is taken as unchanged, a changed one missed with a chance of at most 2^-64 at each comparison, and a commit that finds no host memory for a base fails with `OutOfMemory` - (`copied_bases_refused`). An event signal submitted while a copy is live is seen once its batch's + (`copied_bases_refused`). A comparison of a copy with a base of 16 MiB or more splits its blocks + across up to four threads, the calling one among them (`copied_compare_threads`). An event signal submitted while a copy is live is seen once its batch's writes are back in the pages, as Metal's: its value at the completion turn, and a wait for it held on the host until then (`event_signals_behind_merge`). A copy and another memory over overlapping but not the same bytes agree GPU to GPU only through the pages, so a read committed diff --git a/docs/HOWTO.md b/docs/HOWTO.md index e176708f1..f22bb72e4 100644 --- a/docs/HOWTO.md +++ b/docs/HOWTO.md @@ -537,7 +537,9 @@ without resizable BAR, whose 256 MiB window no base takes, and every device with blocks and a completion the copy's, each compared with its block's tag, and the base's bytes are read only for a block both sides changed since they agreed (`copied_base_blocks_read`; uncached, across the bus, where they lie in the device's memory). A block whose tag agrees is taken as -unchanged: a changed block is missed with a chance of at most 2^-64 at each comparison. A commit +unchanged: a changed block is missed with a chance of at most 2^-64 at each comparison. A +comparison of a copy with a base of 16 MiB or more splits its blocks across up to four threads, +the calling one among them, which end before it returns (`copied_compare_threads`). A commit that finds no host memory for a base fails with `Error::OutOfMemory` and runs nothing (`copied_bases_refused`); the copy keeps none, and a later commit makes it. An event signal submitted while a copy is live is seen at its batch's completion, after that write-back: no read