mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 09:13:08 +00:00
Implement yielding loop while waiting for input
Some MPI implementations use busy-wait pooling, which will turn MPI_Bcast into busy-wait loop, workaround with our own yielding loop.
This commit is contained in:
parent
80afeb0d3b
commit
0d6cdc0c6d
1 changed files with 17 additions and 0 deletions
|
@ -124,6 +124,23 @@ bool getline(std::istream& input, std::string& str) {
|
||||||
vec.assign(str.begin(), str.end());
|
vec.assign(str.begin(), str.end());
|
||||||
size = vec.size();
|
size = vec.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some MPI implementations use busy-wait pooling, while we need yielding
|
||||||
|
static MPI_Request reqInput = MPI_REQUEST_NULL;
|
||||||
|
MPI_Ibarrier(InputComm, &reqInput);
|
||||||
|
if (is_root())
|
||||||
|
MPI_Wait(&reqInput, MPI_STATUS_IGNORE);
|
||||||
|
else {
|
||||||
|
while (true) {
|
||||||
|
static int flag;
|
||||||
|
MPI_Test(&reqInput, &flag, MPI_STATUS_IGNORE);
|
||||||
|
if (flag)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MPI_Bcast(&size, 1, MPI_UNSIGNED_LONG, 0, InputComm);
|
MPI_Bcast(&size, 1, MPI_UNSIGNED_LONG, 0, InputComm);
|
||||||
if (!is_root())
|
if (!is_root())
|
||||||
vec.resize(size);
|
vec.resize(size);
|
||||||
|
|
Loading…
Add table
Reference in a new issue