Use MultiISA CPU detection for rec

Allows us to use overrides to test older ISA codegen on newer computers
This commit is contained in:
TellowKrinkle authored and TellowKrinkle committed 2025-08-24 20:16:24 -05:00
1 parent 406d7468dd
commit 5561884126
6 files changed
+31 -15

No files matched your search

+17 -5
View File
@@ -18,6 +18,11 @@ static ProcessorFeatures::VectorISA getCurrentISA()
// For debugging
if (const char* over = getenv("OVERRIDE_VECTOR_ISA"))
{
if (strcasecmp(over, "avx512f") == 0)
{
fprintf(stderr, "Vector ISA Override: AVX512F\n");
return ProcessorFeatures::VectorISA::AVX512F;
}
if (strcasecmp(over, "avx2") == 0)
{
fprintf(stderr, "Vector ISA Override: AVX2\n");
@@ -35,12 +40,13 @@ static ProcessorFeatures::VectorISA getCurrentISA()
}
}
if (cpuinfo_has_x86_avx2() && cpuinfo_has_x86_bmi() && cpuinfo_has_x86_bmi2())
return ProcessorFeatures::VectorISA::AVX2;
else if (cpuinfo_has_x86_avx())
return ProcessorFeatures::VectorISA::AVX;
else
if (!cpuinfo_has_x86_avx())
return ProcessorFeatures::VectorISA::SSE4;
if (!cpuinfo_has_x86_avx2())
return ProcessorFeatures::VectorISA::AVX;
if (!cpuinfo_has_x86_avx512f())
return ProcessorFeatures::VectorISA::AVX2;
return ProcessorFeatures::VectorISA::AVX512F;
}
#endif
@@ -53,11 +59,17 @@ static ProcessorFeatures getProcessorFeatures()
#if defined(_M_X86)
features.vectorISA = getCurrentISA();
features.hasFMA = cpuinfo_has_x86_fma3();
features.hasBMI2 = cpuinfo_has_x86_bmi() && cpuinfo_has_x86_bmi2();
if (const char* over = getenv("OVERRIDE_FMA"))
{
features.hasFMA = over[0] == 'Y' || over[0] == 'y' || over[0] == '1';
fprintf(stderr, "Processor FMA override: %s\n", features.hasFMA ? "Supported" : "Unsupported");
}
if (const char* over = getenv("OVERRIDE_BMI2"))
{
features.hasBMI2 = over[0] == 'Y' || over[0] == 'y' || over[0] == '1';
fprintf(stderr, "Processor BMI2 override: %s\n", features.hasBMI2 ? "Supported" : "Unsupported");
}
features.hasSlowGather = false;
if (const char* over = getenv("OVERRIDE_SLOW_GATHER")) // Easy override for comparing on vs off
{
+2 -2
View File
@@ -4,7 +4,6 @@
#pragma once
#include "common/Pcsx2Defs.h"
#include "common/VectorIntrin.h"
// For multiple-isa compilation
#ifdef MULTI_ISA_UNSHARED_COMPILATION
@@ -45,9 +44,10 @@
struct ProcessorFeatures
{
#ifdef _M_X86
enum class VectorISA { SSE4, AVX, AVX2 };
enum class VectorISA { SSE4, AVX, AVX2, AVX512F };
VectorISA vectorISA;
bool hasFMA;
bool hasBMI2;
bool hasSlowGather;
#endif
};
+1
View File
@@ -7,6 +7,7 @@
#include <algorithm>
#include <array>
#include <cstdio>
// --------------------------------------------------------------------------------------
// SPU2 Register Table LUT
+3 -3
View File
@@ -2527,11 +2527,11 @@ void VMManager::LogCPUCapabilities()
#ifdef _M_X86
std::string extensions;
if (cpuinfo_has_x86_avx())
if (g_cpu.vectorISA >= ProcessorFeatures::VectorISA::AVX)
extensions += "AVX ";
if (cpuinfo_has_x86_avx2())
if (g_cpu.vectorISA >= ProcessorFeatures::VectorISA::AVX2)
extensions += "AVX2 ";
if (cpuinfo_has_x86_avx512f())
if (g_cpu.vectorISA >= ProcessorFeatures::VectorISA::AVX512F)
extensions += "AVX512F ";
#ifdef _M_ARM64
if (cpuinfo_has_arm_neon())
+5 -2
View File
@@ -215,6 +215,9 @@ static const char eeOpcodeName[][16] = {
#ifdef eeProfileProg
#include <utility>
#include <algorithm>
#include "common/emitter/x86emitter.h"
#include "common/Console.h"
#include "GS/MultiISA.h"
using namespace x86Emitter;
@@ -368,7 +371,7 @@ struct eeProfiler
void EmitMem()
{
// Compact the 4GB virtual address to a 512KB virtual address
if (x86caps.hasBMI2)
if (g_cpu.hasBMI2)
{
xPEXT(ebx, ecx, ptr[&memMask]);
xADD(ptr32[(rbx * 4) + memStats], 1);
@@ -377,7 +380,7 @@ struct eeProfiler
void EmitConstMem(u32 add)
{
if (x86caps.hasBMI2)
if (g_cpu.hasBMI2)
{
u32 a = _pext_u32(add, memMask);
xADD(ptr32[a + memStats], 1);
+3 -3
View File
@@ -4,7 +4,7 @@
#pragma once
#include "Config.h"
#include "cpuinfo.h"
#include "GS/MultiISA.h"
//------------------------------------------------------------------
// Dispatcher Functions
@@ -207,7 +207,7 @@ static void mVUGenerateCopyPipelineState(mV)
{
mVU.copyPLState = xGetAlignedCallTarget();
if (cpuinfo_has_x86_avx())
if (g_cpu.vectorISA >= ProcessorFeatures::VectorISA::AVX)
{
xVMOVAPS(ymm0, ptr[rax]);
xVMOVAPS(ymm1, ptr[rax + 32u]);
@@ -252,7 +252,7 @@ static void mVUGenerateCompareState(mV)
{
mVU.compareStateF = xGetAlignedCallTarget();
if (!cpuinfo_has_x86_avx2())
if (g_cpu.vectorISA < ProcessorFeatures::VectorISA::AVX2)
{
xMOVAPS (xmm0, ptr32[arg1reg]);
xPCMP.EQD(xmm0, ptr32[arg2reg]);