the following code is written sequentially. I want to implement OpenMP by replacing while loop to for loop but have no idea how to do this. I know the OpenMP syntax but unable to implement.
The reason to do parallelism is to check the performance between sequential and parallel technique. Any help?
void block::mine_block(uint32_t difficulty) noexcept
{
string str(difficulty, '0');
auto start = system_clock::now();
while (_hash.substr(0, difficulty) != str)
{
++_nonce;
_hash = calculate_hash();
}
auto end = system_clock::now();
duration<double> diff = end - start;
cout << "Block mined: " << _hash << " in " << diff.count() << " seconds" << endl;
}
Aucun commentaire:
Enregistrer un commentaire