mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-14 09:08:06 -05:00
Compare commits
1 Commits
pa/paralle
...
go/chore/u
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5b9b7a032 |
@@ -51,11 +51,10 @@ impl Default for ParamsAndNumBlocksIter {
|
||||
} else {
|
||||
// FIXME One set of parameter is tested since we want to benchmark only quickest
|
||||
// operations.
|
||||
let params = vec![
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS.into(),
|
||||
// PARAM_MESSAGE_3_CARRY_3_KS_PBS.into(),
|
||||
// PARAM_MESSAGE_4_CARRY_4_KS_PBS.into(),
|
||||
];
|
||||
#[cfg(feature = "gpu")]
|
||||
let params = vec![PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS.into()];
|
||||
#[cfg(not(feature = "gpu"))]
|
||||
let params = vec![PARAM_MESSAGE_2_CARRY_2_KS_PBS.into()];
|
||||
|
||||
let params_and_bit_sizes = iproduct!(params, env_config.bit_sizes());
|
||||
Self {
|
||||
|
||||
@@ -11,11 +11,14 @@ use tfhe::integer::keycache::KEY_CACHE;
|
||||
use tfhe::integer::prelude::*;
|
||||
use tfhe::integer::{IntegerKeyKind, RadixCiphertext, ServerKey, SignedRadixCiphertext, I256};
|
||||
use tfhe::keycache::NamedParam;
|
||||
#[cfg(feature = "gpu")]
|
||||
use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS;
|
||||
use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
#[cfg(not(feature = "gpu"))]
|
||||
use tfhe::shortint::parameters::PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS;
|
||||
use tfhe::shortint::parameters::*;
|
||||
// #[cfg(feature = "gpu")]
|
||||
// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS;
|
||||
// #[cfg(feature = "gpu")]
|
||||
// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
// #[cfg(not(feature = "gpu"))]
|
||||
// use tfhe::shortint::parameters::PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS;
|
||||
|
||||
fn gen_random_i256(rng: &mut ThreadRng) -> I256 {
|
||||
let clearlow = rng.gen::<u128>();
|
||||
@@ -49,12 +52,10 @@ impl Default for ParamsAndNumBlocksIter {
|
||||
} else {
|
||||
// FIXME One set of parameter is tested since we want to benchmark only quickest
|
||||
// operations.
|
||||
let params = vec![
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS.into(),
|
||||
// PARAM_MESSAGE_3_CARRY_3_KS_PBS.into(),
|
||||
// PARAM_MESSAGE_4_CARRY_4_KS_PBS.into(),
|
||||
];
|
||||
|
||||
#[cfg(feature = "gpu")]
|
||||
let params = vec![PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS.into()];
|
||||
#[cfg(not(feature = "gpu"))]
|
||||
let params = vec![PARAM_MESSAGE_2_CARRY_2_KS_PBS.into()];
|
||||
let params_and_bit_sizes = iproduct!(params, env_config.bit_sizes());
|
||||
Self {
|
||||
params_and_bit_sizes,
|
||||
|
||||
@@ -32,14 +32,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let streams = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &streams);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &streams);
|
||||
///
|
||||
/// let msg1 = 14;
|
||||
/// let msg2 = 97;
|
||||
@@ -125,14 +125,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let streams = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &streams);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &streams);
|
||||
///
|
||||
/// let msg1 = 10;
|
||||
/// let msg2 = 127;
|
||||
@@ -361,14 +361,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let streams = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &streams);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &streams);
|
||||
/// let total_bits = num_blocks * cks.parameters().message_modulus().0.ilog2() as usize;
|
||||
/// let modulus = 1 << total_bits;
|
||||
///
|
||||
|
||||
@@ -23,14 +23,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg = 1u64;
|
||||
///
|
||||
@@ -149,14 +149,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg1 = 201u64;
|
||||
/// let msg2 = 1u64;
|
||||
@@ -296,14 +296,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg1 = 200u64;
|
||||
/// let msg2 = 1u64;
|
||||
@@ -363,14 +363,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg1 = 49;
|
||||
/// let msg2 = 64;
|
||||
@@ -430,14 +430,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg1 = 201u64;
|
||||
/// let msg2 = 1u64;
|
||||
@@ -535,14 +535,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg1 = 201u64;
|
||||
/// let msg2 = 1u64;
|
||||
@@ -639,14 +639,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg1 = 201u64;
|
||||
/// let msg2 = 1u64;
|
||||
@@ -744,14 +744,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg = 1u64;
|
||||
///
|
||||
|
||||
@@ -145,14 +145,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg1 = 14u64;
|
||||
/// let msg2 = 97u64;
|
||||
@@ -218,14 +218,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg1 = 14u64;
|
||||
/// let msg2 = 97u64;
|
||||
@@ -316,14 +316,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg1 = 14u64;
|
||||
/// let msg2 = 97u64;
|
||||
@@ -409,14 +409,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg1 = 14u64;
|
||||
/// let msg2 = 97u64;
|
||||
@@ -472,14 +472,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg1 = 14u64;
|
||||
/// let msg2 = 97u64;
|
||||
@@ -595,14 +595,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg1 = 97u64;
|
||||
/// let msg2 = 97u64;
|
||||
@@ -718,14 +718,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg1 = 237u64;
|
||||
/// let msg2 = 23u64;
|
||||
@@ -841,14 +841,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg1 = 237u64;
|
||||
/// let msg2 = 23u64;
|
||||
|
||||
@@ -54,7 +54,7 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::{gen_keys_radix, RadixCiphertext};
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
@@ -62,7 +62,8 @@ impl CudaServerKey {
|
||||
/// let num_blocks = 4;
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &mut stream);
|
||||
/// let (cks, sks) =
|
||||
/// gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &mut stream);
|
||||
///
|
||||
/// let d_ctxt: CudaUnsignedRadixCiphertext =
|
||||
/// sks.create_trivial_zero_radix(num_blocks, &mut stream);
|
||||
@@ -89,7 +90,7 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::{gen_keys_radix, RadixCiphertext};
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
@@ -97,7 +98,8 @@ impl CudaServerKey {
|
||||
/// let num_blocks = 4;
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &mut stream);
|
||||
/// let (cks, sks) =
|
||||
/// gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &mut stream);
|
||||
///
|
||||
/// let d_ctxt: CudaUnsignedRadixCiphertext =
|
||||
/// sks.create_trivial_radix(212u64, num_blocks, &mut stream);
|
||||
@@ -296,7 +298,7 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::{CudaRadixCiphertext, CudaUnsignedRadixCiphertext};
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::IntegerCiphertext;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let num_blocks = 4;
|
||||
///
|
||||
@@ -304,7 +306,8 @@ impl CudaServerKey {
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &mut stream);
|
||||
/// let (cks, sks) =
|
||||
/// gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &mut stream);
|
||||
///
|
||||
/// let mut d_ct1: CudaUnsignedRadixCiphertext =
|
||||
/// sks.create_trivial_radix(7u64, num_blocks, &mut stream);
|
||||
@@ -319,7 +322,7 @@ impl CudaServerKey {
|
||||
/// // Decrypt
|
||||
/// let res: u64 = cks.decrypt(&ct_res);
|
||||
/// assert_eq!(
|
||||
/// 7 * (PARAM_MESSAGE_2_CARRY_2_KS_PBS.message_modulus.0 as u64).pow(added_blocks as u32),
|
||||
/// 7 * (PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS.message_modulus.0 as u64).pow(added_blocks as u32),
|
||||
/// res
|
||||
/// );
|
||||
/// ```
|
||||
@@ -371,7 +374,7 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::IntegerCiphertext;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let num_blocks = 4;
|
||||
///
|
||||
@@ -379,7 +382,8 @@ impl CudaServerKey {
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &mut stream);
|
||||
/// let (cks, sks) =
|
||||
/// gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &mut stream);
|
||||
///
|
||||
/// let mut d_ct1: CudaUnsignedRadixCiphertext =
|
||||
/// sks.create_trivial_radix(7u64, num_blocks, &mut stream);
|
||||
@@ -436,7 +440,7 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::IntegerCiphertext;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let num_blocks = 4;
|
||||
///
|
||||
@@ -444,7 +448,8 @@ impl CudaServerKey {
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &mut stream);
|
||||
/// let (cks, sks) =
|
||||
/// gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &mut stream);
|
||||
///
|
||||
/// let mut d_ct1: CudaUnsignedRadixCiphertext =
|
||||
/// sks.create_trivial_radix(119u64, num_blocks, &mut stream);
|
||||
@@ -503,7 +508,7 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::IntegerCiphertext;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let num_blocks = 4;
|
||||
///
|
||||
@@ -511,7 +516,8 @@ impl CudaServerKey {
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &mut stream);
|
||||
/// let (cks, sks) =
|
||||
/// gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &mut stream);
|
||||
///
|
||||
/// let mut d_ct1: CudaUnsignedRadixCiphertext =
|
||||
/// sks.create_trivial_radix(119u64, num_blocks, &mut stream);
|
||||
@@ -712,14 +718,15 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaSignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::IntegerCiphertext;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let num_blocks = 4;
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &mut stream);
|
||||
/// let (cks, sks) =
|
||||
/// gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &mut stream);
|
||||
///
|
||||
/// let msg = -2i8;
|
||||
///
|
||||
@@ -801,14 +808,15 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::{gen_keys_radix, IntegerCiphertext};
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let num_blocks = 8;
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &mut stream);
|
||||
/// let (cks, sks) =
|
||||
/// gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &mut stream);
|
||||
///
|
||||
/// let msg = u16::MAX;
|
||||
///
|
||||
|
||||
@@ -17,7 +17,7 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let number_of_blocks = 2;
|
||||
///
|
||||
@@ -25,9 +25,9 @@ impl CudaServerKey {
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, &mut stream);
|
||||
///
|
||||
/// let modulus = PARAM_MESSAGE_2_CARRY_2_KS_PBS
|
||||
/// let modulus = PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS
|
||||
/// .message_modulus
|
||||
/// .0
|
||||
/// .pow(number_of_blocks as u32) as u64;
|
||||
@@ -144,7 +144,7 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let number_of_blocks = 2;
|
||||
///
|
||||
@@ -152,9 +152,9 @@ impl CudaServerKey {
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, &mut stream);
|
||||
///
|
||||
/// let modulus = PARAM_MESSAGE_2_CARRY_2_KS_PBS
|
||||
/// let modulus = PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS
|
||||
/// .message_modulus
|
||||
/// .0
|
||||
/// .pow(number_of_blocks as u32) as u64;
|
||||
|
||||
@@ -17,7 +17,7 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
@@ -25,7 +25,7 @@ impl CudaServerKey {
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let modulus = 1 << 8;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg = 159u64;
|
||||
///
|
||||
@@ -117,7 +117,7 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
@@ -125,7 +125,7 @@ impl CudaServerKey {
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let modulus = 1 << 8;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg = 159u64;
|
||||
///
|
||||
|
||||
@@ -345,14 +345,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg = 128u8;
|
||||
/// let rotate = 2u8;
|
||||
@@ -498,14 +498,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg = 128u8;
|
||||
/// let rotate = 2u8;
|
||||
|
||||
@@ -22,14 +22,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut streams);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut streams);
|
||||
///
|
||||
/// let msg = 4;
|
||||
/// let scalar = 40;
|
||||
@@ -132,14 +132,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut streams);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut streams);
|
||||
///
|
||||
/// let msg = 4;
|
||||
/// let scalar = 40;
|
||||
|
||||
@@ -470,7 +470,7 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::{gen_keys_radix, RadixCiphertext};
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
@@ -478,7 +478,7 @@ impl CudaServerKey {
|
||||
/// let size = 4;
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &stream);
|
||||
///
|
||||
/// let msg1 = 14u64;
|
||||
/// let msg2 = 97u64;
|
||||
@@ -551,7 +551,7 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::{gen_keys_radix, RadixCiphertext};
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
@@ -559,7 +559,7 @@ impl CudaServerKey {
|
||||
/// let size = 4;
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &stream);
|
||||
///
|
||||
/// let msg1 = 14u64;
|
||||
/// let msg2 = 97u64;
|
||||
|
||||
@@ -46,14 +46,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut streams);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut streams);
|
||||
///
|
||||
/// let msg = 30;
|
||||
/// let scalar = 3;
|
||||
@@ -199,14 +199,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut streams);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut streams);
|
||||
///
|
||||
/// let msg = 30;
|
||||
/// let scalar = 3;
|
||||
@@ -279,14 +279,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut streams);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut streams);
|
||||
///
|
||||
/// let msg = 30;
|
||||
/// let scalar = 3;
|
||||
@@ -359,14 +359,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut streams);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut streams);
|
||||
///
|
||||
/// let msg = 30;
|
||||
/// let scalar = 3;
|
||||
|
||||
@@ -23,14 +23,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg = 30;
|
||||
/// let scalar = 3;
|
||||
@@ -186,14 +186,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg = 30;
|
||||
/// let scalar = 3;
|
||||
|
||||
@@ -111,14 +111,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg = 21u64;
|
||||
/// let shift = 2;
|
||||
@@ -311,14 +311,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg = 21u64;
|
||||
/// let shift = 2;
|
||||
@@ -403,14 +403,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg = 21u64;
|
||||
/// let shift = 2;
|
||||
@@ -490,14 +490,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg = 21u64;
|
||||
/// let shift = 2;
|
||||
|
||||
@@ -20,14 +20,15 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &mut stream);
|
||||
/// let (cks, sks) =
|
||||
/// gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &mut stream);
|
||||
///
|
||||
/// let msg = 40;
|
||||
/// let scalar = 3;
|
||||
@@ -99,14 +100,15 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &mut stream);
|
||||
/// let (cks, sks) =
|
||||
/// gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &mut stream);
|
||||
///
|
||||
/// let msg = 40;
|
||||
/// let scalar = 3;
|
||||
|
||||
@@ -341,14 +341,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg = 128;
|
||||
/// let shift = 2;
|
||||
@@ -493,14 +493,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &mut stream);
|
||||
///
|
||||
/// let msg = 21;
|
||||
/// let shift = 2;
|
||||
|
||||
@@ -27,13 +27,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let streams = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &streams);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &streams);
|
||||
///
|
||||
/// let msg_1 = 12;
|
||||
/// let msg_2 = 10;
|
||||
@@ -109,14 +109,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let streams = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &streams);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, num_blocks, &streams);
|
||||
///
|
||||
/// let msg_1 = 128;
|
||||
/// let msg_2 = 99;
|
||||
@@ -167,14 +167,14 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let streams = CudaStreams::new_single_gpu(gpu_index);
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS, size, &streams);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS, size, &streams);
|
||||
///
|
||||
/// let msg_1 = 120u8;
|
||||
/// let msg_2 = 181u8;
|
||||
|
||||
@@ -44,12 +44,12 @@ macro_rules! define_gpu_signed_comparison_test_functions {
|
||||
|
||||
// Then call our create_gpu_parametrized_test macro onto or specialized fns
|
||||
create_gpu_parametrized_test!([<integer_signed_unchecked_ $comparison_name _ $clear_type>]{
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
create_gpu_parametrized_test!([<integer_signed_default_ $comparison_name _ $clear_type>]{
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
@@ -90,22 +90,22 @@ where
|
||||
}
|
||||
|
||||
create_gpu_parametrized_test!(integer_signed_unchecked_max_128_bits {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
create_gpu_parametrized_test!(integer_signed_unchecked_min_128_bits {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
create_gpu_parametrized_test!(integer_signed_max_128_bits {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
create_gpu_parametrized_test!(integer_signed_min_128_bits {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
|
||||
@@ -42,12 +42,12 @@ macro_rules! define_gpu_signed_scalar_comparison_test_functions {
|
||||
}
|
||||
|
||||
create_gpu_parametrized_test!([<integer_signed_unchecked_scalar_ $comparison_name _ $clear_type>]{
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
create_gpu_parametrized_test!([<integer_signed_default_scalar_ $comparison_name $clear_type>]{
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
@@ -88,22 +88,22 @@ where
|
||||
}
|
||||
|
||||
create_gpu_parametrized_test!(integer_signed_unchecked_scalar_max_i128 {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
create_gpu_parametrized_test!(integer_signed_unchecked_scalar_min_i128 {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
create_gpu_parametrized_test!(integer_signed_scalar_max_i128 {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
create_gpu_parametrized_test!(integer_signed_scalar_min_i128 {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
|
||||
@@ -40,8 +40,8 @@ macro_rules! create_gpu_parametrized_test{
|
||||
($name:ident)=> {
|
||||
create_gpu_parametrized_test!($name
|
||||
{
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_3_CARRY_3_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
|
||||
@@ -41,12 +41,12 @@ macro_rules! define_gpu_comparison_test_functions {
|
||||
}
|
||||
|
||||
create_gpu_parametrized_test!([<integer_unchecked_ $comparison_name _ $clear_type:lower>]{
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
create_gpu_parametrized_test!([<integer_default_ $comparison_name _ $clear_type:lower>]{
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
@@ -87,22 +87,22 @@ where
|
||||
}
|
||||
|
||||
create_gpu_parametrized_test!(integer_unchecked_min_u256 {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
create_gpu_parametrized_test!(integer_unchecked_max_u256 {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
create_gpu_parametrized_test!(integer_min_u256 {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
create_gpu_parametrized_test!(integer_max_u256 {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
|
||||
@@ -45,12 +45,12 @@ macro_rules! define_gpu_scalar_comparison_test_functions {
|
||||
}
|
||||
|
||||
create_gpu_parametrized_test!([<integer_unchecked_scalar_ $comparison_name _ $clear_type:lower>]{
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
create_gpu_parametrized_test!([<integer_default_scalar_ $comparison_name$clear_type:lower>]{
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
@@ -224,22 +224,22 @@ where
|
||||
}
|
||||
|
||||
create_gpu_parametrized_test!(integer_unchecked_scalar_min_u256 {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
create_gpu_parametrized_test!(integer_unchecked_scalar_max_u256 {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
create_gpu_parametrized_test!(integer_scalar_min_u256 {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
create_gpu_parametrized_test!(integer_scalar_max_u256 {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS,
|
||||
PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
});
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
use crate::core_crypto::prelude::*;
|
||||
use crate::shortint::ciphertext::MaxNoiseLevel;
|
||||
use crate::shortint::parameters::{CarryModulus, ClassicPBSParameters, MessageModulus};
|
||||
|
||||
// p-fail = 2^-64.179, algorithmic cost ~ 60, 2-norm = 3
|
||||
pub const PARAM_GPU_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64: ClassicPBSParameters =
|
||||
ClassicPBSParameters {
|
||||
lwe_dimension: LweDimension(785),
|
||||
glwe_dimension: GlweDimension(4),
|
||||
polynomial_size: PolynomialSize(512),
|
||||
lwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
|
||||
8.2770753462599e-06,
|
||||
)),
|
||||
glwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
|
||||
2.845267479601915e-15,
|
||||
)),
|
||||
pbs_base_log: DecompositionBaseLog(23),
|
||||
pbs_level: DecompositionLevelCount(1),
|
||||
ks_base_log: DecompositionBaseLog(4),
|
||||
ks_level: DecompositionLevelCount(3),
|
||||
message_modulus: MessageModulus(2),
|
||||
carry_modulus: CarryModulus(2),
|
||||
max_noise_level: MaxNoiseLevel::new(3),
|
||||
log2_p_fail: -64.179,
|
||||
ciphertext_modulus: CiphertextModulus::new_native(),
|
||||
encryption_key_choice: EncryptionKeyChoice::Big,
|
||||
};
|
||||
// p-fail = 2^-64.082, algorithmic cost ~ 107, 2-norm = 5
|
||||
pub const PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64: ClassicPBSParameters =
|
||||
ClassicPBSParameters {
|
||||
lwe_dimension: LweDimension(841),
|
||||
glwe_dimension: GlweDimension(1),
|
||||
polynomial_size: PolynomialSize(2048),
|
||||
lwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
|
||||
3.1496674685772435e-06,
|
||||
)),
|
||||
glwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
|
||||
2.845267479601915e-15,
|
||||
)),
|
||||
pbs_base_log: DecompositionBaseLog(22),
|
||||
pbs_level: DecompositionLevelCount(1),
|
||||
ks_base_log: DecompositionBaseLog(3),
|
||||
ks_level: DecompositionLevelCount(5),
|
||||
message_modulus: MessageModulus(4),
|
||||
carry_modulus: CarryModulus(4),
|
||||
max_noise_level: MaxNoiseLevel::new(5),
|
||||
log2_p_fail: -64.082,
|
||||
ciphertext_modulus: CiphertextModulus::new_native(),
|
||||
encryption_key_choice: EncryptionKeyChoice::Big,
|
||||
};
|
||||
// p-fail = 2^-64.149, algorithmic cost ~ 838, 2-norm = 9
|
||||
pub const PARAM_GPU_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64: ClassicPBSParameters =
|
||||
ClassicPBSParameters {
|
||||
lwe_dimension: LweDimension(984),
|
||||
glwe_dimension: GlweDimension(1),
|
||||
polynomial_size: PolynomialSize(8192),
|
||||
lwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
|
||||
2.671498718807819e-07,
|
||||
)),
|
||||
glwe_noise_distribution: DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
|
||||
2.168404344971009e-19,
|
||||
)),
|
||||
pbs_base_log: DecompositionBaseLog(14),
|
||||
pbs_level: DecompositionLevelCount(2),
|
||||
ks_base_log: DecompositionBaseLog(3),
|
||||
ks_level: DecompositionLevelCount(6),
|
||||
message_modulus: MessageModulus(8),
|
||||
carry_modulus: CarryModulus(8),
|
||||
max_noise_level: MaxNoiseLevel::new(9),
|
||||
log2_p_fail: -64.149,
|
||||
ciphertext_modulus: CiphertextModulus::new_native(),
|
||||
encryption_key_choice: EncryptionKeyChoice::Big,
|
||||
};
|
||||
|
||||
pub const GPU_WITH_CARRY_PARAMETERS_VEC: [ClassicPBSParameters; 3] = [
|
||||
PARAM_GPU_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
PARAM_GPU_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
];
|
||||
@@ -1,2 +1,3 @@
|
||||
pub mod ks_pbs;
|
||||
pub mod ks_pbs_gpu;
|
||||
pub mod pbs_ks;
|
||||
|
||||
@@ -33,9 +33,11 @@ pub use super::PBSOrder;
|
||||
pub use crate::core_crypto::commons::parameters::EncryptionKeyChoice;
|
||||
pub use crate::shortint::parameters::classic::compact_pk::*;
|
||||
pub use crate::shortint::parameters::classic::gaussian::p_fail_2_minus_64::ks_pbs::*;
|
||||
pub use crate::shortint::parameters::classic::gaussian::p_fail_2_minus_64::ks_pbs_gpu::*;
|
||||
pub use crate::shortint::parameters::classic::gaussian::p_fail_2_minus_64::pbs_ks::*;
|
||||
pub use crate::shortint::parameters::classic::tuniform::p_fail_2_minus_64::ks_pbs::*;
|
||||
pub use crate::shortint::parameters::classic::tuniform::p_fail_2_minus_64::pbs_ks::*;
|
||||
|
||||
pub use compact_public_key_only::CompactCiphertextListExpansionKind;
|
||||
#[cfg(tarpaulin)]
|
||||
pub use coverage_parameters::*;
|
||||
@@ -823,3 +825,10 @@ pub const PARAM_SMALL_MESSAGE_1_CARRY_1: ClassicPBSParameters = PARAM_MESSAGE_1_
|
||||
pub const PARAM_SMALL_MESSAGE_2_CARRY_2: ClassicPBSParameters = PARAM_MESSAGE_2_CARRY_2_PBS_KS;
|
||||
pub const PARAM_SMALL_MESSAGE_3_CARRY_3: ClassicPBSParameters = PARAM_MESSAGE_3_CARRY_3_PBS_KS;
|
||||
pub const PARAM_SMALL_MESSAGE_4_CARRY_4: ClassicPBSParameters = PARAM_MESSAGE_4_CARRY_4_PBS_KS;
|
||||
|
||||
pub const PARAM_GPU_MESSAGE_1_CARRY_1_KS_PBS: ClassicPBSParameters =
|
||||
PARAM_GPU_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64;
|
||||
pub const PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS: ClassicPBSParameters =
|
||||
PARAM_GPU_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
pub const PARAM_GPU_MESSAGE_3_CARRY_3_KS_PBS: ClassicPBSParameters =
|
||||
PARAM_GPU_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64;
|
||||
|
||||
Reference in New Issue
Block a user