mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 10:42:36 +01:00
atomic.cpp: add sparse atomics
Set alignment as second template argument (typically cache line).
This commit is contained in:
parent
130a0ef20e
commit
d344701fd5
@ -492,10 +492,10 @@ template <typename T>
|
||||
using to_le_t = typename to_se<T, std::endian::big == std::endian::native>::type;
|
||||
|
||||
// BE/LE aliases for atomic_t
|
||||
template <typename T>
|
||||
using atomic_be_t = atomic_t<be_t<T>>;
|
||||
template <typename T>
|
||||
using atomic_le_t = atomic_t<le_t<T>>;
|
||||
template <typename T, std::size_t Align = alignof(T)>
|
||||
using atomic_be_t = atomic_t<be_t<T>, Align>;
|
||||
template <typename T, std::size_t Align = alignof(T)>
|
||||
using atomic_le_t = atomic_t<le_t<T>, Align>;
|
||||
|
||||
template <typename T, bool Se, std::size_t Align>
|
||||
struct fmt_unveil<se_t<T, Se, Align>, void>
|
||||
|
@ -242,7 +242,7 @@ namespace fmt
|
||||
const fmt_type_info* get_type_info();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename T, std::size_t Align>
|
||||
class atomic_t;
|
||||
|
||||
// Extract T::simple_type if available, remove cv qualifiers
|
||||
|
@ -93,9 +93,9 @@ static constexpr u32 s_max_conds = 512 * 64;
|
||||
|
||||
static std::aligned_storage_t<sizeof(cond_handle), alignof(cond_handle)> s_cond_list[s_max_conds]{};
|
||||
|
||||
alignas(64) atomic_t<u64> s_cond_bits[s_max_conds / 64];
|
||||
atomic_t<u64, 64> s_cond_bits[s_max_conds / 64];
|
||||
|
||||
alignas(64) atomic_t<u32> s_cond_sema{0};
|
||||
atomic_t<u32, 64> s_cond_sema{0};
|
||||
|
||||
static u32 cond_alloc()
|
||||
{
|
||||
@ -281,7 +281,7 @@ static constexpr u32 s_slot_gcount = (s_hashtable_power > 7 ? 4096 : 256) / 64;
|
||||
alignas(64) static slot_info s_slot_list[s_slot_gcount * 64]{};
|
||||
|
||||
// Allocation bits
|
||||
alignas(64) static atomic_t<u64> s_slot_bits[s_slot_gcount]{};
|
||||
static atomic_t<u64, 64> s_slot_bits[s_slot_gcount]{};
|
||||
|
||||
static u64 slot_alloc()
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ enum class atomic_wait_timeout : u64
|
||||
struct atomic_storage_futex
|
||||
{
|
||||
private:
|
||||
template <typename T>
|
||||
template <typename T, std::size_t Align>
|
||||
friend class atomic_t;
|
||||
|
||||
static void wait(const void* data, std::size_t size, u64 old_value, u64 timeout, u64 mask);
|
||||
@ -674,7 +674,7 @@ struct atomic_storage<T, 16> : atomic_storage<T, 0>
|
||||
};
|
||||
|
||||
// Atomic type with lock-free and standard layout guarantees (and appropriate limitations)
|
||||
template <typename T>
|
||||
template <typename T, std::size_t Align = alignof(T)>
|
||||
class atomic_t
|
||||
{
|
||||
protected:
|
||||
@ -684,7 +684,7 @@ protected:
|
||||
|
||||
static_assert(alignof(type) == sizeof(type), "atomic_t<> error: unexpected alignment, use alignas() if necessary");
|
||||
|
||||
type m_data;
|
||||
alignas(Align) type m_data;
|
||||
|
||||
public:
|
||||
atomic_t() noexcept = default;
|
||||
|
Loading…
Reference in New Issue
Block a user