From 58e40766205934d0a0b0c27cec4c7d7dfeda8776 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sun, 18 Dec 2016 22:51:23 +0100 Subject: [PATCH] vif: update alignment constraint 16B alignment is now useless for nVifBlock (no more SSE) However update the alignment of bucket to 64B. It will reduce cache miss probability in the find loop --- pcsx2/x86/newVif_Dynarec.cpp | 2 +- pcsx2/x86/newVif_HashBucket.h | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pcsx2/x86/newVif_Dynarec.cpp b/pcsx2/x86/newVif_Dynarec.cpp index e5bd1c5364..d5757f7001 100644 --- a/pcsx2/x86/newVif_Dynarec.cpp +++ b/pcsx2/x86/newVif_Dynarec.cpp @@ -307,7 +307,7 @@ _vifT __fi void dVifUnpack(const u8* data, bool isFill) { const u8 upkType = (vif.cmd & 0x1f) | (vif.usn << 5); const int doMask = isFill? 1 : (vif.cmd & 0x10); - __aligned16 nVifBlock block; + nVifBlock block; // Performance note: initial code was using u8/u16 field of the struct // directly. However reading back the data (as u32) in HashBucket.find diff --git a/pcsx2/x86/newVif_HashBucket.h b/pcsx2/x86/newVif_HashBucket.h index 3d10168366..7dc2ecd1d7 100644 --- a/pcsx2/x86/newVif_HashBucket.h +++ b/pcsx2/x86/newVif_HashBucket.h @@ -19,7 +19,7 @@ // nVifBlock - Ordered for Hashing; the 'num' and 'upkType' fields are // used as the hash bucket selector. -union __aligned16 nVifBlock { +union nVifBlock { // Warning: order depends on the newVifDynaRec code struct { u8 num; // [00] Num Field @@ -85,7 +85,8 @@ public: u32 size = bucket_size( dataPtr ); // Warning there is an extra +1 due to the empty cell - if( (m_bucket[b] = (nVifBlock*)pcsx2_aligned_realloc( m_bucket[b], sizeof(nVifBlock)*(size+2), 16, sizeof(nVifBlock)*(size+1) )) == NULL ) { + // Performance note: 64B align to reduce cache miss penalty in `find` + if( (m_bucket[b] = (nVifBlock*)pcsx2_aligned_realloc( m_bucket[b], sizeof(nVifBlock)*(size+2), 64, sizeof(nVifBlock)*(size+1) )) == NULL ) { throw Exception::OutOfMemory( wxsFormat(L"HashBucket Chain (bucket size=%d)", size+2) ); @@ -121,7 +122,7 @@ public: // Allocate an empty cell for all buckets for (auto& bucket : m_bucket) { - if( (bucket = (nVifBlock*)_aligned_malloc( sizeof(nVifBlock), 16 )) == nullptr ) { + if( (bucket = (nVifBlock*)_aligned_malloc( sizeof(nVifBlock), 64 )) == nullptr ) { throw Exception::OutOfMemory( wxsFormat(L"HashBucket Chain (bucket size=%d)", 1) );