You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apologies, this seems to have become rather long. It seemed like such a simple idea at the start!
There are four main tracts to this idea:
Allow DeviceBox<[T]>, making DeviceBuffer just an alias that could be deprecated in future.
Make the interface safer by using MaybeUninit for uninitialized/zeroed allocations on the device.
Add an Alloc generic parameter to DeviceBox, allowing for various new type of allocation.
Bonus: Add support for async allocations.
I think this proposal is entirely backwards compatible, though it does introduce some methods that are very similar to existing, e.g. new_unit vs. uninitialized, new_zeroed vs. zeroed.
DeviceAllocator
// new `alloc` modulepubtraitDeviceAllocator{typePtr;fnallocate(&self,size:usize) -> CudaResult<Ptr>;// This allows for asynchronous zeroing.fnallocate_zeroed(&self,size:usize) -> CudaResult<Ptr>;fndeallocate(&self,ptr:Ptr) -> CudaResult<()>;}// Uses `cudaMalloc`, `cudaFree`.pubstructGlobal;// TODO better name?implDeviceAllocatorforGlobal{typePtr = DevicePointer<u8>;
...
}// Other allocators might include:// `Unified`, `HostPinned`, `Pitched`, `Async`, `MemoryPool`, etc.
impl<T>DeviceBox<T,Global>{
...
// Note that these methods are safe.pubfnnew_uninit() -> DeviceBox<MaybeUninit<T>,Global>;pubfnnew_zeroed() -> DeviceBox<MaybeUninit<T>,Global>;}impl<T,A>DeviceBox<T,A>{
...
pubfnnew_uninit_in(alloc:A) -> DeviceBox<MaybeUninit<T>,A>;pubfnnew_zeroed_in(alloc:A) -> DeviceBox<MaybeUninit<T>,A>;}impl<T,A>DeviceBox<MaybeUninit<T>,A>{pubunsafefnassume_init(self) -> DeviceBox<T,A>;// Use this for kernel outputs, then `assume_init` after the kernel is complete.pubunsafefnas_uninit_device_pointer(&mutself) -> DevicePointer<T>;}
Apologies, this seems to have become rather long. It seemed like such a simple idea at the start!
There are four main tracts to this idea:
DeviceBox<[T]>
, makingDeviceBuffer
just an alias that could be deprecated in future.MaybeUninit
for uninitialized/zeroed allocations on the device.Alloc
generic parameter toDeviceBox
, allowing for various new type of allocation.I think this proposal is entirely backwards compatible, though it does introduce some methods that are very similar to existing, e.g.
new_unit
vs.uninitialized
,new_zeroed
vs.zeroed
.DeviceAllocator
MaybeUninit
DeviceBox<[T]>
Async
The text was updated successfully, but these errors were encountered: