Skip to content

Commit

Permalink
chore(gpu): remove device synchronization in drop for CudaVec
Browse files Browse the repository at this point in the history
  • Loading branch information
agnesLeroy committed Sep 2, 2024
1 parent c258d53 commit 39cee66
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 1 addition & 3 deletions tfhe/src/core_crypto/gpu/vec.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::core_crypto::gpu::slice::{CudaSlice, CudaSliceMut};
use crate::core_crypto::gpu::{synchronize_device, CudaStreams};
use crate::core_crypto::gpu::CudaStreams;
use crate::core_crypto::prelude::Numeric;
use std::collections::Bound::{Excluded, Included, Unbounded};
use std::ffi::c_void;
Expand Down Expand Up @@ -447,8 +447,6 @@ impl<T: Numeric> Drop for CudaVec<T> {
/// Free memory for pointer `ptr` synchronously
fn drop(&mut self) {
for &gpu_index in self.gpu_indexes.iter() {
// Synchronizes the device to be sure no stream is still using this pointer
synchronize_device(gpu_index);
unsafe { cuda_drop(self.get_mut_c_ptr(gpu_index), gpu_index) };
}
}
Expand Down
1 change: 1 addition & 0 deletions tfhe/src/integer/gpu/server_key/radix/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ impl CudaServerKey {
let mut result = unsafe { ciphertexts[0].duplicate_async(streams) };

if ciphertexts.len() == 1 {
streams.synchronize();
return Some(result);
}

Expand Down

0 comments on commit 39cee66

Please sign in to comment.