Skip to content

Feature request unsafe CudaViewMut & CudaViewMut constructors #295

@audioXD

Description

@audioXD

I would really like it if one could construct a CudaViewMut and CudaViewMut

Like how one does for std::slice::from_raw_parts

pub unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T]

Use case is creating a non owning safe View type.

Implementations

impl<'a, T> CudaViewMut<'a, T> {
    pub const unsafe fn from_raw_parts(ptr: sys::CUdeviceptr, len: usize) -> Self {
        Self {
            ptr,
            len,
            marker: PhantomData,
        }
    }
}

impl<'a, T> CudaView<'a, T> {
    pub const unsafe fn from_raw_parts(ptr: sys::CUdeviceptr, len: usize) -> Self {
        Self {
            ptr,
            len,
            marker: PhantomData,
        }
    }
}

Please define in the docs if the len is in bytes or if its in elements.

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