Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions crates/vm/src/system/cuda/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,12 @@ impl MemoryInventoryGPU {
ret
}
}

impl Drop for PersistentMemoryInventoryGPU {
fn drop(&mut self) {
// Drop merkle subtrees first so their individual streams synchronize before dropping the
// initial memory buffers. This prevents buffers from dropping before build_async completes.
self.merkle_tree.drop_subtrees();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IS this enough? Strange. I don't see a sync in MemoryMerkleSubTree drop. There is no drop impl there

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just the CudaStream drop implementation. When you remove a subtree, the subtree drops, which drops the stream, which forces a sync.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, nice

self.initial_memory.clear();
}
}