@@ -11,16 +11,16 @@ use bytemuck::Pod;
1111use sycl_rs_sys:: { queue:: ffi, types:: ffi:: EventPtr } ;
1212
1313use crate :: {
14- buffer:: {
15- Buffer , DeviceBuffer , EnqueuedBuffer , EnqueuedDeviceBuffer , EnqueuedHostBuffer ,
16- EnqueuedSharedBuffer , HostBuffer , SharedBuffer ,
17- } ,
1814 context:: Context ,
1915 device:: Device ,
2016 event:: Event ,
2117 kernel:: { Kernel , KernelArgumentList } ,
2218 range:: { NdRange , ValidDimension } ,
2319 usm:: { UsmAlloc , UsmAllocator } ,
20+ usmbox:: {
21+ DeviceUsmBox , EnqueuedDeviceUsmBox , EnqueuedHostUsmBox , EnqueuedSharedUsmBox ,
22+ EnqueuedUsmBox , HostUsmBox , SharedUsmBox , UsmBox ,
23+ } ,
2424} ;
2525
2626/// The `Queue` connects a host program to a single device. Programs submit tasks to a device via the
@@ -44,74 +44,74 @@ impl Queue {
4444 ffi:: get_context ( & self . 0 ) . into ( )
4545 }
4646
47- /// Allocates zeroed memory and creates a host-side [`Buffer `] that can store an array of T.
48- pub fn alloc_host < T : Pod > ( & mut self , len : usize ) -> Result < EnqueuedHostBuffer < T > > {
47+ /// Allocates zeroed memory and creates a host-side [`UsmBox `] that can store an array of T.
48+ pub fn alloc_host < T : Pod > ( & mut self , len : usize ) -> Result < EnqueuedHostUsmBox < T > > {
4949 unsafe {
50- let mut buffer = self . alloc_uninit_host ( len) ;
51- self . memset ( & mut buffer , 0 )
52- . map ( |event| EnqueuedBuffer :: new ( buffer , event) )
50+ let mut array = self . alloc_uninit_host ( len) ;
51+ self . memset ( & mut array , 0 )
52+ . map ( |event| EnqueuedUsmBox :: new ( array , event) )
5353 }
5454 }
5555
56- /// Allocates zeroed memory and creates a shared [`Buffer `] that can store an array of T.
57- pub fn alloc_shared < T : Pod > ( & mut self , len : usize ) -> Result < EnqueuedSharedBuffer < T > > {
56+ /// Allocates zeroed memory and creates a shared [`UsmBox `] that can store an array of T.
57+ pub fn alloc_shared < T : Pod > ( & mut self , len : usize ) -> Result < EnqueuedSharedUsmBox < T > > {
5858 unsafe {
59- let mut buffer = self . alloc_uninit_shared ( len) ;
60- self . memset ( & mut buffer , 0 )
61- . map ( |event| EnqueuedBuffer :: new ( buffer , event) )
59+ let mut array = self . alloc_uninit_shared ( len) ;
60+ self . memset ( & mut array , 0 )
61+ . map ( |event| EnqueuedUsmBox :: new ( array , event) )
6262 }
6363 }
6464
65- /// Allocates zeroed memory and creates a device [`Buffer `] that can store an array of T.
66- pub fn alloc_device < T : Pod > ( & mut self , len : usize ) -> Result < EnqueuedDeviceBuffer < T > > {
65+ /// Allocates zeroed memory and creates a device [`UsmBox `] that can store an array of T.
66+ pub fn alloc_device < T : Pod > ( & mut self , len : usize ) -> Result < EnqueuedDeviceUsmBox < T > > {
6767 unsafe {
68- let mut buffer = self . alloc_uninit_device ( len) ;
69- self . memset ( & mut buffer , 0 )
70- . map ( |event| EnqueuedBuffer :: new ( buffer , event) )
68+ let mut array = self . alloc_uninit_device ( len) ;
69+ self . memset ( & mut array , 0 )
70+ . map ( |event| EnqueuedUsmBox :: new ( array , event) )
7171 }
7272 }
7373
74- /// Allocates memory and creates a host-side [`Buffer `] that can store an array of T.
75- /// Safety: the buffer contents are uninitialized.
76- pub unsafe fn alloc_uninit_host < T > ( & self , len : usize ) -> HostBuffer < T > {
74+ /// Allocates memory and creates a host-side [`UsmBox `] that can store an array of T.
75+ /// Safety: the array contents are uninitialized.
76+ pub unsafe fn alloc_uninit_host < T > ( & self , len : usize ) -> HostUsmBox < T > {
7777 let allocator = UsmAllocator :: from ( self ) ;
78- unsafe { Buffer :: new ( allocator, len) }
78+ unsafe { UsmBox :: new ( allocator, len) }
7979 }
8080
81- /// Allocates memory and creates a shared [`Buffer `] that can store an array of T.
82- /// Safety: the buffer contents are uninitialized.
83- pub unsafe fn alloc_uninit_shared < T > ( & self , len : usize ) -> SharedBuffer < T > {
81+ /// Allocates memory and creates a shared [`UsmBox `] that can store an array of T.
82+ /// Safety: the array contents are uninitialized.
83+ pub unsafe fn alloc_uninit_shared < T > ( & self , len : usize ) -> SharedUsmBox < T > {
8484 let allocator = UsmAllocator :: from ( self ) ;
85- unsafe { Buffer :: new ( allocator, len) }
85+ unsafe { UsmBox :: new ( allocator, len) }
8686 }
8787
88- /// Allocates memory and creates a device-side [`Buffer `] that can store an array of T.
89- /// Safety: the buffer contents are uninitialized.
90- pub unsafe fn alloc_uninit_device < T > ( & self , len : usize ) -> DeviceBuffer < T > {
88+ /// Allocates memory and creates a device-side [`UsmBox `] that can store an array of T.
89+ /// Safety: the array contents are uninitialized.
90+ pub unsafe fn alloc_uninit_device < T > ( & self , len : usize ) -> DeviceUsmBox < T > {
9191 let allocator = UsmAllocator :: from ( self ) ;
92- unsafe { Buffer :: new ( allocator, len) }
92+ unsafe { UsmBox :: new ( allocator, len) }
9393 }
9494
9595 /// Sets memory allocated with USM allocations.
9696 /// Safety: the caller must make sure the underlying memory isn't being aliased somewhere else.
9797 pub unsafe fn memset < T , A : UsmAlloc > (
9898 & mut self ,
99- buffer : & mut Buffer < T , A > ,
99+ array : & mut UsmBox < T , A > ,
100100 value : i32 ,
101101 ) -> Result < Event > {
102- unsafe { self . memset_with_deps ( buffer , value, & [ ] ) }
102+ unsafe { self . memset_with_deps ( array , value, & [ ] ) }
103103 }
104104
105105 /// Sets memory allocated with USM allocations after all specified events finish.
106106 /// Safety: the caller must make sure the underlying memory isn't being aliased somewhere else.
107107 pub unsafe fn memset_with_deps < T , A : UsmAlloc > (
108108 & mut self ,
109- buffer : & mut Buffer < T , A > ,
109+ array : & mut UsmBox < T , A > ,
110110 value : i32 ,
111111 dep_events : & [ & Event ] ,
112112 ) -> Result < Event > {
113- let ptr = buffer . get_byte_ptr ( ) ;
114- let num_bytes = buffer . get_byte_size ( ) ;
113+ let ptr = array . get_byte_ptr ( ) ;
114+ let num_bytes = array . get_byte_size ( ) ;
115115 let dep_events = dep_events
116116 . iter ( )
117117 . map ( |e| EventPtr {
@@ -162,10 +162,10 @@ impl Queue {
162162 unsafe { nd_range. launch ( self , kernel, args) }
163163 }
164164
165- /// Copies the contents of the source buffer to the destination buffer .
165+ /// Copies the contents of the source array to the destination array .
166166 ///
167- /// Panics if the source and destination buffer lengths differ.
168- pub fn copy < T , A1 , A2 > ( & mut self , src : & Buffer < T , A1 > , dst : & mut Buffer < T , A2 > ) -> Result < Event >
167+ /// Panics if the source and destination array lengths differ.
168+ pub fn copy < T , A1 , A2 > ( & mut self , src : & UsmBox < T , A1 > , dst : & mut UsmBox < T , A2 > ) -> Result < Event >
169169 where
170170 T : Pod ,
171171 A1 : UsmAlloc ,
@@ -174,14 +174,14 @@ impl Queue {
174174 self . copy_with_deps ( src, dst, & [ ] )
175175 }
176176
177- /// Copies the contents of the source buffer to the destination buffer after all specified
177+ /// Copies the contents of the source array to the destination array after all specified
178178 /// events finish.
179179 ///
180- /// Panics if the source and destination buffer lengths differ.
180+ /// Panics if the source and destination array lengths differ.
181181 pub fn copy_with_deps < T , A1 , A2 > (
182182 & mut self ,
183- src : & Buffer < T , A1 > ,
184- dst : & mut Buffer < T , A2 > ,
183+ src : & UsmBox < T , A1 > ,
184+ dst : & mut UsmBox < T , A2 > ,
185185 dep_events : & [ & Event ] ,
186186 ) -> Result < Event >
187187 where
@@ -192,7 +192,7 @@ impl Queue {
192192 assert_eq ! (
193193 src. get_len( ) ,
194194 dst. get_len( ) ,
195- "source and destination buffer lengths differ"
195+ "source and destination array lengths differ"
196196 ) ;
197197
198198 // TODO: Resolve the C++ lifetime elision issue
0 commit comments