mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-22 19:39:22 +00:00
Self-test: multithreaded dataset initialization
This commit is contained in:
parent
ddc6986401
commit
5febb8c4e2
1 changed files with 20 additions and 1 deletions
21
src/main.cpp
21
src/main.cpp
|
@ -106,7 +106,26 @@ int p2pool_test()
|
|||
return 1;
|
||||
}
|
||||
|
||||
randomx_init_dataset(myDataset, myCache, 0, randomx_dataset_item_count());
|
||||
{
|
||||
const uint32_t numThreads = std::max(std::thread::hardware_concurrency(), 1U);
|
||||
const uint32_t numItems = randomx_dataset_item_count();
|
||||
|
||||
std::vector<std::thread> threads;
|
||||
threads.reserve(numThreads);
|
||||
|
||||
for (uint32_t i = 1; i < numThreads; ++i) {
|
||||
const uint32_t a = (numItems * i) / numThreads;
|
||||
const uint32_t b = (numItems * (i + 1)) / numThreads;
|
||||
|
||||
threads.emplace_back([myDataset, myCache, a, b]() { randomx_init_dataset(myDataset, myCache, a, b - a); });
|
||||
}
|
||||
randomx_init_dataset(myDataset, myCache, 0, numItems / numThreads);
|
||||
|
||||
for (std::thread& t : threads) {
|
||||
t.join();
|
||||
}
|
||||
}
|
||||
|
||||
randomx_release_cache(myCache);
|
||||
|
||||
randomx_vm* myMachine = randomx_create_vm(flags, nullptr, myDataset);
|
||||
|
|
Loading…
Reference in a new issue