+
Skip to content

Improve unsafe usages for methods #401

Open
@coreylowman

Description

@coreylowman

I don't think that the various allocation methods (alloc, alloc_unified, alloc_pinned) should be marked unsafe, because allocating uninitialized device memory is not unsafe, its the actual reading of uninitialized values that is unsafe.

We also know that rust and cuda likely have different rules for undefined behavior.

Things to check:

  1. When doing rust -> cuda memcpy, is it undefined behavior to read uninitialized values in rust for copying to cuda?
  2. When doing cuda -> rust memcpy, is it undefined behavior if the cuda values are uninitialized?
  3. When doing cuda -> cuda memcpy, is it undefined behavior if values are uninitialized?

Additionally, for CudaStream::memcpy_dtov, do we need to mark it as unsafe because the resulting Vec<T> might contain uninitialized or invalid values for T?

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浏览器服务,不要输入任何密码和下载