Bläddra i källkod

A little more templatization

Ian Goldberg 1 år sedan
förälder
incheckning
2c32812a93
3 ändrade filer med 19 tillägg och 4 borttagningar
  1. 4 4
      duoram.tcc
  2. 3 0
      rdpf.hpp
  3. 12 0
      rdpf.tcc

+ 4 - 4
duoram.tcc

@@ -286,7 +286,7 @@ Duoram<T>::Shape::MemRefAS::operator T()
         RDPFTriple dt = shape.tio.rdpftriple(shape.yield, shape.addr_size);
 
         // Compute the index offset
-        RegAS indoffset = dt.as_target;
+        RegAS indoffset = dt.target<RegAS>();
         indoffset -= idx;
 
         // We only need two of the DPFs for reading
@@ -385,7 +385,7 @@ typename Duoram<T>::Shape::MemRefAS
         RDPFTriple dt = shape.tio.rdpftriple(shape.yield, shape.addr_size);
 
         // Compute the index and message offsets
-        RegAS indoffset = dt.as_target;
+        RegAS indoffset = dt.target<RegAS>();
         indoffset -= idx;
         auto Moffset = std::make_tuple(M, M, M);
         Moffset -= dt.scaled_value<T>();
@@ -518,7 +518,7 @@ Duoram<T>::Shape::MemRefXS::operator T()
         RDPFTriple dt = shape.tio.rdpftriple(shape.yield, shape.addr_size);
 
         // Compute the index offset
-        RegXS indoffset = dt.xs_target;
+        RegXS indoffset = dt.target<RegXS>();
         indoffset -= idx;
 
         // We only need two of the DPFs for reading
@@ -615,7 +615,7 @@ typename Duoram<T>::Shape::MemRefXS
         RDPFTriple dt = shape.tio.rdpftriple(shape.yield, shape.addr_size);
 
         // Compute the index and message offsets
-        RegXS indoffset = dt.xs_target;
+        RegXS indoffset = dt.target<RegXS>();
         indoffset -= idx;
         auto Moffset = std::make_tuple(M, M, M);
         Moffset -= dt.scaled_value<T>();

+ 3 - 0
rdpf.hpp

@@ -152,6 +152,9 @@ struct RDPFTriple {
     // so that the appropriate one can be selected with a template
     // parameter
 
+    template <typename T>
+    inline T target() const;
+
     template <typename T>
     inline std::tuple<T,T,T> scaled_value() const;
 

+ 12 - 0
rdpf.tcc

@@ -165,6 +165,18 @@ inline V ParallelEval<T>::reduce(V init, W process, X accumulate)
     return total;
 }
 
+// Additive share of the target index
+template <>
+inline RegAS RDPFTriple::target<RegAS>() const {
+    return as_target;
+}
+
+// XOR share of the target index
+template <>
+inline RegXS RDPFTriple::target<RegXS>() const {
+    return xs_target;
+}
+
 // Additive share of the scaling value M_as such that the high words
 // of the leaf values for P0 and P1 add to M_as * e_{target}
 template <>