cudarc icon indicating copy to clipboard operation
cudarc copied to clipboard

Redesing `CudaView` and `CudaViewMut` to allow for splitting of mutable views.

Open dkales opened this issue 1 year ago • 0 comments

This is an attempt to address #233.

Since this is code that touches some aspects of the lifetimes of CudaView and CudaViewMut, this could use some extra scrutiny to check if the safety invariants of the involved types are still ok.

I removed the root field of both CudaView and CudaViewMut, since it's only purpose was AFAIK, to keep track of the lifetimes of the respective structs. I have moved this into a PhantomData which should serve the same purpose.

Furthermore, I have now added the split_at_mut methods to CudaSlice and CudaViewMut, which mimic the behavior of split_at_mut of the standard library.

The old method of storing a &mut to the cuda device pointer does not work for splitting, since it would mean that there exist two mutable references to the same value (the u64 device ptr value) at the same time, which AFAIK is always unsound. Therefore the removal and moving the lifetimes into PhantomData as discussed above.

dkales avatar May 21 '24 15:05 dkales