Run a single thread synchronously

This commit is contained in:
tevador 2018-12-23 15:12:54 +01:00
parent c05947db09
commit 03913d0e81

View file

@ -206,6 +206,7 @@ int main(int argc, char** argv) {
else { else {
RandomX::Cache* cache = dataset.cache; RandomX::Cache* cache = dataset.cache;
RandomX::datasetAlloc(dataset); RandomX::datasetAlloc(dataset);
if (threadCount > 1) {
auto perThread = RandomX::DatasetBlockCount / threadCount; auto perThread = RandomX::DatasetBlockCount / threadCount;
auto remainder = RandomX::DatasetBlockCount % threadCount; auto remainder = RandomX::DatasetBlockCount % threadCount;
for (int i = 0; i < threadCount; ++i) { for (int i = 0; i < threadCount; ++i) {
@ -220,6 +221,15 @@ int main(int argc, char** argv) {
for (int i = 0; i < threads.size(); ++i) { for (int i = 0; i < threads.size(); ++i) {
threads[i].join(); threads[i].join();
} }
}
else {
if (softAes) {
RandomX::datasetInit<true>(cache, dataset, 0, RandomX::DatasetBlockCount);
}
else {
RandomX::datasetInit<false>(cache, dataset, 0, RandomX::DatasetBlockCount);
}
}
delete cache; delete cache;
threads.clear(); threads.clear();
std::cout << "Dataset (4 GiB) initialized in " << sw.getElapsed() << " s" << std::endl; std::cout << "Dataset (4 GiB) initialized in " << sw.getElapsed() << " s" << std::endl;
@ -238,12 +248,17 @@ int main(int argc, char** argv) {
} }
std::cout << "Running benchmark (" << programCount << " programs) ..." << std::endl; std::cout << "Running benchmark (" << programCount << " programs) ..." << std::endl;
sw.restart(); sw.restart();
if (threadCount > 1) {
for (int i = 0; i < vms.size(); ++i) { for (int i = 0; i < vms.size(); ++i) {
threads.push_back(std::thread(&mine, vms[i], std::ref(atomicNonce), std::ref(result), programCount, i)); threads.push_back(std::thread(&mine, vms[i], std::ref(atomicNonce), std::ref(result), programCount, i));
} }
for (int i = 0; i < threads.size(); ++i) { for (int i = 0; i < threads.size(); ++i) {
threads[i].join(); threads[i].join();
} }
}
else {
mine(vms[0], std::ref(atomicNonce), std::ref(result), programCount, 0);
}
double elapsed = sw.getElapsed(); double elapsed = sw.getElapsed();
std::cout << "Calculated result: "; std::cout << "Calculated result: ";
result.print(std::cout); result.print(std::cout);