File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -484,6 +484,9 @@ pub struct CudaStream {
484
484
device : Arc < CudaDevice > ,
485
485
}
486
486
487
+ unsafe impl Send for CudaStream { }
488
+ unsafe impl Sync for CudaStream { }
489
+
487
490
impl CudaDevice {
488
491
/// Allocates a new stream that can execute kernels concurrently to the default stream.
489
492
///
@@ -906,6 +909,8 @@ impl<R: RangeBounds<usize>> RangeHelper for R {
906
909
907
910
#[ cfg( test) ]
908
911
mod tests {
912
+ use std:: thread;
913
+
909
914
use super :: * ;
910
915
911
916
#[ test]
@@ -930,4 +935,17 @@ mod tests {
930
935
assert ! ( unsafe { slice. transmute_mut:: <f32 >( 25 ) } . is_some( ) ) ;
931
936
assert ! ( unsafe { slice. transmute_mut:: <f32 >( 26 ) } . is_none( ) ) ;
932
937
}
938
+
939
+ #[ test]
940
+ fn test_send_dev ( ) {
941
+ let dev = CudaDevice :: new ( 0 ) . unwrap ( ) ;
942
+ thread:: spawn ( || dev) ;
943
+ }
944
+
945
+ #[ test]
946
+ fn test_send_stream ( ) {
947
+ let dev = CudaDevice :: new ( 0 ) . unwrap ( ) ;
948
+ let stream = dev. fork_default_stream ( ) . unwrap ( ) ;
949
+ thread:: spawn ( || stream) ;
950
+ }
933
951
}
You can’t perform that action at this time.
0 commit comments