Commit Graph

36 Commits

Author SHA1 Message Date
Nekotekina 160b131de3 types.hpp: implement smin, smax, amin, amax
Rewritten the following global utility constants:
`umax` returns max number, restricted to unsigned.
`smax` returns max signed number, restricted to integrals.
`smin` returns min signed number, restricted to signed.
`amin` returns smin or zero, less restricted.
`amax` returns smax or umax, less restricted.

Fix operators == and <=> for synthesized rel-ops.
2021-05-22 12:10:57 +03:00
Megamouse a16d8ba3ea More random changes 2021-04-11 14:01:51 +03:00
Nekotekina e055d16b2c Replace verify() with ensure() with auto src location.
Expression ensure(x) returns x.
Using comma operator removed.
2020-12-09 15:43:38 +03:00
Nekotekina 34fa010601 Improve cond_var notifiers
But nobody uses it anyway, so clean up includes.
2020-11-06 00:10:16 +03:00
Nekotekina c50233cc92 atomics.cpp: add support for waiting on 128-bit atomics
Complementarily.
Also refactored to make waiting mask non-template arg.
2020-10-28 03:47:41 +03:00
Nekotekina Aux1 250736ece5 Fix warnings in emucore 2020-03-04 21:23:34 +03:00
Nekotekina 3304cfacde cond_variable: improve wait a bit
Mask signal bits
2019-10-19 14:02:13 +03:00
Nekotekina feee3838eb Revert "Revert "Remove `shared_cond` and simplify reservation waiting""
This reverts commit b70c08a2e8.
2019-09-24 05:01:00 +03:00
Nekotekina 3121fecc8f cond_variable: fix warning in cond.h for MSVC 2019-09-21 03:59:43 +03:00
Nekotekina b70c08a2e8 Revert "Remove `shared_cond` and simplify reservation waiting"
This reverts commit 0a96497e13.
2019-09-14 00:02:48 +03:00
Nekotekina 0a96497e13 Remove `shared_cond` and simplify reservation waiting
Use atomic wait for reservations
Cleanup some obsolete code
2019-09-10 19:25:39 +03:00
Nekotekina d13ff285d1 Rewrite `cond_variable` to use waitable atomics
Increase max_timeout and fix max_timeout usage
2019-09-10 19:25:39 +03:00
Nekotekina 92a75cfa80 Remove `unique_cond`
Not very useful.
2019-09-10 19:25:39 +03:00
Nekotekina a45f86a4a2 Remove `notifier` class
Poorly implemented condition variable.
2019-09-10 19:25:39 +03:00
Nekotekina b91661ae71 Remove timeout support from lf_queue::wait
Add notify method and use atomic wait
2019-09-10 19:25:39 +03:00
Nekotekina 5d45a3e47d Implement cpu_thread::suspend_all
Remove Accurate PUTLLC option.
Implement fallback path for SPU transactions.
2019-06-19 20:36:12 +03:00
Nekotekina 1dedeb37bf Fix lf_queue_base::wait
Add missing state change
2019-06-05 15:51:25 +03:00
Nekotekina 9dc0368079 Rename cond_x16 to shared_cond
Extend capacity from 16 to 32.
Remove redundant m_total counter.
2019-06-04 16:37:50 +03:00
Nekotekina 31994dd3b2 Rename cond_one to unique_cond
Remove redundant in_cv in cellVdec
2019-06-02 23:22:16 +03:00
Nekotekina 0333942795 Change utils::popcnt16 to popcnt32
Use __builtin_popcount if available.
2019-06-02 23:22:16 +03:00
Nekotekina 4f152ad126 SPU: multithread compilation
Allow parallel compilation of SPU code, both at startup and runtime
Remove 'SPU Shared Runtime' option (it became obsolete)
Refactor spu_runtime class (now is common for ASMJIT and LLVM)
Implement SPU ubertrampoline generation in raw assembly (LLVM)
Minor improvement of balanced_wait_until<> and balanced_awaken<>
Make JIT MemoryManager2 shared (global)
Fix wrong assertion in cond_variable
2019-01-22 22:02:02 +03:00
Nekotekina 81c50bad69 lf_queue: implement wait() method
Synchronization does not occupy additional space by reusing LSB
2019-01-13 14:45:36 +03:00
Nekotekina 96cabeadff Rewrite condition variables
Implement helper functions balanced_wait_until and balanced_awaken
They include new path for Windows 8.1+ (WaitOnAddress)

