Browse Source

Fix e2e test output bug

Samir Menon 1 year ago
parent
commit
853ba1df6f
3 changed files with 9 additions and 3 deletions
  1. 3 2
      spiral-rs/src/bin/e2e.rs
  2. 5 0
      spiral-rs/src/params.rs
  3. 1 1
      spiral-rs/src/util.rs

+ 3 - 2
spiral-rs/src/bin/e2e.rs

@@ -10,8 +10,9 @@ use std::fs;
 use std::time::Instant;
 
 fn print_params_summary(params: &Params) {
-    let total_size = params.num_items() * params.db_item_size;
-    println!("{} x {} database ({} bytes total)", params.num_items(), params.db_item_size, total_size);    
+    let db_elem_size = params.item_size();
+    let total_size = params.num_items() * db_elem_size;
+    println!("Using a {} x {} byte database ({} bytes total)", params.num_items(), db_elem_size, total_size);    
 }
 
 fn main() {

+ 5 - 0
spiral-rs/src/params.rs

@@ -119,6 +119,11 @@ impl Params {
         (1 << self.db_dim_1) * (1 << self.db_dim_2)
     }
 
+    pub fn item_size(&self) -> usize {
+        let logp = log2(self.pt_modulus) as usize;
+        self.instances * self.n * self.n * self.poly_len * logp / 8
+    }
+
     pub fn g(&self) -> usize {
         let num_bits_to_gen = self.t_gsw * self.db_dim_2 + self.num_expanded();
         log2_ceil_usize(num_bits_to_gen)

+ 1 - 1
spiral-rs/src/util.rs

@@ -230,7 +230,7 @@ pub fn get_params_from_store(target_num_log2: usize, item_size: usize) -> Params
     let v: Value = serde_json::from_str(&params_store_str).unwrap();
     let nearest_target_num = target_num_log2;
     let nearest_item_size = 1 << usize::max(log2_ceil_usize(item_size), 8);
-    println!("{} x {}", nearest_target_num, nearest_item_size);
+    println!("Starting with parameters for 2^{} x {} bytes...", nearest_target_num, nearest_item_size);
     let target = v.as_array().unwrap().iter()
         .map(|x| x.as_object().unwrap() )
         .filter(|x| x.get("target_num").unwrap().as_u64().unwrap() == (nearest_target_num as u64))