Skip to content

Commit 87ea91c

Browse files
chore: remove the drop-specific code, since Rust automatically drops the events and buffers when they go out of scope.
1 parent 5b6d246 commit 87ea91c

File tree

1 file changed

+3
-20
lines changed
  • samples/introduction/async_api/src

1 file changed

+3
-20
lines changed

samples/introduction/async_api/src/main.rs

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use cust::context::Context;
21
use cust::device::Device;
32
use cust::event::{Event, EventFlags};
43
use cust::function::{BlockSize, GridSize};
@@ -30,7 +29,7 @@ fn main() -> Result<(), cust::error::CudaError> {
3029
println!("Device Name: {}", device.name().unwrap());
3130

3231
// 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();
3433
let module = Module::from_ptx(PTX, &[]).expect("Module couldn't be init!");
3534
let increment = module
3635
.get_function("increment")
@@ -113,24 +112,8 @@ fn main() -> Result<(), cust::error::CudaError> {
113112
// Stream is synchronized as a safety measure
114113
stream.synchronize().expect("Stream couldn't synchronize!");
115114

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-
134115
println!("test PASSED");
135116
Ok(())
117+
118+
// The events and the memory buffers are automatically dropped here.
136119
}

0 commit comments

Comments
 (0)