@@ -5,13 +5,14 @@ use std::{
55} ;
66
77use const_type_layout:: TypeGraphLayout ;
8- use rustacuda :: {
8+ use cust :: {
99 context:: Context ,
1010 error:: CudaError ,
1111 event:: Event ,
1212 memory:: { CopyDestination , DeviceBox , DeviceBuffer , LockedBox , LockedBuffer } ,
1313 module:: Module ,
1414} ;
15+ use cust_core:: DeviceCopy ;
1516
1617use crate :: {
1718 safety:: PortableBitSemantics ,
@@ -30,12 +31,12 @@ type InvariantLifetime<'brand> = PhantomData<fn(&'brand ()) -> &'brand ()>;
3031#[ derive( Copy , Clone ) ]
3132#[ repr( transparent) ]
3233pub struct Stream < ' stream > {
33- stream : & ' stream rustacuda :: stream:: Stream ,
34+ stream : & ' stream cust :: stream:: Stream ,
3435 _brand : InvariantLifetime < ' stream > ,
3536}
3637
3738impl < ' stream > Deref for Stream < ' stream > {
38- type Target = rustacuda :: stream:: Stream ;
39+ type Target = cust :: stream:: Stream ;
3940
4041 fn deref ( & self ) -> & Self :: Target {
4142 self . stream
@@ -65,7 +66,7 @@ impl<'stream> Stream<'stream> {
6566 /// }
6667 /// ```
6768 pub fn with < O > (
68- stream : & mut rustacuda :: stream:: Stream ,
69+ stream : & mut cust :: stream:: Stream ,
6970 inner : impl for < ' new_stream > FnOnce ( Stream < ' new_stream > ) -> O ,
7071 ) -> O {
7172 inner ( Stream {
@@ -77,7 +78,7 @@ impl<'stream> Stream<'stream> {
7778
7879pub trait CudaDroppable : Sized {
7980 #[ expect( clippy:: missing_errors_doc) ]
80- fn drop ( val : Self ) -> Result < ( ) , ( rustacuda :: error:: CudaError , Self ) > ;
81+ fn drop ( val : Self ) -> Result < ( ) , ( cust :: error:: CudaError , Self ) > ;
8182}
8283
8384#[ repr( transparent) ]
@@ -112,25 +113,27 @@ impl<C: CudaDroppable> DerefMut for CudaDropWrapper<C> {
112113 }
113114}
114115
115- impl < T > CudaDroppable for DeviceBox < T > {
116+ impl < T : DeviceCopy > CudaDroppable for DeviceBox < T > {
116117 fn drop ( val : Self ) -> Result < ( ) , ( CudaError , Self ) > {
117118 Self :: drop ( val)
118119 }
119120}
120121
121- impl < T : rustacuda_core :: DeviceCopy > CudaDroppable for DeviceBuffer < T > {
122+ impl < T : cust_core :: DeviceCopy > CudaDroppable for DeviceBuffer < T > {
122123 fn drop ( val : Self ) -> Result < ( ) , ( CudaError , Self ) > {
123124 Self :: drop ( val)
124125 }
125126}
126127
127- impl < T > CudaDroppable for LockedBox < T > {
128+ impl < T : DeviceCopy > CudaDroppable for LockedBox < T > {
128129 fn drop ( val : Self ) -> Result < ( ) , ( CudaError , Self ) > {
129- Self :: drop ( val)
130+ // FIXME: cust's LockedBox no longer has a fallible drop
131+ std:: mem:: drop ( val) ;
132+ Ok ( ( ) )
130133 }
131134}
132135
133- impl < T : rustacuda_core :: DeviceCopy > CudaDroppable for LockedBuffer < T > {
136+ impl < T : cust_core :: DeviceCopy > CudaDroppable for LockedBuffer < T > {
134137 fn drop ( val : Self ) -> Result < ( ) , ( CudaError , Self ) > {
135138 Self :: drop ( val)
136139 }
@@ -147,7 +150,7 @@ macro_rules! impl_sealed_drop_value {
147150}
148151
149152impl_sealed_drop_value ! ( Module ) ;
150- impl_sealed_drop_value ! ( rustacuda :: stream:: Stream ) ;
153+ impl_sealed_drop_value ! ( cust :: stream:: Stream ) ;
151154impl_sealed_drop_value ! ( Context ) ;
152155impl_sealed_drop_value ! ( Event ) ;
153156
@@ -207,7 +210,7 @@ impl<'a, T: PortableBitSemantics + TypeGraphLayout> HostAndDeviceMutRef<'a, T> {
207210 ' a : ' b ,
208211 {
209212 DeviceMutRef {
210- pointer : DeviceMutPointer ( self . device_box . as_device_ptr ( ) . as_raw_mut ( ) . cast ( ) ) ,
213+ pointer : DeviceMutPointer ( self . device_box . as_device_ptr ( ) . as_mut_ptr ( ) . cast ( ) ) ,
211214 reference : PhantomData ,
212215 }
213216 }
@@ -322,10 +325,10 @@ impl<'a, T: PortableBitSemantics + TypeGraphLayout> HostAndDeviceConstRef<'a, T>
322325 where
323326 ' a : ' b ,
324327 {
325- let mut hack = ManuallyDrop :: new ( unsafe { std:: ptr:: read ( self . device_box ) } ) ;
328+ let hack = ManuallyDrop :: new ( unsafe { std:: ptr:: read ( self . device_box ) } ) ;
326329
327330 DeviceConstRef {
328- pointer : DeviceConstPointer ( hack. as_device_ptr ( ) . as_raw ( ) . cast ( ) ) ,
331+ pointer : DeviceConstPointer ( hack. as_device_ptr ( ) . as_ptr ( ) . cast ( ) ) ,
329332 reference : PhantomData ,
330333 }
331334 }
@@ -390,7 +393,7 @@ impl<'a, T: PortableBitSemantics + TypeGraphLayout> HostAndDeviceOwned<'a, T> {
390393 #[ must_use]
391394 pub ( crate ) fn for_device ( self ) -> DeviceOwnedRef < ' a , T > {
392395 DeviceOwnedRef {
393- pointer : DeviceOwnedPointer ( self . device_box . as_device_ptr ( ) . as_raw_mut ( ) . cast ( ) ) ,
396+ pointer : DeviceOwnedPointer ( self . device_box . as_device_ptr ( ) . as_mut_ptr ( ) . cast ( ) ) ,
394397 marker : PhantomData :: < T > ,
395398 reference : PhantomData :: < & ' a mut ( ) > ,
396399 }
0 commit comments