19 #ifndef __AGPARAMS_H__
20 #define __AGPARAMS_H__
23 #include "recursiveparams.h"
30 typedef ZZ AG_Element;
32 #define AGELT_TO_ULONG(x) (to_ulong(x))
33 #define AGELT_TO_UINT64(x) ( \
34 (uint64_t)(to_ulong(x)&0xFFFFFFFFUL) + \
35 ((uint64_t)(to_ulong(x>>32)&0xFFFFFFFFUL)<<32) )
36 inline AG_Element UINT64_TO_AGELT(uint64_t x) {
37 unsigned long lo = ((
unsigned long)x)&0xFFFFFFFFUL;
38 unsigned long hi = (x>>32)&0xFFFFFFFFUL;
39 AG_Element r = to_ZZ(hi);
40 AG_Element loz = to_ZZ(lo);
45 inline void PERCY_WRITE_LE_AGELT(std::ostream &os,
const AG_Element &elt) {
46 unsigned char buf[16];
47 BytesFromZZ(buf, elt, 16);
48 os.write((
const char *)buf, 16);
50 inline void PERCY_READ_LE_AGELT(std::istream &is, AG_Element &elt) {
51 unsigned char buf[16];
52 is.read((
char *)buf, 16);
53 ZZFromBytes(elt, buf, 16);
55 #define ULONG_TO_AGELT(x) (to_ZZ(x))
58 typedef __uint128_t AG_Element;
60 #define AGELT_TO_ULONG(x) ((unsigned long)(x))
61 #define AGELT_TO_UINT64(x) ((uint64_t)(x))
62 #define UINT64_TO_AGELT(x) ((AG_Element)(x))
63 #define ULONG_TO_AGELT(x) ((AG_Element)(x))
64 inline void swap(AG_Element &a, AG_Element &b) {
69 #define PERCY_WRITE_LE_AGELT(os, elt) (os).write((char*)(&(elt)), 16)
70 #define PERCY_READ_LE_AGELT(is, elt) (is).read((char*)(&(elt)), 16)
81 dbsize_t N ()
const {
return _N; }
82 AG_Element p ()
const {
return _p; }
83 AG_Element q ()
const {
return _q; }
84 dbsize_t block_rows ()
const {
return _block_rows; }
94 virtual dbsize_t
request_size (nqueries_t num_queries = 1)
const;
95 virtual dbsize_t
response_size (nqueries_t num_queries = 1)
const;
103 std::vector<Dimension> worker_dims)
const;
107 virtual void write (std::ostream &os)
const;
116 dbsize_t _block_rows;
123 nqueries_t depth = 0, dbsize_t N = 50, dbsize_t
word_size = 20);
128 dbsize_t N ()
const {
return _N; }
138 void init_iterations (std::vector<dbsize_t> iteration_num_blocks);
dbsize_t word_size() const
Get the word size used to split blocks.
Definition: percyparams.h:110
Definition: recursiveparams.h:24
virtual void write(std::ostream &os) const
Write the parameters to a stream to check compatibility.
virtual void print_mode_specific(std::ostream &os) const
Print mode-specific parameters.
virtual std::vector< const PercyParams * > create_worker_params(std::vector< Dimension > worker_dims) const
Create protocol parameters for threads/workers.
dbsize_t virtual_block_size() const
Get the number of actual blocks in a virtual block when being used as one iteration of a recursive pr...
Definition: percyparams.h:123
dbsize_t num_blocks() const
Get the number of blocks in the database.
Definition: percyparams.h:102
virtual dbsize_t request_size(nqueries_t num_queries=1) const
Get the size of a client to server request.
virtual bool check_compatible(std::istream &is) const
Read the parameters from a stream (as written by write()) and check that they are compatible with the...
Definition: agparams.h:73
An abstract base class for a protocol's parameters.
Definition: percyparams.h:80
Definition: agparams.h:120
dbsize_t block_size() const
Get the size of each block in the database in bytes.
Definition: percyparams.h:104
virtual dbsize_t response_size(nqueries_t num_queries=1) const
Get the size of a server to client response.
Defines the basic structure of protocol parameters (PercyParams), client parameters (PercyClientParam...
virtual void print_mode_specific(std::ostream &os) const
Print mode-specific parameters.