Commit graph

212 commits

Author SHA1 Message Date
Nekotekina 32f39fec1c Make cpu_counter::remove() async
Remove both mutex and assertion from it.
2020-12-01 10:18:41 +03:00
Nekotekina 43952e18e2 Implement prefetch_write() and prefetch_exec() wrappers
Do some refactoring to prefetch_read() in util/asm.hpp as well.
Make all these function constexpr because they are no-ops.
2020-11-24 12:31:11 +03:00
Nekotekina f85c8584b0 Attempt to fix #9316 2020-11-22 12:57:50 +03:00
Nekotekina 292af1e4cd CPU: use u128 in bit counter
Apparently, u64 was not enough.
2020-11-19 16:05:08 +03:00
Nekotekina 6d37bc62a5 CPU: remove cpu_counter from g_fxo
Convert it to a namespace, simplify add/remove functions.
Don't add() threads just creates, they are trapped in check_state() anyway.
Don't add() threads which are leaving check_state() because stopped.
2020-11-19 09:46:22 +03:00
Nekotekina e9f7c100a0 CPU: update suspend interface (dummy) 2020-11-18 19:15:56 +03:00
Nekotekina 190676c982 CPU: Fix g_suspend_counter waiting logic 2020-11-18 14:38:01 +03:00
Nekotekina badb3dc2dd atomic.cpp/threads: remove old wait callback
Add new wait callback which simply collects statistics.
Shift workarounds towards actual problem detection.
2020-11-14 18:16:27 +03:00
Nekotekina 5b69eda39a Fix suspend_all bug (TSX, TSX-FA)
Could cause freezes.
2020-11-14 10:56:05 +03:00
Nekotekina ab365fe494 Fixed thread pool a bit
Use 128-bit allocator instead of queue.
When pool is full (128), threads just terminate as before.
2020-11-13 13:32:44 +03:00
Nekotekina 67785a918c Implement simple thread pool 2020-11-13 03:32:24 +03:00
Nekotekina cdaa8cb5c4 CPU: Improve suspend_all g_suspend_counter handling
Increase in two stages, giving more chances to use it.
Second stage is when all wait flags have been seen.
2020-11-09 23:54:36 +03:00
Nekotekina bc61835d97 CPU: use unsigned (u8) priority in suspend_all 2020-11-09 22:57:36 +03:00
Nekotekina 557f0c5a8a atomic.cpp: remove load() from notify functions
Only compare masks for overlap for second overload (with mask provided).
Explicit "new value" can be provided in new 3-arg overloads.
Also rename atomic_storage_futex -> atomic_wait_engine.
2020-11-06 04:44:31 +03:00
Nekotekina 8d5e119582 Improve cpu_flag::temp handling
Ignore cpu_flag::suspend
Ignore cpu_flag::signal
2020-11-04 14:59:26 +03:00
Nekotekina dea8aa675a Optimize cpu check_state() a bit
Move cpu_flag::dbg_pause check from the start.
To the moment before it actually goes to sleep.
2020-11-04 14:59:25 +03:00
Nekotekina ba26e16411 Rename vm::reservation_light_op -> light_op
Rename vm::reservation_peek_op -> peek_op
Also remove overkill assertion for cpu_flag::temp.
2020-10-31 15:08:49 +03:00
Nekotekina f972fa26a4 Derive RSX Replay thread from cpu_thread
Its id is set to 0, so fix some id_type() usages.
2020-10-30 17:36:11 +03:00
Nekotekina 0da24f21d6 CPU: improve cpu_thread::suspend_all for cache efficiency (TSX)
Add prefetch hint list parameter.
Workloads may be executed by another thread on another CPU core.
It means they may benefit from directly prefetching the data as hinted.
Also implement mov_rdata_nt, for "streaming" data from such workloads.
2020-10-30 05:22:09 +03:00
Nekotekina d5667a859a CPU: improve cpu_thread::suspend_all (TSX)
Try to make more clever busy-waiting on cpu_flag::pause.
2020-10-30 02:58:39 +03:00
Nekotekina 95dbcf2fd7 Logs: add callback for cpu_thread to set cpu_flag::wait
May improve waiting time in critical suspend_all ops.
2020-10-29 18:57:57 +03:00
Nekotekina d6daa0d05b Fix cpu_flag::temp, make sure it removes cpu_flag::wait 2020-10-28 14:00:09 +03:00
Nekotekina 6806e3d5c7 atomic.cpp: implement notify callback
Notification can be very heavy, especially if we need to wake many threads.
Callback is set for cpu_thread in order to set wait flag accordingly.
2020-10-27 17:56:19 +03:00
Nekotekina f1e66085cd Fixup for cpu_flag::temp
Wrong check_state() result was triggering assertion.
2020-10-26 01:18:26 +03:00
Nekotekina 130a0ef20e Implement cpu_flag::temp flag
Accompanies wait flag, indicating that it was set in limited conditions.
Such condition don't allow thread to terminate after its removal.
2020-10-25 21:48:20 +03:00
Nekotekina f0fd7e2e19 Atomics: use WaitOnAddress if available (Win8+) 2020-10-21 00:22:08 +03:00
Nekotekina a5eb11d79f Improve cpu_thread::suspend_all (TSX-FA)
Add prefetching of cpu->state fields.
2020-10-19 19:41:28 +03:00
Nekotekina 120849c734 Implement perf stat counter for PPU/SPU reservation ops
Adds Emu/perf_meter.hpp header file.
Uses RDTSC for speed.
Prints stats at exit.
2020-10-19 19:41:28 +03:00
Nekotekina adf50b7c4b Implement cpu_thread::if_suspended
Use it for opportunistic guaranteed GETLLAR execution (TSX-FA).
2020-10-18 20:10:48 +03:00
Nekotekina f5c575961f Implement priorities for cpu_thread::suspend_all tasks
Give PUTLLUC increased priority.
2020-10-18 20:10:48 +03:00
Nekotekina 1606f97177 CPU: print and reset suspend_all statistics 2020-10-13 00:33:20 +03:00
Nekotekina ec7d243ee9 More optimization for cpu_thread::suspend_all
Try to not pause inactive threads.
2020-10-10 14:22:12 +03:00
Nekotekina b74c5e04f5 Optimize cpu_thread::suspend_all
Reduce internal thread status polling.
Refactor utility functions.
2020-10-10 14:12:49 +03:00
Nekotekina 050c3e1d6b Rewrite cpu_thread::suspend_all
Now it's a function of higher order.
Make only one thread do the hard work of thread pausing.
2020-10-10 13:58:48 +03:00
Nekotekina 346a1d4433 vm: rewrite reservation bits
Implement classic unique/shared locking concept.
Implement vm::reservation_light_op.
2020-10-10 13:58:48 +03:00
Eladash bcddbc15f0 Debugger: Fix PPU stepping on non-TSX 2020-08-19 19:48:35 +01:00
Eladash 82068cf802
SPU: Fix spu_thread::cpu_stop() missed executions (#8656) 2020-07-30 10:07:18 +01:00
Eladash d9750e8f9f SPU/PPU reservations: Optimizations for reservation locks and check_state() (non-TSX) 2020-07-09 03:17:35 +01:00
Eladash dc25a3fa2a PPU debugger: Show stack address of each function 2020-07-06 18:58:16 +02:00
sampletext32 437f374bae Fix some checks 2020-06-04 19:48:08 +03:00
Eladash b38580bf32 SPU: Use optimized PPU signaling to SPU on reservation pause 2020-05-13 11:10:13 +01:00
Nekotekina 19acf260d8 SPU DMA: Fix PUTLLUC (TSX)
Prevent edge case of missing store.
2020-04-29 15:40:41 +03:00
Nekotekina d0c199d455 Replace utils::cnttz{32,64} with std::countr_{zero,one}
Make #include <bit> mandatory.
2020-04-14 16:05:58 +03:00
Eladash 492a80f6c5 CPUThread.cpp: Minor indetation fixup 2020-04-13 04:34:10 +01:00
sampletext32 c69691f19b Fix various explicitness, laziness, hard codes 2020-04-12 17:29:42 +03:00
Nick Renieris 1231274e0f CPUThread: Split dump() info to separate methods 2020-04-03 01:36:35 +01:00
Nekotekina 20f7544a8a SPU profiler: minor change
Use std::greater to sort
2020-03-18 18:28:46 +03:00
Nekotekina 04dedb17eb Disable exception handling.
Use -fno-exceptions in cmake.
On MSVC, enable _HAS_EXCEPTION=0.
Cleanup throw/catch from the source.
Create yaml.cpp enclave because it needs exception to work.
Disable thread_local optimizations in logs.cpp (TODO).
Implement cpu_counter for cpu_threads (moved globals).
2020-03-12 16:03:08 +03:00
Nekotekina 9dca2887d8 Fixup for Emu.Pause()
Remove some reduntant calls.
Don't pause on unknown sys_fs_fcntl operation.
2020-03-08 22:03:16 +03:00
Nekotekina 07e1766a7c Implement thread_ctrl::emergency_exit()
Replace exception throws with this.
2020-03-08 15:11:02 +03:00