From 4b82006984cabba32ad3e711fdc1a76ae6a41bdb Mon Sep 17 00:00:00 2001 From: Eladash Date: Fri, 9 Aug 2019 19:35:42 +0300 Subject: [PATCH] ppu: Improve LWSYNC Block load<->load reordering as real lwsync. --- rpcs3/Emu/Cell/Modules/cellSpurs.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellSync.cpp | 14 +++++++------- rpcs3/Emu/Cell/Modules/sys_lwmutex_.cpp | 4 ++-- rpcs3/Emu/Cell/PPUTranslator.cpp | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp index f8aa61441f..d4175a4bb1 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp @@ -2577,7 +2577,7 @@ s32 _cellSpursWorkloadFlagReceiver(vm::ptr spurs, u32 wid, u32 is_set return CELL_SPURS_POLICY_MODULE_ERROR_STAT; } - std::atomic_thread_fence(std::memory_order_seq_cst); + std::atomic_thread_fence(std::memory_order_acq_rel); if (s32 res = spurs->wklFlag.flag.atomic_op([spurs, wid, is_set](be_t& flag) -> s32 { diff --git a/rpcs3/Emu/Cell/Modules/cellSync.cpp b/rpcs3/Emu/Cell/Modules/cellSync.cpp index 4dd5f38b4e..0babe4424d 100644 --- a/rpcs3/Emu/Cell/Modules/cellSync.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSync.cpp @@ -87,7 +87,7 @@ error_code cellSyncMutexLock(ppu_thread& ppu, vm::ptr mutex) } } - std::atomic_thread_fence(std::memory_order_release); + std::atomic_thread_fence(std::memory_order_acq_rel); return CELL_OK; } @@ -196,7 +196,7 @@ error_code cellSyncBarrierTryNotify(vm::ptr barrier) return CELL_SYNC_ERROR_ALIGN; } - std::atomic_thread_fence(std::memory_order_release); + std::atomic_thread_fence(std::memory_order_acq_rel); if (!barrier->ctrl.atomic_op<&CellSyncBarrier::try_notify>()) { @@ -220,7 +220,7 @@ error_code cellSyncBarrierWait(ppu_thread& ppu, vm::ptr barrier return CELL_SYNC_ERROR_ALIGN; } - std::atomic_thread_fence(std::memory_order_release); + std::atomic_thread_fence(std::memory_order_acq_rel); while (!barrier->ctrl.atomic_op<&CellSyncBarrier::try_wait>()) { @@ -247,7 +247,7 @@ error_code cellSyncBarrierTryWait(vm::ptr barrier) return CELL_SYNC_ERROR_ALIGN; } - std::atomic_thread_fence(std::memory_order_release); + std::atomic_thread_fence(std::memory_order_acq_rel); if (!barrier->ctrl.atomic_op<&CellSyncBarrier::try_wait>()) { @@ -281,7 +281,7 @@ error_code cellSyncRwmInitialize(vm::ptr rwm, vm::ptr buffer, rwm->size = buffer_size; rwm->buffer = buffer; - std::atomic_thread_fence(std::memory_order_release); + std::atomic_thread_fence(std::memory_order_acq_rel); return CELL_OK; } @@ -453,7 +453,7 @@ error_code cellSyncQueueInitialize(vm::ptr queue, vm::ptr buf queue->depth = depth; queue->buffer = buffer; - std::atomic_thread_fence(std::memory_order_release); + std::atomic_thread_fence(std::memory_order_acq_rel); return CELL_OK; } @@ -866,7 +866,7 @@ error_code cellSyncLFQueueInitialize(vm::ptr queue, vm::cptr lwmutex, u64 // recursive locking succeeded lwmutex->recursive_count++; - std::atomic_thread_fence(std::memory_order_release); + std::atomic_thread_fence(std::memory_order_acq_rel); return CELL_OK; } @@ -290,7 +290,7 @@ error_code sys_lwmutex_trylock(ppu_thread& ppu, vm::ptr lwmutex) // recursive locking succeeded lwmutex->recursive_count++; - std::atomic_thread_fence(std::memory_order_release); + std::atomic_thread_fence(std::memory_order_acq_rel); return CELL_OK; } diff --git a/rpcs3/Emu/Cell/PPUTranslator.cpp b/rpcs3/Emu/Cell/PPUTranslator.cpp index 30d360a47a..6197a885f1 100644 --- a/rpcs3/Emu/Cell/PPUTranslator.cpp +++ b/rpcs3/Emu/Cell/PPUTranslator.cpp @@ -3106,8 +3106,8 @@ void PPUTranslator::LFSUX(ppu_opcode_t op) void PPUTranslator::SYNC(ppu_opcode_t op) { // sync: Full seq cst barrier - // lwsync: Release barrier - m_ir->CreateFence(op.l10 ? AtomicOrdering::Release : AtomicOrdering::SequentiallyConsistent); + // lwsync: Acq/Release barrier + m_ir->CreateFence(op.l10 ? AtomicOrdering::AcquireRelease : AtomicOrdering::SequentiallyConsistent); } void PPUTranslator::LFDX(ppu_opcode_t op)