1- use cust:: context:: Context ;
21use cust:: device:: Device ;
32use cust:: event:: { Event , EventFlags } ;
43use cust:: function:: { BlockSize , GridSize } ;
4+ use cust:: launch;
55use cust:: memory:: { AsyncCopyDestination , DeviceBuffer , LockedBuffer } ;
66use cust:: module:: Module ;
77use cust:: prelude:: EventStatus ;
88use cust:: stream:: { Stream , StreamFlags } ;
9- use cust:: { CudaFlags , launch} ;
109use std:: time:: Instant ;
1110
1211static PTX : & str = include_str ! ( concat!( env!( "OUT_DIR" ) , "/kernels.ptx" ) ) ;
@@ -54,7 +53,9 @@ fn main() -> Result<(), cust::error::CudaError> {
5453 . expect ( "Failed to record start_event in the CUDA stream!" ) ;
5554 let start = Instant :: now ( ) ;
5655
57- // SAFETY: until the stop_event is triggered:
56+ // # Safety
57+ //
58+ // Until the stop_event is triggered:
5859 // 1. `host_a` is not being modified
5960 // 2. Both `device_a` and `host_a` are not deallocated
6061 // 3. Until `stop_query` yields `EventStatus::Ready`, `device_a` is not involved in any other operation
@@ -65,7 +66,9 @@ fn main() -> Result<(), cust::error::CudaError> {
6566 . expect ( "Could not copy from host to device!" ) ;
6667 }
6768
68- // SAFETY: number of threads * number of blocks = total number of elements.
69+ // # Safety
70+ //
71+ // Number of threads * number of blocks = total number of elements.
6972 // Hence there will not be any out-of-bounds issues.
7073 unsafe {
7174 let result = launch ! ( increment<<<grids, blocks, 0 , stream>>>(
@@ -75,7 +78,9 @@ fn main() -> Result<(), cust::error::CudaError> {
7578 result. expect ( "Result of `increment` kernel did not process!" ) ;
7679 }
7780
78- // SAFETY: until the stop_event is triggered:
81+ // # Safety
82+ //
83+ // Until the stop_event is triggered:
7984 // 1. `device_a` is not being modified
8085 // 2. Both `device_a` and `host_a` are not deallocated
8186 // 3. At this point, until `stop_query` yields `EventStatus::Ready`,
0 commit comments