Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
PALISADE
PALISADE Development
Commits
806fa56b
Commit
806fa56b
authored
Jan 24, 2018
by
Jerry Ryan
Browse files
removed redundant items. all benchmarks compile and run
parent
60779a7f
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
142 additions
and
1078 deletions
+142
-1078
Makefile.common
Makefile.common
+1
-1
benchmark/src/Crypto.cpp
benchmark/src/Crypto.cpp
+16
-51
benchmark/src/ElementParmsHelper.h
benchmark/src/ElementParmsHelper.h
+11
-11
benchmark/src/Encoding.cpp
benchmark/src/Encoding.cpp
+47
-84
benchmark/src/EncryptHelper.h
benchmark/src/EncryptHelper.h
+7
-3
benchmark/src/Lattice.cpp
benchmark/src/Lattice.cpp
+28
-5
benchmark/src/LatticeCompare.cpp
benchmark/src/LatticeCompare.cpp
+0
-169
benchmark/src/LatticeNative.cpp
benchmark/src/LatticeNative.cpp
+0
-204
benchmark/src/SHE.cpp
benchmark/src/SHE.cpp
+28
-18
benchmark/src/Source_presim_bm.cpp
benchmark/src/Source_presim_bm.cpp
+0
-528
src/core/lib/lattice/elemparamfactory.h
src/core/lib/lattice/elemparamfactory.h
+2
-2
src/core/unittest/UnitTestSerialize.cpp
src/core/unittest/UnitTestSerialize.cpp
+2
-2
No files found.
Makefile.common
View file @
806fa56b
...
...
@@ -113,7 +113,7 @@ PALISADEPYLIB := pycrypto$(LIBSUFFIX)
all
:
$(MAKE)
gmp_all
$(MAKE)
ntl_all
$(MAKE)
allcore allpke alltrapdoor allcircuit utall
benchmark
$(MAKE)
allcore allpke alltrapdoor allcircuit utall
docs
:
apidocs
...
...
benchmark/src/Crypto.cpp
View file @
806fa56b
...
...
@@ -60,29 +60,24 @@ void BM_keygen(benchmark::State& state) { // benchmark
CryptoContext
<
Poly
>
cc
;
if
(
state
.
thread_index
==
0
)
{
state
.
PauseTiming
();
try
{
cc
=
CryptoContextHelper
::
getNewContext
(
parms
[
state
.
range
(
0
)]);
cc
->
Enable
(
ENCRYPTION
);
cc
->
Enable
(
PRE
);
}
catch
(
...
)
{
state
.
SkipWithError
(
"Unable to make context"
);
}
catch
(
std
::
exception
&
e
)
{
state
.
SkipWithError
(
e
.
what
()
);
return
;
}
try
{
ChineseRemainderTransformFTT
<
BigInteger
,
BigVector
>::
PreCompute
(
cc
->
GetRootOfUnity
(),
cc
->
GetCyclotomicOrder
(),
cc
->
GetModulus
());
cc
->
GetCyclotomicOrder
(),
cc
->
GetModulus
());
}
catch
(
...
)
{}
state
.
ResumeTiming
();
}
while
(
state
.
KeepRunning
())
{
//try {
LPKeyPair
<
Poly
>
kp
=
cc
->
KeyGen
();
//} catch( ... ) {}
LPKeyPair
<
Poly
>
kp
=
cc
->
KeyGen
();
}
}
...
...
@@ -101,13 +96,12 @@ void BM_encrypt(benchmark::State& state) { // benchmark
Plaintext
plaintext
;
if
(
state
.
thread_index
==
0
)
{
state
.
PauseTiming
();
try
{
cc
=
CryptoContextHelper
::
getNewContext
(
parms
[
state
.
range
(
0
)]);
cc
->
Enable
(
ENCRYPTION
);
cc
->
Enable
(
PRE
);
}
catch
(
...
)
{
state
.
ResumeTiming
(
);
}
catch
(
std
::
exception
&
e
)
{
state
.
SkipWithError
(
e
.
what
()
);
return
;
}
...
...
@@ -117,17 +111,9 @@ void BM_encrypt(benchmark::State& state) { // benchmark
cc
->
GetModulus
());
}
catch
(
...
)
{}
size_t
strSize
=
cc
->
GetRingDimension
();
if
(
strSize
==
0
)
{
state
.
SkipWithError
(
"Chunk size is 0"
);
}
vector
<
int64_t
>
input
(
strSize
,
0
);
vector
<
int64_t
>
input
(
cc
->
GetRingDimension
(),
0
);
fillrandint
(
input
,
cc
->
GetEncodingParams
()
->
GetPlaintextModulus
());
plaintext
=
cc
->
MakeCoefPackedPlaintext
(
input
);
state
.
ResumeTiming
();
}
while
(
state
.
KeepRunning
())
{
...
...
@@ -149,13 +135,12 @@ void BM_decrypt(benchmark::State& state) { // benchmark
Plaintext
plaintextNew
;
if
(
state
.
thread_index
==
0
)
{
state
.
PauseTiming
();
try
{
cc
=
CryptoContextHelper
::
getNewContext
(
parms
[
state
.
range
(
0
)]);
cc
->
Enable
(
ENCRYPTION
);
cc
->
Enable
(
PRE
);
}
catch
(
...
)
{
state
.
ResumeTiming
(
);
}
catch
(
std
::
exception
&
e
)
{
state
.
SkipWithError
(
e
.
what
()
);
return
;
}
...
...
@@ -165,17 +150,9 @@ void BM_decrypt(benchmark::State& state) { // benchmark
cc
->
GetModulus
());
}
catch
(
...
)
{}
size_t
strSize
=
cc
->
GetRingDimension
();
if
(
strSize
==
0
)
{
state
.
SkipWithError
(
"Chunk size is 0"
);
}
vector
<
int64_t
>
input
(
strSize
,
0
);
vector
<
int64_t
>
input
(
cc
->
GetRingDimension
(),
0
);
fillrandint
(
input
,
cc
->
GetEncodingParams
()
->
GetPlaintextModulus
());
plaintext
=
cc
->
MakeCoefPackedPlaintext
(
input
);
state
.
ResumeTiming
();
}
while
(
state
.
KeepRunning
())
{
...
...
@@ -195,14 +172,13 @@ void BM_rekeygen(benchmark::State& state) { // benchmark
LPKeyPair
<
Poly
>
kp
;
if
(
state
.
thread_index
==
0
)
{
state
.
PauseTiming
();
try
{
cc
=
CryptoContextHelper
::
getNewContext
(
parms
[
state
.
range
(
0
)]);
cc
->
Enable
(
ENCRYPTION
);
cc
->
Enable
(
PRE
);
cc
->
Enable
(
SHE
);
}
catch
(
...
)
{
state
.
ResumeTiming
(
);
}
catch
(
std
::
exception
&
e
)
{
state
.
SkipWithError
(
e
.
what
()
);
return
;
}
...
...
@@ -212,8 +188,6 @@ void BM_rekeygen(benchmark::State& state) { // benchmark
cc
->
GetModulus
());
}
catch
(
...
)
{
}
state
.
ResumeTiming
();
}
while
(
state
.
KeepRunning
())
{
...
...
@@ -243,13 +217,12 @@ void BM_reencrypt(benchmark::State& state) { // benchmark
Plaintext
plaintextNew
;
if
(
state
.
thread_index
==
0
)
{
state
.
PauseTiming
();
try
{
cc
=
CryptoContextHelper
::
getNewContext
(
parms
[
state
.
range
(
0
)]);
cc
->
Enable
(
ENCRYPTION
);
cc
->
Enable
(
PRE
);
}
catch
(
...
)
{
state
.
ResumeTiming
(
);
}
catch
(
std
::
exception
&
e
)
{
state
.
SkipWithError
(
e
.
what
()
);
return
;
}
...
...
@@ -259,17 +232,9 @@ void BM_reencrypt(benchmark::State& state) { // benchmark
cc
->
GetModulus
());
}
catch
(
...
)
{}
size_t
strSize
=
cc
->
GetRingDimension
();
if
(
strSize
==
0
)
{
state
.
SkipWithError
(
"Chunk size is 0"
);
}
vector
<
int64_t
>
input
(
strSize
,
0
);
vector
<
int64_t
>
input
(
cc
->
GetRingDimension
(),
0
);
fillrandint
(
input
,
cc
->
GetEncodingParams
()
->
GetPlaintextModulus
());
plaintext
=
cc
->
MakeCoefPackedPlaintext
(
input
);
state
.
ResumeTiming
();
}
LPEvalKey
<
Poly
>
evalKey
;
...
...
benchmark/src/ElementParmsHelper.h
View file @
806fa56b
...
...
@@ -25,13 +25,13 @@
#include "lattice/elemparamfactory.h"
shared_ptr
<
ILParams
>
parm_16
=
ElemParamFactory
::
GenElemParams
<
ILParams
,
BigInteger
>
(
M16
);
shared_ptr
<
ILParams
>
parm_1024
=
ElemParamFactory
::
GenElemParams
<
ILParams
,
BigInteger
>
(
M1024
);
shared_ptr
<
ILParams
>
parm_2048
=
ElemParamFactory
::
GenElemParams
<
ILParams
,
BigInteger
>
(
M2048
);
shared_ptr
<
ILParams
>
parm_4096
=
ElemParamFactory
::
GenElemParams
<
ILParams
,
BigInteger
>
(
M4096
);
shared_ptr
<
ILParams
>
parm_8192
=
ElemParamFactory
::
GenElemParams
<
ILParams
,
BigInteger
>
(
M8192
);
shared_ptr
<
ILParams
>
parm_16384
=
ElemParamFactory
::
GenElemParams
<
ILParams
,
BigInteger
>
(
M16384
);
shared_ptr
<
ILParams
>
parm_32768
=
ElemParamFactory
::
GenElemParams
<
ILParams
,
BigInteger
>
(
M32768
);
shared_ptr
<
ILParams
>
parm_16
=
ElemParamFactory
::
GenElemParams
<
ILParams
>
(
M16
);
shared_ptr
<
ILParams
>
parm_1024
=
ElemParamFactory
::
GenElemParams
<
ILParams
>
(
M1024
);
shared_ptr
<
ILParams
>
parm_2048
=
ElemParamFactory
::
GenElemParams
<
ILParams
>
(
M2048
);
shared_ptr
<
ILParams
>
parm_4096
=
ElemParamFactory
::
GenElemParams
<
ILParams
>
(
M4096
);
shared_ptr
<
ILParams
>
parm_8192
=
ElemParamFactory
::
GenElemParams
<
ILParams
>
(
M8192
);
shared_ptr
<
ILParams
>
parm_16384
=
ElemParamFactory
::
GenElemParams
<
ILParams
>
(
M16384
);
shared_ptr
<
ILParams
>
parm_32768
=
ElemParamFactory
::
GenElemParams
<
ILParams
>
(
M32768
);
shared_ptr
<
ILParams
>
parmArray
[]
=
{
parm_16
,
...
...
@@ -43,10 +43,10 @@ parm_16384,
parm_32768
,
};
shared_ptr
<
ILNativeParams
>
nparm_16
=
ElemParamFactory
::
GenElemParams
<
ILNativeParams
,
NativeInteger
>
(
M16
);
shared_ptr
<
ILNativeParams
>
nparm_1024
=
ElemParamFactory
::
GenElemParams
<
ILNativeParams
,
NativeInteger
>
(
M1024
);
shared_ptr
<
ILNativeParams
>
nparm_2048
=
ElemParamFactory
::
GenElemParams
<
ILNativeParams
,
NativeInteger
>
(
M2048
);
shared_ptr
<
ILNativeParams
>
nparm_4096
=
ElemParamFactory
::
GenElemParams
<
ILNativeParams
,
NativeInteger
>
(
M4096
);
shared_ptr
<
ILNativeParams
>
nparm_16
=
ElemParamFactory
::
GenElemParams
<
ILNativeParams
>
(
M16
);
shared_ptr
<
ILNativeParams
>
nparm_1024
=
ElemParamFactory
::
GenElemParams
<
ILNativeParams
>
(
M1024
);
shared_ptr
<
ILNativeParams
>
nparm_2048
=
ElemParamFactory
::
GenElemParams
<
ILNativeParams
>
(
M2048
);
shared_ptr
<
ILNativeParams
>
nparm_4096
=
ElemParamFactory
::
GenElemParams
<
ILNativeParams
>
(
M4096
);
shared_ptr
<
ILNativeParams
>
nparmArray
[]
=
{
nparm_16
,
...
...
benchmark/src/Encoding.cpp
View file @
806fa56b
...
...
@@ -41,22 +41,15 @@ using namespace std;
using
namespace
lbcrypto
;
void
BM_encoding_Scalar
(
benchmark
::
State
&
state
)
{
usint
m
=
1024
;
PlaintextModulus
ptm
=
128
;
int64_t
value
=
47
;
Plaintext
plaintext
;
if
(
state
.
thread_index
==
0
)
{
state
.
PauseTiming
();
int64_t
value
=
47
;
usint
m
=
1024
;
PlaintextModulus
ptm
=
128
;
shared_ptr
<
ILParams
>
lp
=
ElemParamFactory
::
GenElemParams
<
ILParams
>
(
m
);
EncodingParams
ep
(
new
EncodingParamsImpl
(
ptm
)
);
plaintext
.
reset
(
new
ScalarEncoding
(
lp
,
ep
,
value
)
);
state
.
ResumeTiming
();
}
shared_ptr
<
ILParams
>
lp
=
ElemParamFactory
::
GenElemParams
<
ILParams
>
(
m
);
EncodingParams
ep
(
new
EncodingParamsImpl
(
ptm
)
);
while
(
state
.
KeepRunning
())
{
plaintext
.
reset
(
new
ScalarEncoding
(
lp
,
ep
,
value
)
);
plaintext
->
Encode
();
}
}
...
...
@@ -65,23 +58,16 @@ BENCHMARK(BM_encoding_Scalar);
void
BM_encoding_Integer
(
benchmark
::
State
&
state
)
{
// benchmark
CryptoContext
<
Poly
>
cc
;
Plaintext
plaintext
;
usint
m
=
1024
;
PlaintextModulus
ptm
=
128
;
int64_t
mv
=
58
;
if
(
state
.
thread_index
==
0
)
{
state
.
PauseTiming
();
usint
m
=
1024
;
PlaintextModulus
ptm
=
128
;
int64_t
mv
=
58
;
shared_ptr
<
ILParams
>
lp
=
ElemParamFactory
::
GenElemParams
<
ILParams
>
(
m
);
EncodingParams
ep
(
new
EncodingParamsImpl
(
ptm
)
);
plaintext
.
reset
(
new
IntegerEncoding
(
lp
,
ep
,
mv
)
);
state
.
ResumeTiming
();
}
shared_ptr
<
ILParams
>
lp
=
ElemParamFactory
::
GenElemParams
<
ILParams
>
(
m
);
EncodingParams
ep
(
new
EncodingParamsImpl
(
ptm
)
);
while
(
state
.
KeepRunning
())
{
plaintext
.
reset
(
new
IntegerEncoding
(
lp
,
ep
,
mv
)
);
plaintext
->
Encode
();
}
}
...
...
@@ -90,26 +76,19 @@ BENCHMARK(BM_encoding_Integer);
void
BM_encoding_CoefPacked
(
benchmark
::
State
&
state
)
{
Plaintext
plaintext
;
usint
m
=
1024
;
PlaintextModulus
ptm
=
128
;
PlaintextModulus
half
=
ptm
/
2
;
if
(
state
.
thread_index
==
0
)
{
state
.
PauseTiming
();
usint
m
=
1024
;
PlaintextModulus
ptm
=
128
;
PlaintextModulus
half
=
ptm
/
2
;
shared_ptr
<
ILParams
>
lp
=
ElemParamFactory
::
GenElemParams
<
ILParams
>
(
m
);
EncodingParams
ep
(
new
EncodingParamsImpl
(
ptm
)
);
shared_ptr
<
ILParams
>
lp
=
ElemParamFactory
::
GenElemParams
<
ILParams
>
(
m
);
EncodingParams
ep
(
new
EncodingParamsImpl
(
ptm
)
);
vector
<
int64_t
>
intvec
;
for
(
usint
ii
=
0
;
ii
<
m
/
2
;
ii
++
)
intvec
.
push_back
(
rand
()
%
half
);
plaintext
.
reset
(
new
CoefPackedEncoding
(
lp
,
ep
,
intvec
)
);
state
.
ResumeTiming
();
}
vector
<
int64_t
>
intvec
;
for
(
usint
ii
=
0
;
ii
<
m
/
2
;
ii
++
)
intvec
.
push_back
(
rand
()
%
half
);
while
(
state
.
KeepRunning
())
{
plaintext
.
reset
(
new
CoefPackedEncoding
(
lp
,
ep
,
intvec
)
);
plaintext
->
Encode
();
}
}
...
...
@@ -123,29 +102,22 @@ void BM_encoding_PackedIntPlaintext(benchmark::State& state) {
std
::
vector
<
uint64_t
>
vectorOfInts1
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
0
,
0
};
if
(
state
.
thread_index
==
0
)
{
state
.
PauseTiming
();
usint
m
=
22
;
PlaintextModulus
p
=
89
;
BigInteger
modulusP
(
p
);
BigInteger
modulusQ
(
"955263939794561"
);
BigInteger
squareRootOfRoot
(
"941018665059848"
);
BigInteger
bigmodulus
(
"80899135611688102162227204937217"
);
BigInteger
bigroot
(
"77936753846653065954043047918387"
);
usint
m
=
22
;
PlaintextModulus
p
=
89
;
BigInteger
modulusP
(
p
);
BigInteger
modulusQ
(
"955263939794561"
);
BigInteger
squareRootOfRoot
(
"941018665059848"
);
BigInteger
bigmodulus
(
"80899135611688102162227204937217"
);
BigInteger
bigroot
(
"77936753846653065954043047918387"
);
auto
cycloPoly
=
GetCyclotomicPolynomial
<
BigVector
,
BigInteger
>
(
m
,
modulusQ
);
ChineseRemainderTransformArb
<
BigInteger
,
BigVector
>::
SetCylotomicPolynomial
(
cycloPoly
,
modulusQ
);
auto
cycloPoly
=
GetCyclotomicPolynomial
<
BigVector
,
BigInteger
>
(
m
,
modulusQ
);
ChineseRemainderTransformArb
<
BigInteger
,
BigVector
>::
SetCylotomicPolynomial
(
cycloPoly
,
modulusQ
);
lp
.
reset
(
new
ILParams
(
m
,
modulusQ
,
squareRootOfRoot
,
bigmodulus
,
bigroot
));
ep
.
reset
(
new
EncodingParamsImpl
(
p
,
8
));
state
.
ResumeTiming
();
}
lp
.
reset
(
new
ILParams
(
m
,
modulusQ
,
squareRootOfRoot
,
bigmodulus
,
bigroot
));
ep
.
reset
(
new
EncodingParamsImpl
(
p
,
8
));
while
(
state
.
KeepRunning
())
{
state
.
PauseTiming
();
plaintext
.
reset
(
new
PackedEncoding
(
lp
,
ep
,
vectorOfInts1
)
);
state
.
ResumeTiming
();
plaintext
->
Encode
();
}
...
...
@@ -165,8 +137,6 @@ void BM_encoding_PackedIntPlaintext_SetParams(benchmark::State& state) {
std
::
vector
<
uint64_t
>
vectorOfInts1
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
0
,
0
};
if
(
state
.
thread_index
==
0
)
{
state
.
PauseTiming
();
BigInteger
modulusQ
(
"955263939794561"
);
BigInteger
squareRootOfRoot
(
"941018665059848"
);
BigInteger
bigmodulus
(
"80899135611688102162227204937217"
);
...
...
@@ -178,12 +148,10 @@ void BM_encoding_PackedIntPlaintext_SetParams(benchmark::State& state) {
lp
.
reset
(
new
ILParams
(
m
,
modulusQ
,
squareRootOfRoot
,
bigmodulus
,
bigroot
));
ep
.
reset
(
new
EncodingParamsImpl
(
p
,
8
));
state
.
ResumeTiming
();
}
while
(
state
.
KeepRunning
())
{
PackedEncoding
::
SetParams
(
m
,
p
);
state
.
PauseTiming
();
PackedEncoding
::
Destroy
();
state
.
ResumeTiming
();
...
...
@@ -197,31 +165,26 @@ void BM_Encoding_String(benchmark::State& state) { // benchmark
CryptoContext
<
Poly
>
cc
;
Plaintext
plaintext
;
if
(
state
.
thread_index
==
0
)
{
state
.
PauseTiming
()
;
usint
m
=
1024
;
PlaintextModulus
ptm
=
256
;
usint
m
=
1024
;
PlaintextModulus
ptm
=
256
;
shared_ptr
<
ILParams
>
lp
=
ElemParamFactory
::
GenElemParams
<
ILParams
>
(
m
)
;
EncodingParams
ep
(
new
EncodingParamsImpl
(
ptm
)
)
;
shared_ptr
<
ILParams
>
lp
=
ElemParamFactory
::
GenElemParams
<
ILParams
>
(
m
);
EncodingParams
ep
(
new
EncodingParamsImpl
(
ptm
)
);
auto
randchar
=
[]()
->
char
{
const
char
charset
[]
=
"0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
;
const
size_t
max_index
=
(
sizeof
(
charset
)
-
1
);
return
charset
[
rand
()
%
max_index
];
};
auto
randchar
=
[]()
->
char
{
const
char
charset
[]
=
"0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
;
const
size_t
max_index
=
(
sizeof
(
charset
)
-
1
);
return
charset
[
rand
()
%
max_index
];
};
string
fullStr
(
m
/
2
,
0
);
std
::
generate_n
(
fullStr
.
begin
(),
m
/
2
,
randchar
);
plaintext
.
reset
(
new
StringEncoding
(
lp
,
ep
,
fullStr
)
);
state
.
ResumeTiming
();
}
string
fullStr
(
m
/
2
,
0
);
std
::
generate_n
(
fullStr
.
begin
(),
m
/
2
,
randchar
);
while
(
state
.
KeepRunning
())
{
plaintext
.
reset
(
new
StringEncoding
(
lp
,
ep
,
fullStr
)
);
plaintext
->
Encode
();
}
}
...
...
benchmark/src/EncryptHelper.h
View file @
806fa56b
...
...
@@ -44,7 +44,7 @@ public:
for
(
auto
p
:
lbcrypto
::
CryptoContextParameterSets
)
parms
.
push_back
(
p
.
first
);
if
(
parms
.
size
()
!=
2
5
)
if
(
parms
.
size
()
!=
2
7
)
cout
<<
"WARNING: fix macros in EncryptHelper.h, size should be "
<<
parms
.
size
()
<<
endl
;
}
};
...
...
@@ -76,7 +76,9 @@ BENCHMARK(X)->ArgName(parms[20])->Arg(20); \
BENCHMARK(X)->ArgName(parms[21])->Arg(21); \
BENCHMARK(X)->ArgName(parms[22])->Arg(22); \
BENCHMARK(X)->ArgName(parms[23])->Arg(23); \
BENCHMARK(X)->ArgName(parms[24])->Arg(24);
BENCHMARK(X)->ArgName(parms[24])->Arg(24); \
BENCHMARK(X)->ArgName(parms[25])->Arg(25); \
BENCHMARK(X)->ArgName(parms[26])->Arg(26);
#define BENCHMARK_PARMS_TEMPLATE(X,Y) \
BENCHMARK_TEMPLATE(X,Y)->ArgName(parms[0])->Arg(0); \
...
...
@@ -103,7 +105,9 @@ BENCHMARK(X)->ArgName(parms[24])->Arg(24);
BENCHMARK_TEMPLATE(X,Y)->ArgName(parms[21])->Arg(21); \
BENCHMARK_TEMPLATE(X,Y)->ArgName(parms[22])->Arg(22); \
BENCHMARK_TEMPLATE(X,Y)->ArgName(parms[23])->Arg(23); \
BENCHMARK_TEMPLATE(X,Y)->ArgName(parms[24])->Arg(24);
BENCHMARK_TEMPLATE(X,Y)->ArgName(parms[24])->Arg(24); \
BENCHMARK_TEMPLATE(X,Y)->ArgName(parms[25])->Arg(25); \
BENCHMARK_TEMPLATE(X,Y)->ArgName(parms[26])->Arg(26);
#endif
/* BENCHMARK_SRC_ENCRYPTHELPER_H_ */
benchmark/src/Lattice.cpp
View file @
806fa56b
...
...
@@ -88,15 +88,17 @@ static vector<usint> o( { 16, 1024, 2048, 4096, 8192, 16384, 32768 } );
template
<
typename
P
>
static
void
GenerateParms
(
map
<
usint
,
shared_ptr
<
P
>>&
parmArray
)
{
for
(
usint
v
:
o
)
{
parmArray
[
v
]
=
ElemParamFactory
::
GenElemParams
<
P
>
(
v
);
try
{
parmArray
[
v
]
=
ElemParamFactory
::
GenElemParams
<
P
>
(
v
);
}
catch
(
...
)
{
break
;
}
}
}
template
<
typename
P
>
static
void
GenerateDCRTParms
(
map
<
usint
,
shared_ptr
<
P
>>&
parmArray
)
{
for
(
usint
v
:
o
)
{
parmArray
[
v
]
=
ElemParamFactory
::
GenElemParams
<
P
>
(
v
,
28
,
5
);
}
...
...
@@ -104,9 +106,9 @@ static void GenerateDCRTParms(map<usint,shared_ptr<P>>& parmArray) {
template
<
typename
P
,
typename
E
>
static
void
GeneratePolys
(
map
<
usint
,
shared_ptr
<
P
>>&
parmArray
,
map
<
usint
,
vector
<
E
>>&
polyArray
)
{
for
(
usint
v
:
o
)
{
for
(
auto
&
pair
:
parmArray
)
{
for
(
int
i
=
0
;
i
<
2
;
i
++
)
polyArray
[
v
].
push_back
(
makeElement
<
E
>
(
parmArray
[
v
])
);
polyArray
[
pair
.
first
].
push_back
(
makeElement
<
E
>
(
parmArray
[
pair
.
first
])
);
}
}
...
...
@@ -205,12 +207,14 @@ PolyImpl<BE6Integer, BE6Integer, BE6Vector, BE6ILParams>::DecryptionCRTInterpola
}
#endif
map
<
usint
,
shared_ptr
<
ILNativeParams
>>
Nativeparms
;
map
<
usint
,
shared_ptr
<
BE2ILParams
>>
BE2parms
;
map
<
usint
,
shared_ptr
<
BE2ILDCRTParams
>>
BE2dcrtparms
;
map
<
usint
,
shared_ptr
<
BE4ILParams
>>
BE4parms
;
map
<
usint
,
shared_ptr
<
BE4ILDCRTParams
>>
BE4dcrtparms
;
map
<
usint
,
shared_ptr
<
BE6ILParams
>>
BE6parms
;
map
<
usint
,
shared_ptr
<
BE6ILDCRTParams
>>
BE6dcrtparms
;
map
<
usint
,
vector
<
NativePoly
>>
Nativepolys
;
map
<
usint
,
vector
<
BE2Poly
>>
BE2polys
;
map
<
usint
,
vector
<
BE2DCRTPoly
>>
BE2DCRTpolys
;
map
<
usint
,
vector
<
BE4Poly
>>
BE4polys
;
...
...
@@ -221,12 +225,14 @@ map<usint,vector<BE6DCRTPoly>> BE6DCRTpolys;
class
Setup
{
public:
Setup
()
{
GenerateParms
<
ILNativeParams
>
(
Nativeparms
);
GenerateParms
<
BE2ILParams
>
(
BE2parms
);
GenerateDCRTParms
<
BE2ILDCRTParams
>
(
BE2dcrtparms
);
GenerateParms
<
BE4ILParams
>
(
BE4parms
);
GenerateDCRTParms
<
BE4ILDCRTParams
>
(
BE4dcrtparms
);
GenerateParms
<
BE6ILParams
>
(
BE6parms
);
GenerateDCRTParms
<
BE6ILDCRTParams
>
(
BE6dcrtparms
);
GeneratePolys
<
ILNativeParams
,
NativePoly
>
(
Nativeparms
,
Nativepolys
);
GeneratePolys
<
BE2ILParams
,
BE2Poly
>
(
BE2parms
,
BE2polys
);
GeneratePolys
<
BE4ILParams
,
BE4Poly
>
(
BE4parms
,
BE4polys
);
GeneratePolys
<
BE6ILParams
,
BE6Poly
>
(
BE6parms
,
BE6polys
);
...
...
@@ -242,6 +248,9 @@ public:
const
E
&
GetPoly
(
usint
o
,
int
p
);
}
TestParameters
;
template
<
>
shared_ptr
<
ILNativeParams
>
Setup
::
GetParm
(
usint
o
)
{
return
Nativeparms
[
o
];
}
template
<
>
shared_ptr
<
BE2ILParams
>
Setup
::
GetParm
(
usint
o
)
{
return
BE2parms
[
o
];
}
...
...
@@ -260,6 +269,7 @@ shared_ptr<BE6ILParams> Setup::GetParm(usint o) { return BE6parms[o]; }
template
<
>
shared_ptr
<
BE6ILDCRTParams
>
Setup
::
GetParm
(
usint
o
)
{
return
BE6dcrtparms
[
o
];
}
template
<
>
const
NativePoly
&
Setup
::
GetPoly
(
usint
o
,
int
p
)
{
return
Nativepolys
[
o
][
p
];
}
template
<
>
const
BE2Poly
&
Setup
::
GetPoly
(
usint
o
,
int
p
)
{
return
BE2polys
[
o
][
p
];
}
template
<
>
const
BE4Poly
&
Setup
::
GetPoly
(
usint
o
,
int
p
)
{
return
BE4polys
[
o
][
p
];
}
template
<
>
const
BE6Poly
&
Setup
::
GetPoly
(
usint
o
,
int
p
)
{
return
BE6polys
[
o
][
p
];
}
...
...
@@ -267,6 +277,11 @@ template<> const BE2DCRTPoly& Setup::GetPoly(usint o, int p) { return BE2DCRTpol
template
<
>
const
BE4DCRTPoly
&
Setup
::
GetPoly
(
usint
o
,
int
p
)
{
return
BE4DCRTpolys
[
o
][
p
];
}
template
<
>
const
BE6DCRTPoly
&
Setup
::
GetPoly
(
usint
o
,
int
p
)
{
return
BE6DCRTpolys
[
o
][
p
];
}
#define DO_NATIVEPOLY_BENCHMARK(X) \
BENCHMARK_TEMPLATE(X,NativePoly)->Unit(benchmark::kMicrosecond)->ArgName("parm_16")->Arg(16); \
BENCHMARK_TEMPLATE(X,NativePoly)->Unit(benchmark::kMicrosecond)->ArgName("parm_1024")->Arg(1024); \
BENCHMARK_TEMPLATE(X,NativePoly)->Unit(benchmark::kMicrosecond)->ArgName("parm_2048")->Arg(2048);
#define DO_POLY_BENCHMARK_TEMPLATE(X,Y) \
BENCHMARK_TEMPLATE(X,Y)->Unit(benchmark::kMicrosecond)->ArgName("parm_16")->Arg(16); \
BENCHMARK_TEMPLATE(X,Y)->Unit(benchmark::kMicrosecond)->ArgName("parm_1024")->Arg(1024); \
...
...
@@ -293,6 +308,7 @@ void BM_LATTICE_empty(benchmark::State& state) { // benchmark
}
}
DO_NATIVEPOLY_BENCHMARK
(
BM_LATTICE_empty
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_LATTICE_empty
,
BE2Poly
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_LATTICE_empty
,
BE4Poly
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_LATTICE_empty
,
BE6Poly
)
...
...
@@ -316,6 +332,7 @@ void BM_LATTICE_makevector(benchmark::State& state) { // benchmark
}
}
DO_NATIVEPOLY_BENCHMARK
(
BM_LATTICE_makevector
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_LATTICE_makevector
,
BE2Poly
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_LATTICE_makevector
,
BE4Poly
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_LATTICE_makevector
,
BE6Poly
)
...
...
@@ -346,6 +363,7 @@ static void BM_add_LATTICE(benchmark::State& state) { // benchmark
}
}
DO_NATIVEPOLY_BENCHMARK
(
BM_add_LATTICE
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_add_LATTICE
,
BE2Poly
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_add_LATTICE
,
BE4Poly
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_add_LATTICE
,
BE6Poly
)
...
...
@@ -375,6 +393,7 @@ static void BM_addeq_LATTICE(benchmark::State& state) { // benchmark
}
}
DO_NATIVEPOLY_BENCHMARK
(
BM_addeq_LATTICE
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_addeq_LATTICE
,
BE2Poly
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_addeq_LATTICE
,
BE4Poly
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_addeq_LATTICE
,
BE6Poly
)
...
...
@@ -403,6 +422,7 @@ static void BM_mult_LATTICE(benchmark::State& state) {
}
}
DO_NATIVEPOLY_BENCHMARK
(
BM_mult_LATTICE
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_mult_LATTICE
,
BE2Poly
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_mult_LATTICE
,
BE4Poly
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_mult_LATTICE
,
BE6Poly
)
...
...
@@ -430,6 +450,7 @@ static void BM_multeq_LATTICE(benchmark::State& state) { // benchmark
}
}
DO_NATIVEPOLY_BENCHMARK
(
BM_multeq_LATTICE
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_multeq_LATTICE
,
BE2Poly
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_multeq_LATTICE
,
BE4Poly
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_multeq_LATTICE
,
BE6Poly
)
...
...
@@ -454,6 +475,7 @@ static void BM_switchformat_LATTICE(benchmark::State& state) { // benchmark
}
}
DO_NATIVEPOLY_BENCHMARK
(
BM_switchformat_LATTICE
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_switchformat_LATTICE
,
BE2Poly
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_switchformat_LATTICE
,
BE4Poly
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_switchformat_LATTICE
,
BE6Poly
)
...
...
@@ -480,6 +502,7 @@ static void BM_doubleswitchformat_LATTICE(benchmark::State& state) { // benchmar
}
}
DO_NATIVEPOLY_BENCHMARK
(
BM_doubleswitchformat_LATTICE
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_doubleswitchformat_LATTICE
,
BE2Poly
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_doubleswitchformat_LATTICE
,
BE4Poly
)
DO_POLY_BENCHMARK_TEMPLATE
(
BM_doubleswitchformat_LATTICE
,
BE6Poly
)
...
...
benchmark/src/LatticeCompare.cpp
deleted
100644 → 0
View file @
60779a7f
/*
* LatticeCompare.cpp
* @author TPOC: palisade@njit.edu