@@ -28,6 +28,12 @@ use crate::{
2828/// a kernel.
2929pub struct Queue ( pub ( crate ) cxx:: UniquePtr < ffi:: Queue > ) ;
3030
31+ impl Default for Queue {
32+ fn default ( ) -> Self {
33+ Self :: new ( )
34+ }
35+ }
36+
3137impl Queue {
3238 /// Construct a `Queue` based on the device returned from the default selector.
3339 pub fn new ( ) -> Self {
@@ -77,28 +83,40 @@ impl Queue {
7783 }
7884
7985 /// Allocates memory and creates a host-side [`UsmBox`] that can store an array of T.
80- /// Safety: the array contents are uninitialized.
86+ ///
87+ /// # Safety
88+ ///
89+ /// The array contents are uninitialized and must not be read before they are initialized.
8190 pub unsafe fn alloc_uninit_host < T > ( & self , len : usize ) -> HostUsmBox < T > {
8291 let allocator = UsmAllocator :: from ( self ) ;
8392 unsafe { UsmBox :: new ( allocator, len) }
8493 }
8594
8695 /// Allocates memory and creates a shared [`UsmBox`] that can store an array of T.
87- /// Safety: the array contents are uninitialized.
96+ ///
97+ /// # Safety
98+ ///
99+ /// The array contents are uninitialized and must not be read before they are initialized.
88100 pub unsafe fn alloc_uninit_shared < T > ( & self , len : usize ) -> SharedUsmBox < T > {
89101 let allocator = UsmAllocator :: from ( self ) ;
90102 unsafe { UsmBox :: new ( allocator, len) }
91103 }
92104
93105 /// Allocates memory and creates a device-side [`UsmBox`] that can store an array of T.
94- /// Safety: the array contents are uninitialized.
106+ ///
107+ /// # Safety
108+ ///
109+ /// The array contents are uninitialized and must not be read before they are initialized.
95110 pub unsafe fn alloc_uninit_device < T > ( & self , len : usize ) -> DeviceUsmBox < T > {
96111 let allocator = UsmAllocator :: from ( self ) ;
97112 unsafe { UsmBox :: new ( allocator, len) }
98113 }
99114
100115 /// Sets memory allocated with USM allocations.
101- /// Safety: the caller must make sure the underlying memory isn't being aliased somewhere else.
116+ ///
117+ /// # Safety
118+ ///
119+ /// The caller must ensure the underlying memory is not aliased elsewhere.
102120 pub unsafe fn memset < T , A : UsmAlloc > (
103121 & mut self ,
104122 array : & mut UsmBox < T , A > ,
@@ -108,7 +126,10 @@ impl Queue {
108126 }
109127
110128 /// Sets memory allocated with USM allocations after all specified events finish.
111- /// Safety: the caller must make sure the underlying memory isn't being aliased somewhere else.
129+ ///
130+ /// # Safety
131+ ///
132+ /// The caller must ensure the underlying memory is not aliased elsewhere.
112133 pub unsafe fn memset_with_deps < T , A : UsmAlloc > (
113134 & mut self ,
114135 array : & mut UsmBox < T , A > ,
@@ -128,7 +149,7 @@ impl Queue {
128149
129150 /// Submits a barrier to the queue.
130151 pub fn barrier ( & mut self ) -> Result < Event > {
131- self . barrier_with_deps ( & [ ] ) . map ( Into :: into )
152+ self . barrier_with_deps ( & [ ] )
132153 }
133154
134155 /// Submits a barrier to the queue after all specified events finish.
@@ -153,7 +174,9 @@ impl Queue {
153174 /// Enqueues a kernel object to the queue as an ND-range kernel, using the number of work-items
154175 /// specified by the [`NdRange`] nd_range.
155176 ///
156- /// Safety: The caller must make sure each argument matches the launched SYCL kernel's
177+ /// # Safety
178+ ///
179+ /// The caller must make sure each argument matches the launched SYCL kernel's
157180 /// signature, including their respective size, layout and alignment.
158181 pub unsafe fn launch < const ARGC : usize , const DIMENSIONS : usize > (
159182 & mut self ,
0 commit comments