mirror of
https://github.com/azahar-emu/dynarmic.git
synced 2026-03-20 12:41:02 +01:00
backend: Do not use random generator for reg allocation (#7)
This commit is contained in:
@@ -145,7 +145,7 @@ set(TSL_ROBIN_MAP_ENABLE_INSTALL ON)
|
|||||||
|
|
||||||
find_package(Boost 1.57 REQUIRED)
|
find_package(Boost 1.57 REQUIRED)
|
||||||
find_package(fmt 9 CONFIG)
|
find_package(fmt 9 CONFIG)
|
||||||
find_package(mcl 0.1.12 EXACT CONFIG)
|
find_package(mcl 0.1.14 EXACT CONFIG)
|
||||||
find_package(tsl-robin-map CONFIG)
|
find_package(tsl-robin-map CONFIG)
|
||||||
|
|
||||||
if ("arm64" IN_LIST ARCHITECTURE OR DYNARMIC_TESTS)
|
if ("arm64" IN_LIST ARCHITECTURE OR DYNARMIC_TESTS)
|
||||||
|
|||||||
2
externals/mcl
vendored
2
externals/mcl
vendored
Submodule externals/mcl updated: 7b08d83418...5fc4beaf33
@@ -436,9 +436,10 @@ int RegAlloc::AllocateRegister(const std::array<HostLocInfo, 32>& regs, const st
|
|||||||
std::vector<int> candidates;
|
std::vector<int> candidates;
|
||||||
std::copy_if(order.begin(), order.end(), std::back_inserter(candidates), [&](int i) { return regs[i].MaybeAllocatable(); });
|
std::copy_if(order.begin(), order.end(), std::back_inserter(candidates), [&](int i) { return regs[i].MaybeAllocatable(); });
|
||||||
|
|
||||||
// TODO: LRU
|
// TODO: The candidate was chosen randomly before, and a LRU was
|
||||||
std::uniform_int_distribution<size_t> dis{0, candidates.size() - 1};
|
// suggested as an improvement. However, using an incrementing index
|
||||||
return candidates[dis(rand_gen)];
|
// seems to be close enough. Determine if an LRU is still needed.
|
||||||
|
return candidates[alloc_candidate_index++ % candidates.size()];
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegAlloc::SpillGpr(int index) {
|
void RegAlloc::SpillGpr(int index) {
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ public:
|
|||||||
using ArgumentInfo = std::array<Argument, IR::max_arg_count>;
|
using ArgumentInfo = std::array<Argument, IR::max_arg_count>;
|
||||||
|
|
||||||
explicit RegAlloc(oaknut::CodeGenerator& code, FpsrManager& fpsr_manager, std::vector<int> gpr_order, std::vector<int> fpr_order)
|
explicit RegAlloc(oaknut::CodeGenerator& code, FpsrManager& fpsr_manager, std::vector<int> gpr_order, std::vector<int> fpr_order)
|
||||||
: code{code}, fpsr_manager{fpsr_manager}, gpr_order{gpr_order}, fpr_order{fpr_order}, rand_gen{std::random_device{}()} {}
|
: code{code}, fpsr_manager{fpsr_manager}, gpr_order{gpr_order}, fpr_order{fpr_order} {}
|
||||||
|
|
||||||
ArgumentInfo GetArgumentInfo(IR::Inst* inst);
|
ArgumentInfo GetArgumentInfo(IR::Inst* inst);
|
||||||
bool WasValueDefined(IR::Inst* inst) const;
|
bool WasValueDefined(IR::Inst* inst) const;
|
||||||
@@ -333,7 +333,7 @@ private:
|
|||||||
HostLocInfo flags;
|
HostLocInfo flags;
|
||||||
std::array<HostLocInfo, SpillCount> spills;
|
std::array<HostLocInfo, SpillCount> spills;
|
||||||
|
|
||||||
mutable std::mt19937 rand_gen;
|
mutable size_t alloc_candidate_index{};
|
||||||
|
|
||||||
tsl::robin_set<const IR::Inst*> defined_insts;
|
tsl::robin_set<const IR::Inst*> defined_insts;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -269,9 +269,10 @@ u32 RegAlloc::AllocateRegister(const std::array<HostLocInfo, 32>& regs, const st
|
|||||||
std::vector<u32> candidates;
|
std::vector<u32> candidates;
|
||||||
std::copy_if(order.begin(), order.end(), std::back_inserter(candidates), [&](u32 i) { return !regs[i].locked; });
|
std::copy_if(order.begin(), order.end(), std::back_inserter(candidates), [&](u32 i) { return !regs[i].locked; });
|
||||||
|
|
||||||
// TODO: LRU
|
// TODO: The candidate was chosen randomly before, and a LRU was
|
||||||
std::uniform_int_distribution<size_t> dis{0, candidates.size() - 1};
|
// suggested as an improvement. However, using an incrementing index
|
||||||
return candidates[dis(rand_gen)];
|
// seems to be close enough. Determine if an LRU is still needed.
|
||||||
|
return candidates[alloc_candidate_index++ % candidates.size()];
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegAlloc::SpillGpr(u32 index) {
|
void RegAlloc::SpillGpr(u32 index) {
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ private:
|
|||||||
std::array<HostLocInfo, 32> fprs;
|
std::array<HostLocInfo, 32> fprs;
|
||||||
std::array<HostLocInfo, SpillCount> spills;
|
std::array<HostLocInfo, SpillCount> spills;
|
||||||
|
|
||||||
mutable std::mt19937 rand_gen;
|
mutable size_t alloc_candidate_index{};
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|||||||
Reference in New Issue
Block a user