shared_mutex, cond_variable, cond_one, cond_x16 modified to use it
Added helper function utils::popcnt16
Replace most semaphore<> with shared_mutex
2018-11-29 01:30:05 +03:00
Nekotekina febe4d4a10 Implement class cond_x16
Use as reservation notifier
Limited to 16 threads but allows more precise control of contention
2018-11-26 00:23:29 +03:00
Nekotekina 6104685ad6 Implement cond_one sync primitive
Change futex() args to use unsigned int
2018-11-05 13:14:11 +03:00
Nekotekina 1b37e775be Migration to named_thread<>
Add atomic_t<>::try_dec instead of fetch_dec_sat
Add atomic_t<>::try_inc
GDBDebugServer is broken (needs rewrite)
Removed old_thread class (former named_thread)
Removed storing/rethrowing exceptions from thread
Emu.Stop doesn't inject an exception anymore
task_stack helper class removed
thread_base simplified (no shared_from_this)
thread_ctrl::spawn simplified (creates detached thread)
Implemented overrideable thread detaching logic
Disabled cellAdec, cellDmux, cellFsAio
SPUThread renamed to spu_thread
RawSPUThread removed, spu_thread used instead
Disabled deriving from ppu_thread
Partial support for thread renaming
lv2_timer... simplified, screw it
idm/fxm: butchered support for on_stop/on_init
vm: improved allocation structure (added size)
2018-10-19 22:22:35 +03:00
Nekotekina fb5cdf9769 atomic_t<>: extend fetch_op to support cancellation
Use std::invoke inside atomic_op/fetch_op
Remove op_fetch because it's easily replaced
Add fetch_dec_sat algorithm (conditional decrement)
2018-09-08 00:32:04 +03:00
Nekotekina ee96807305 Remove explicit_bool_t, ignore, multicast<>
Remove vm::ptr operator %
This was a bad idea but explicit_bool_t was created almost for it
Other removed types are unused and have little to no meaning
2018-09-08 00:32:04 +03:00
Nekotekina a33f297315 Replace notifier::lock_shared() with try_lock_shared()
Also add notify_one(), try_lock() and unlock()
Move some code in cond.cpp
2018-05-21 00:18:37 +03:00
Nekotekina 0b1c8bc676 Change retire strategy in cond_variable::imp_wait (WIN32)
Instead of waiting infinitely, try and yield until success
2018-05-17 21:29:49 +03:00
Nekotekina 367f039523 Build transactions at runtime
Drop _xbegin family intrinsics due to bad codegen
Implemented `notifier` class, replacing vm::notify
Minor optimization: detach transactions from global mutex on TSX path
Minor optimization: don't acquire vm::passive_lock on PPU on TSX path
2018-05-16 17:31:58 +03:00
Nekotekina c58738807e Fix cond_variable timeout
Thanks @Farseer2 for debugging
2017-11-18 10:24:17 +03:00
Ryan Gonzalez e447f071ce Misc compile fixes 2017-04-18 22:37:17 +03:00
Nekotekina f35babad98 shared_mutex fix (linux) 2017-02-24 18:48:53 +03:00
Nekotekina b1aa87b515 Busy waiting added 2017-02-16 00:13:55 +03:00
Nekotekina 1c14d872a8 New shared_mutex
Experimental sync utils
New semaphore<>
New cond_variable
New owned_mutex
2017-01-25 00:38:07 +03:00