+
Skip to content

CudaViewMut requires mutable borrow #423

Open
@entropylost

Description

@entropylost

Currently, there's only one way to get a CudaViewMut from a non-mutable slice reference, which is as_view_mut (which isn't actually unsafe). This is somewhat inconvenient, since that prevents me making multiple CudaViewMut instances which would be required for functions like gemm, or idiomatic use of asynchronous kernel calls.

There doesn't seem to be any practical reason why we can't turn a CudaView into a CudaViewMut arbitrarily. As such, I'd like to propose the following changes:

  • as_view_mut should take in an &mut CudaSlice. Possibly also make an unsafe version which does only take in an &.
  • Add a method unsafe fn as_mut_unchecked(&Self) -> CudaViewMut<'a, T> to CudaView<'a, T>. This would allow for use of multiple CudaViewMuts while still being clear on when things are being mutated.

Also, I believe that CudaView should be Copyable, since it only contains references; is there any reason that isn't the case currently?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载