atomic.cpp: improvements.

Reduced static memory amount for waitable atomics.
Allow notifier to skip notifications if wait/notify masks don't overlap.
Improve raw_notify to wake up the thread by its id, add thread_id arg.
Add optional mask argument to notify_one() and notify_all().
This commit is contained in:
Nekotekina 2020-11-04 17:19:35 +03:00
parent b66628baca
commit 5248240e10
7 changed files with 418 additions and 249 deletions

View file

@ -1842,7 +1842,7 @@ static bool ppu_store_reservation(ppu_thread& ppu, u32 addr, u64 reg_value)
return false;
}())
{
res.notify_all();
res.notify_all(-128);
if (addr == ppu.last_faddr)
{

View file

@ -2090,7 +2090,7 @@ void spu_thread::do_dma_transfer(spu_thread* _this, const spu_mfc_cmd& args, u8*
v &= ~wmask;
});
bits->notify_all();
bits->notify_all(wmask);
if (size == size0)
{
@ -2588,7 +2588,7 @@ bool spu_thread::do_putllc(const spu_mfc_cmd& args)
return success;
}())
{
vm::reservation_notifier(addr, 128).notify_all();
vm::reservation_notifier(addr, 128).notify_all(-128);
raddr = 0;
perf0.reset();
return true;
@ -2683,7 +2683,7 @@ void spu_thread::do_putlluc(const spu_mfc_cmd& args)
}
do_cell_atomic_128_store(addr, _ptr<spu_rdata_t>(args.lsa & 0x3ff80));
vm::reservation_notifier(addr, 128).notify_all();
vm::reservation_notifier(addr, 128).notify_all(-128);
}
void spu_thread::do_mfc(bool wait)

View file

@ -126,7 +126,7 @@ namespace vm
_xend();
#endif
if constexpr (Ack)
res.notify_all();
res.notify_all(-128);
return;
}
else
@ -140,7 +140,7 @@ namespace vm
_xend();
#endif
if constexpr (Ack)
res.notify_all();
res.notify_all(-128);
return result;
}
else
@ -201,7 +201,7 @@ namespace vm
#endif
res += 127;
if (Ack)
res.notify_all();
res.notify_all(-128);
return;
}
else
@ -215,7 +215,7 @@ namespace vm
#endif
res += 127;
if (Ack)
res.notify_all();
res.notify_all(-128);
return result;
}
else
@ -250,7 +250,7 @@ namespace vm
});
if constexpr (Ack)
res.notify_all();
res.notify_all(-128);
return;
}
else
@ -270,7 +270,7 @@ namespace vm
});
if (Ack && result)
res.notify_all();
res.notify_all(-128);
return result;
}
}
@ -287,7 +287,7 @@ namespace vm
}
if constexpr (Ack)
res.notify_all();
res.notify_all(-128);
return;
}
else
@ -307,7 +307,7 @@ namespace vm
}
if (Ack && result)
res.notify_all();
res.notify_all(-128);
return result;
}
}
@ -399,7 +399,7 @@ namespace vm
if constexpr (Ack)
{
res.notify_all();
res.notify_all(-128);
}
}
else
@ -409,7 +409,7 @@ namespace vm
if constexpr (Ack)
{
res.notify_all();
res.notify_all(-128);
}
return result;