|
1 | | -use cust::context::Context; |
2 | 1 | use cust::device::Device; |
3 | 2 | use cust::event::{Event, EventFlags}; |
4 | 3 | use cust::function::{BlockSize, GridSize}; |
@@ -30,7 +29,7 @@ fn main() -> Result<(), cust::error::CudaError> { |
30 | 29 | println!("Device Name: {}", device.name().unwrap()); |
31 | 30 |
|
32 | 31 | // Set up the context, load the module, and create a stream to run kernels in. |
33 | | - let _ctx = Context::new(device); |
| 32 | + let _ctx = cust::quick_init(); |
34 | 33 | let module = Module::from_ptx(PTX, &[]).expect("Module couldn't be init!"); |
35 | 34 | let increment = module |
36 | 35 | .get_function("increment") |
@@ -113,24 +112,8 @@ fn main() -> Result<(), cust::error::CudaError> { |
113 | 112 | // Stream is synchronized as a safety measure |
114 | 113 | stream.synchronize().expect("Stream couldn't synchronize!"); |
115 | 114 |
|
116 | | - // Events and buffers can be safely dropped now |
117 | | - match Event::drop(start_event) { |
118 | | - Ok(()) => println!("Successfully destroyed start_event"), |
119 | | - Err((cuda_error, _event)) => { |
120 | | - println!("Failed to destroy start_event: {:?}", cuda_error); |
121 | | - } |
122 | | - } |
123 | | - |
124 | | - match Event::drop(stop_event) { |
125 | | - Ok(()) => println!("Successfully destroyed stop_event"), |
126 | | - Err((cuda_error, _event)) => { |
127 | | - println!("Failed to destroy stop_event: {:?}", cuda_error); |
128 | | - } |
129 | | - } |
130 | | - |
131 | | - DeviceBuffer::drop(device_a).expect("Couldn't drop device array!"); |
132 | | - LockedBuffer::drop(host_a).expect("Couldn't drop host array!"); |
133 | | - |
134 | 115 | println!("test PASSED"); |
135 | 116 | Ok(()) |
| 117 | + |
| 118 | + // The events and the memory buffers are automatically dropped here. |
136 | 119 | } |
0 commit comments