SPU: Use REP MOVSB in do_dma_transfer

- Try to use REP MOVSB when the size of the transfer is above a certain threshold
- This threshold is determined by the ERMS and FSRM cpuid flags
- The threshold values are (roughly) taken from GLIBC
- A threshold of 0xFFFFFFFF indicates that the cpu has neither flag
This commit is contained in:
Malcolm Jestadt 2021-10-29 23:55:47 -04:00 committed by Ivan
parent 1c014299eb
commit 31a5a77ae5
3 changed files with 138 additions and 60 deletions

View file

@ -138,6 +138,38 @@ bool utils::has_fma4()
return g_value;
}
bool utils::has_erms()
{
static const bool g_value = get_cpuid(0, 0)[0] >= 0x7 && (get_cpuid(7, 0)[1] & 0x200) == 0x200;
return g_value;
}
bool utils::has_fsrm()
{
static const bool g_value = get_cpuid(0, 0)[0] >= 0x7 && (get_cpuid(7, 0)[3] & 0x10) == 0x10;
return g_value;
}
u32 utils::get_rep_movsb_threshold()
{
static const u32 g_value = []()
{
u32 thresh_value = 0xFFFFFFFF;
if (has_fsrm())
{
thresh_value = 2047;
}
else if (has_erms())
{
thresh_value = 4095;
}
return thresh_value;
}();
return g_value;
}
std::string utils::get_cpu_brand()
{
std::string brand;