chore(gpu): add checks to ensure limits for compression

This commit is contained in:
Pedro Alves
2024-09-12 11:36:44 -03:00
committed by Pedro Alves
parent 24088fd494
commit faf200218b
3 changed files with 14 additions and 2 deletions

View File

@@ -280,6 +280,12 @@ __host__ void host_packing_keyswitch_lwe_list_to_glwe(
uint32_t lwe_dimension_in, uint32_t glwe_dimension,
uint32_t polynomial_size, uint32_t base_log, uint32_t level_count,
uint32_t num_lwes) {
if (num_lwes > polynomial_size)
PANIC("Cuda error: too many LWEs to pack. The number of LWEs should be "
"smaller than "
"polynomial_size.")
cudaSetDevice(gpu_index);
int glwe_accumulator_size = (glwe_dimension + 1) * polynomial_size;