|
|
@ -11,6 +11,7 @@ cybozu::XorShift rg; |
|
|
|
extern "C" void mcl_fp_addNC64(uint32_t *z, const uint32_t *x, const uint32_t *y); |
|
|
|
extern "C" void mcl_fp_addNC64(uint32_t *z, const uint32_t *x, const uint32_t *y); |
|
|
|
extern "C" void mcl_fp_addNC96(uint32_t *z, const uint32_t *x, const uint32_t *y); |
|
|
|
extern "C" void mcl_fp_addNC96(uint32_t *z, const uint32_t *x, const uint32_t *y); |
|
|
|
extern "C" void mcl_fp_addNC128(uint32_t *z, const uint32_t *x, const uint32_t *y); |
|
|
|
extern "C" void mcl_fp_addNC128(uint32_t *z, const uint32_t *x, const uint32_t *y); |
|
|
|
|
|
|
|
extern "C" void mcl_fp_addNC256(uint32_t *z, const uint32_t *x, const uint32_t *y); |
|
|
|
|
|
|
|
|
|
|
|
template<size_t N> |
|
|
|
template<size_t N> |
|
|
|
void addNC(uint32_t *z, const uint32_t *x, const uint32_t *y); |
|
|
|
void addNC(uint32_t *z, const uint32_t *x, const uint32_t *y); |
|
|
@ -20,6 +21,7 @@ void addNC(uint32_t *z, const uint32_t *x, const uint32_t *y); |
|
|
|
DEF_ADD(64) |
|
|
|
DEF_ADD(64) |
|
|
|
DEF_ADD(96) |
|
|
|
DEF_ADD(96) |
|
|
|
DEF_ADD(128) |
|
|
|
DEF_ADD(128) |
|
|
|
|
|
|
|
DEF_ADD(256) |
|
|
|
|
|
|
|
|
|
|
|
#define CAT(S, BIT) "S##BIT" |
|
|
|
#define CAT(S, BIT) "S##BIT" |
|
|
|
|
|
|
|
|
|
|
@ -45,11 +47,12 @@ void benchAdd() |
|
|
|
CYBOZU_TEST_AUTO(addNC64) { benchAdd<64>(); } |
|
|
|
CYBOZU_TEST_AUTO(addNC64) { benchAdd<64>(); } |
|
|
|
CYBOZU_TEST_AUTO(addNC96) { benchAdd<96>(); } |
|
|
|
CYBOZU_TEST_AUTO(addNC96) { benchAdd<96>(); } |
|
|
|
CYBOZU_TEST_AUTO(addNC128) { benchAdd<128>(); } |
|
|
|
CYBOZU_TEST_AUTO(addNC128) { benchAdd<128>(); } |
|
|
|
|
|
|
|
CYBOZU_TEST_AUTO(addNC256) { benchAdd<256>(); } |
|
|
|
#if 0 |
|
|
|
#if 0 |
|
|
|
CYBOZU_TEST_AUTO(addNC128) |
|
|
|
CYBOZU_TEST_AUTO(addNC) |
|
|
|
{ |
|
|
|
{ |
|
|
|
using namespace mcl::fp; |
|
|
|
using namespace mcl::fp; |
|
|
|
const size_t bit = 128; |
|
|
|
const size_t bit = 256; |
|
|
|
const size_t N = bit / UnitBitSize; |
|
|
|
const size_t N = bit / UnitBitSize; |
|
|
|
Unit x[N], y[N]; |
|
|
|
Unit x[N], y[N]; |
|
|
|
for (int i = 0; i < 10; i++) { |
|
|
|
for (int i = 0; i < 10; i++) { |
|
|
@ -60,11 +63,12 @@ CYBOZU_TEST_AUTO(addNC128) |
|
|
|
low_add<N>(z, x, y); |
|
|
|
low_add<N>(z, x, y); |
|
|
|
addNC<bit>(w, x, y); |
|
|
|
addNC<bit>(w, x, y); |
|
|
|
CYBOZU_TEST_EQUAL_ARRAY(z, w, N); |
|
|
|
CYBOZU_TEST_EQUAL_ARRAY(z, w, N); |
|
|
|
mcl_fp_addNC128_2(w, x, y); |
|
|
|
mcl_fp_addNC256_2(w, x, y); |
|
|
|
CYBOZU_TEST_EQUAL_ARRAY(z, w, N); |
|
|
|
CYBOZU_TEST_EQUAL_ARRAY(z, w, N); |
|
|
|
} |
|
|
|
} |
|
|
|
std::string name = "name" + cybozu::itoa(bit); |
|
|
|
std::string name = "name" + cybozu::itoa(bit); |
|
|
|
CYBOZU_BENCH(name.c_str(), addNC<bit>, x, x, y); |
|
|
|
CYBOZU_BENCH(name.c_str(), addNC<bit>, x, x, y); |
|
|
|
CYBOZU_BENCH("ad128", mcl_fp_addNC128_2, x, x, y); |
|
|
|
CYBOZU_BENCH("ad128", mcl_fp_addNC256_2, x, x, y); |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|