Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(gpu): remove device synchronization in drop for CudaVec
Browse files Browse the repository at this point in the history
agnesLeroy committed Aug 8, 2024
1 parent 5340859 commit befaae1
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;
@@ -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) };
}
}
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
@@ -337,6 +337,7 @@ impl CudaServerKey {
let mut result = unsafe { ciphertexts[0].duplicate_async(streams) };

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

0 comments on commit befaae1

Please sign in to comment.