Browse Source

moving sanity checks to ifdef HEAP_DEBUG

avadapal 1 year ago
parent
commit
1e65b4a3dc
3 changed files with 13 additions and 4 deletions
  1. 1 1
      duoram.hpp
  2. 8 3
      heap.cpp
  3. 4 0
      heap.hpp

+ 1 - 1
duoram.hpp

@@ -545,7 +545,7 @@ public:
    // The function unit_vector takes in an XOR-share of an index foundindx and a size
    // The function outputs _boolean shares_ of a standard-basis vector of size (with the non-zero index at foundindx)
    // For example suppose nitems = 6; and suppose P0 and P1 take parameters foundindx0 and foundindx1 such that, foundindx0 \oplus foundindx1 = 3
-   // P0 and P1 output vectors r0 and r1 such that r0 \oplus r1 = [001000]  
+   // P0 and P1 output vectors r0 and r1 such that r0 \oplus r1 = [000100] 
    std::vector<RegBS> unit_vector(MPCTIO &tio, yield_t &yield, size_t nitems, RegXS foundidx)
    {
       std::vector<RegBS> standard_basis(nitems); 

+ 8 - 3
heap.cpp

@@ -199,6 +199,7 @@ int MinHeap::insert(MPCTIO tio, yield_t & yield, RegAS val) {
 }
 
 
+#ifdef HEAP_DEBUG
 // Note: This function is intended for debugging purposes only.
 // The purpose of this function is to verify that the heap property is satisfied.
 // The function checks if the heap property holds for the given heap structure. It ensures that for each node in the heap, the value of the parent node is less than or equal to the values of its children.
@@ -236,6 +237,8 @@ void MinHeap::verify_heap_property(MPCTIO tio, yield_t & yield) {
 
 }
 
+#endif
+
 // Note: This function is intended for debugging purposes only.
 // The purpose of this function is to assert the fact that the reconstruction values of both the left child and right child are greater than or equal to the reconstruction value of the parent.
 // The function performs an assertion check to validate this condition. If the condition is not satisfied, an assertion error will be triggered.
@@ -722,13 +725,13 @@ void Heap(MPCIO & mpcio,  const PRACOptions & opts, char ** args, int argc) {
         tio.sync_lamport();
         mpcio.dump_stats(std::cout);
         
+        #ifdef HEAP_DEBUG
         if(run_sanity == 1 && n_inserts != 0) tree.verify_heap_property(tio, yield);
-         
+        #endif 
+        
         mpcio.reset_stats();
         tio.reset_lamport();
         
-
-        
         #ifdef HEAP_VERBOSE
         tree.print_heap(tio, yield);
         #endif
@@ -760,7 +763,9 @@ void Heap(MPCIO & mpcio,  const PRACOptions & opts, char ** args, int argc) {
         tree.print_heap(tio, yield);
         #endif
 
+        #ifdef HEAP_DEBUG
         if(run_sanity == 1 && n_extracts != 0) tree.verify_heap_property(tio, yield);
+        #endif
     }
     );
 }

+ 4 - 0
heap.hpp

@@ -25,7 +25,11 @@ class MinHeap {
     void init(MPCTIO tio, yield_t & yield, size_t which_init);
     int insert(MPCTIO tio, yield_t & yield, RegAS val);
     void insert_optimized(MPCTIO tio, yield_t & yield, RegAS val);
+    
+    #ifdef HEAP_DEBUG
     void verify_heap_property(MPCTIO tio, yield_t & yield);
+    #endif
+    
     RegXS restore_heap_property(MPCIO &mpcio, MPCTIO tio, yield_t & yield, RegXS index);
     std::pair<RegXS, RegBS> restore_heap_property_optimized(MPCTIO tio, yield_t & yield, RegXS index, size_t depth, size_t layer, typename Duoram<RegAS>::template OblivIndex<RegXS,3> oidx);
     std::pair<RegXS, RegBS> restore_heap_property_at_explicit_index(MPCTIO tio, yield_t & yield,  size_t index);