Skip to content

Commit 4f9f498

Browse files
committed
fix(gpu): fix memory leak in rerand
1 parent d75844d commit 4f9f498

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

backends/tfhe-cuda-backend/cuda/include/integer/rerand_utilities.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
template <typename Torus> struct int_rerand_mem {
99
int_radix_params params;
10-
Torus *lwe_trivial_indexes;
1110

1211
Torus *tmp_zero_lwes;
1312
Torus *tmp_ksed_zero_lwes;
13+
Torus *lwe_trivial_indexes;
1414
uint32_t num_lwes;
1515

1616
bool gpu_memory_allocated;
@@ -54,7 +54,7 @@ template <typename Torus> struct int_rerand_mem {
5454
num_lwes * sizeof(Torus), streams.stream(0),
5555
streams.gpu_index(0));
5656

57-
streams.synchronize();
57+
cuda_synchronize_stream(streams.stream(0), streams.gpu_index(0));
5858

5959
free(h_lwe_trivial_indexes);
6060
}
@@ -66,6 +66,9 @@ template <typename Torus> struct int_rerand_mem {
6666
cuda_drop_with_size_tracking_async(tmp_ksed_zero_lwes, streams.stream(0),
6767
streams.gpu_index(0),
6868
gpu_memory_allocated);
69+
cuda_drop_with_size_tracking_async(lwe_trivial_indexes, streams.stream(0),
70+
streams.gpu_index(0),
71+
gpu_memory_allocated);
6972
cuda_drop_with_size_tracking_async(d_expand_jobs, streams.stream(0),
7073
streams.gpu_index(0),
7174
gpu_memory_allocated);

0 commit comments

Comments
 (0)