Trait rust_cuda::safety::PortableBitSemantics

source ·
pub auto trait PortableBitSemantics { }
Expand description

Types whose in-memory bit representation on the CPU host is safe to copy to and read back on the GPU device while maintaining the same semantics, iff the type layout on the CPU matches the type layout on the GPU.

For a type to implement PortableBitSemantics, it

  • should have the same memory layout on both the CPU and GPU, and

  • must not contain any references to data that are exposed as safely accessible on both ends but actually inaccessible on one.

For instance, a reference &u8 to host memory has the same well-defined layout on both CPU and GPU (if their pointer sizes and alignments match), but it is not portable since the host memory is generally not accessible from the GPU.

This trait is automatically implemented when the compiler determines it’s appropriate.

Note that this trait is sealed, i.e. you cannot implement it on your own custom types.

Trait bounds usually combine PortableBitSemantics with TypeGraphLayout to check that the type layout is indeed the same on both the host CPU and the GPU device.

Types that implement StackOnly and TypeGraphLayout satisfy both of the above criteria and thus also implement PortableBitSemantics.

Implementations on Foreign Types§

source§

impl<T> PortableBitSemantics for PhantomData<T>

source§

impl<T: ?Sized> !PortableBitSemantics for *const T

source§

impl<T: ?Sized> !PortableBitSemantics for *mut T

source§

impl<T: ?Sized> !PortableBitSemantics for &T

source§

impl<T: ?Sized> !PortableBitSemantics for &mut T

Implementors§

Auto implementors§

§

impl !PortableBitSemantics for RawPtxKernel

§

impl PortableBitSemantics for NoCudaAlloc

§

impl PortableBitSemantics for SomeCudaAlloc

§

impl PortableBitSemantics for PTXAllocator

§

impl PortableBitSemantics for Dim3

§

impl PortableBitSemantics for Idx3

§

impl PortableBitSemantics for Thread

§

impl PortableBitSemantics for ThreadBlock

§

impl PortableBitSemantics for ThreadBlockGrid

§

impl PortableBitSemantics for LaunchConfig

§

impl PortableBitSemantics for NoCompletion

§

impl<'a, 'stream, T> !PortableBitSemantics for AsyncProj<'a, 'stream, T>

§

impl<'a, 'stream, T, C = NoCompletion> !PortableBitSemantics for Async<'a, 'stream, T, C>

§

impl<'a, T> !PortableBitSemantics for HostAndDeviceConstRef<'a, T>

§

impl<'a, T> !PortableBitSemantics for HostAndDeviceMutRef<'a, T>

§

impl<'a, T> !PortableBitSemantics for HostAndDeviceOwned<'a, T>

§

impl<'r, T> PortableBitSemantics for DeviceConstRef<'r, T>

§

impl<'r, T> PortableBitSemantics for DeviceMutRef<'r, T>

§

impl<'r, T> PortableBitSemantics for DeviceOwnedRef<'r, T>

§

impl<'stream> !PortableBitSemantics for Stream<'stream>

§

impl<'stream, 'kernel, Kernel> !PortableBitSemantics for Launcher<'stream, 'kernel, Kernel>

§

impl<A, B> PortableBitSemantics for CombinedCudaAlloc<A, B>

§

impl<C> PortableBitSemantics for CudaDropWrapper<C>

§

impl<Kernel> !PortableBitSemantics for TypedPtxKernel<Kernel>

§

impl<T> !PortableBitSemantics for ExchangeWrapperOnDevice<T>

§

impl<T> !PortableBitSemantics for ExchangeWrapperOnHost<T>

§

impl<T> !PortableBitSemantics for ThreadBlockShared<T>

§

impl<T> !PortableBitSemantics for ThreadBlockSharedSlice<T>

§

impl<T> PortableBitSemantics for DeepPerThreadBorrow<T>

§

impl<T> PortableBitSemantics for PerThreadShallowCopy<T>

§

impl<T> PortableBitSemantics for PtxJit<T>

§

impl<T> PortableBitSemantics for ShallowInteriorMutable<T>

§

impl<T> PortableBitSemantics for DeviceCopyWithPortableBitSemantics<T>

§

impl<T> PortableBitSemantics for RustToCudaWithPortableBitCloneSemantics<T>

§

impl<T> PortableBitSemantics for RustToCudaWithPortableBitCopySemantics<T>

§

impl<T> PortableBitSemantics for SplitSliceOverCudaThreadsDynamicStride<T>

§

impl<T> PortableBitSemantics for DeviceAccessible<T>

§

impl<T, const M2D: bool, const M2H: bool> !PortableBitSemantics for CudaExchangeBuffer<T, M2D, M2H>

§

impl<T, const M2D: bool, const M2H: bool> PortableBitSemantics for CudaExchangeItem<T, M2D, M2H>

§

impl<T, const STRIDE: usize> PortableBitSemantics for SplitSliceOverCudaThreadsConstStride<T, STRIDE>