Browse Source

Swap the halves of the item index in load_db_from_slice_mt so that the polynomials based on the items are written to the AlignedMemoryMT64 more sequentially

Ian Goldberg 1 year ago
parent
commit
101d09589e
1 changed files with 8 additions and 3 deletions
  1. 8 3
      src/spiral_mt.rs

+ 8 - 3
src/spiral_mt.rs

@@ -73,11 +73,16 @@ pub fn load_db_from_slice_mt(
                     s.spawn(move |_| {
                         let vptr = unsafe { v.as_mut_ptr() };
                         for i in item_thread_start..item_thread_end {
-                            let ii = i % num_per;
-                            let j = i / num_per;
+                            // Swap the halves of the item index so that
+                            // the polynomials based on the items are
+                            // written to the AlignedMemoryMT64 more
+                            // sequentially
+                            let ii = i / dim0;
+                            let j = i % dim0;
+                            let db_idx = j * num_per + ii;
 
                             let mut db_item =
-                                load_item_from_slice(&params, slice, instance, trial, i);
+                                load_item_from_slice(&params, slice, instance, trial, db_idx);
                             // db_item.reduce_mod(params.pt_modulus);
 
                             for z in 0..params.poly_len {