prefine: Add shared lock around bel availability checks
Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
parent
b7f91e57a0
commit
61cc5259d9
@ -69,7 +69,13 @@ struct ThreadState : DetailPlacerThreadState
|
|||||||
{
|
{
|
||||||
NPNR_ASSERT(moved_cells.empty());
|
NPNR_ASSERT(moved_cells.empty());
|
||||||
BelId old_bel = cell->bel;
|
BelId old_bel = cell->bel;
|
||||||
CellInfo *bound = ctx->getBoundBelCell(new_bel);
|
CellInfo *bound = nullptr;
|
||||||
|
{
|
||||||
|
#if !defined(NPNR_DISABLE_THREADS)
|
||||||
|
std::shared_lock<std::shared_timed_mutex> l(g.archapi_mutex);
|
||||||
|
#endif
|
||||||
|
bound = ctx->getBoundBelCell(new_bel);
|
||||||
|
}
|
||||||
if (bound && (bound->belStrength > STRENGTH_STRONG || bound->cluster != ClusterId()))
|
if (bound && (bound->belStrength > STRENGTH_STRONG || bound->cluster != ClusterId()))
|
||||||
return false;
|
return false;
|
||||||
if (!add_to_move(cell, old_bel, new_bel))
|
if (!add_to_move(cell, old_bel, new_bel))
|
||||||
@ -119,8 +125,13 @@ struct ThreadState : DetailPlacerThreadState
|
|||||||
if (used_bels.count(db.second))
|
if (used_bels.count(db.second))
|
||||||
goto fail;
|
goto fail;
|
||||||
used_bels.insert(db.second);
|
used_bels.insert(db.second);
|
||||||
|
CellInfo *bound = nullptr;
|
||||||
CellInfo *bound = ctx->getBoundBelCell(db.second);
|
{
|
||||||
|
#if !defined(NPNR_DISABLE_THREADS)
|
||||||
|
std::shared_lock<std::shared_timed_mutex> l(g.archapi_mutex);
|
||||||
|
#endif
|
||||||
|
bound = ctx->getBoundBelCell(db.second);
|
||||||
|
}
|
||||||
if (bound) {
|
if (bound) {
|
||||||
if (moved_cells.count(bound->name)) {
|
if (moved_cells.count(bound->name)) {
|
||||||
// Don't move a cell multiple times in the same go
|
// Don't move a cell multiple times in the same go
|
||||||
@ -146,7 +157,15 @@ struct ThreadState : DetailPlacerThreadState
|
|||||||
if (!add_to_move(bound, bound->bel, old_bel))
|
if (!add_to_move(bound, bound->bel, old_bel))
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
} else if (!ctx->checkBelAvail(db.second)) {
|
} else {
|
||||||
|
bool avail = false;
|
||||||
|
{
|
||||||
|
#if !defined(NPNR_DISABLE_THREADS)
|
||||||
|
std::shared_lock<std::shared_timed_mutex> l(g.archapi_mutex);
|
||||||
|
#endif
|
||||||
|
avail = ctx->checkBelAvail(db.second);
|
||||||
|
}
|
||||||
|
if (!avail)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user