mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
make straus cached mode thread safe, and add tests for it
This commit is contained in:
parent
7f48bf05d7
commit
e895c3def1
7 changed files with 233 additions and 35 deletions
|
@ -221,6 +221,13 @@ int main(int argc, char** argv)
|
|||
TEST_PERFORMANCE2(filter, verbose, test_multiexp, multiexp_straus, 1024);
|
||||
TEST_PERFORMANCE2(filter, verbose, test_multiexp, multiexp_straus, 4096);
|
||||
|
||||
TEST_PERFORMANCE2(filter, verbose, test_multiexp, multiexp_straus_cached, 2);
|
||||
TEST_PERFORMANCE2(filter, verbose, test_multiexp, multiexp_straus_cached, 8);
|
||||
TEST_PERFORMANCE2(filter, verbose, test_multiexp, multiexp_straus_cached, 16);
|
||||
TEST_PERFORMANCE2(filter, verbose, test_multiexp, multiexp_straus_cached, 256);
|
||||
TEST_PERFORMANCE2(filter, verbose, test_multiexp, multiexp_straus_cached, 1024);
|
||||
TEST_PERFORMANCE2(filter, verbose, test_multiexp, multiexp_straus_cached, 4096);
|
||||
|
||||
std::cout << "Tests finished. Elapsed time: " << timer.elapsed_ms() / 1000 << " sec" << std::endl;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -38,6 +38,7 @@ enum test_multiexp_algorithm
|
|||
{
|
||||
multiexp_bos_coster,
|
||||
multiexp_straus,
|
||||
multiexp_straus_cached,
|
||||
};
|
||||
|
||||
template<test_multiexp_algorithm algorithm, size_t npoints>
|
||||
|
@ -59,6 +60,7 @@ public:
|
|||
rct::key kn = rct::scalarmultKey(point, data[n].scalar);
|
||||
res = rct::addKeys(res, kn);
|
||||
}
|
||||
cache = rct::straus_init_cache(data);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -69,7 +71,9 @@ public:
|
|||
case multiexp_bos_coster:
|
||||
return res == bos_coster_heap_conv_robust(data);
|
||||
case multiexp_straus:
|
||||
return res == straus(data, false);
|
||||
return res == straus(data);
|
||||
case multiexp_straus_cached:
|
||||
return res == straus(data, cache);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -77,5 +81,6 @@ public:
|
|||
|
||||
private:
|
||||
std::vector<rct::MultiexpData> data;
|
||||
std::shared_ptr<rct::straus_cached_data> cache;
|
||||
rct::key res;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue