(Performance) Use one single unsigned variable instead of
multiple bools - also introduce bitmasks
This commit is contained in:
parent
9f3af988f1
commit
af648b6598
|
@ -146,18 +146,35 @@ void rarch_get_cpu_features(struct rarch_cpu_features *cpu)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
x86_cpuid(1, flags);
|
x86_cpuid(1, flags);
|
||||||
cpu->sse = flags[3] & (1 << 25);
|
|
||||||
cpu->sse2 = flags[3] & (1 << 26);
|
if(flags[3] & (1 << 25))
|
||||||
|
cpu->simd |= RARCH_SIMD_SSE;
|
||||||
|
|
||||||
|
if(flags[3] & (1 << 26))
|
||||||
|
cpu->simd |= RARCH_SIMD_SSE2;
|
||||||
|
|
||||||
int avx_flags = (1 << 27) | (1 << 28);
|
int avx_flags = (1 << 27) | (1 << 28);
|
||||||
cpu->avx = (flags[2] & avx_flags) == avx_flags; // Is this enough?
|
|
||||||
|
|
||||||
RARCH_LOG("[CPUID]: SSE: %d\n", cpu->sse);
|
if((flags[2] & avx_flags) == avx_flags)
|
||||||
RARCH_LOG("[CPUID]: SSE2: %d\n", cpu->sse2);
|
cpu->simd |= RARCH_SIMD_AVX;
|
||||||
RARCH_LOG("[CPUID]: AVX: %d\n", cpu->avx);
|
|
||||||
|
RARCH_LOG("[CPUID]: SSE: %d\n", (cpu->simd & RARCH_SIMD_SSE) == RARCH_SIMD_SSE);
|
||||||
|
RARCH_LOG("[CPUID]: SSE2: %d\n", (cpu->simd & RARCH_SIMD_SSE2) == RARCH_SIMD_SSE2);
|
||||||
|
RARCH_LOG("[CPUID]: AVX: %d\n", (cpu->simd & RARCH_SIMD_AVX) == RARCH_SIMD_AVX);
|
||||||
#elif defined(ANDROID) && defined(ANDROID_ARM)
|
#elif defined(ANDROID) && defined(ANDROID_ARM)
|
||||||
uint64_t cpu_flags = android_getCpuFeatures();
|
uint64_t cpu_flags = android_getCpuFeatures();
|
||||||
cpu->neon = (cpu_flags & ANDROID_CPU_ARM_FEATURE_NEON);
|
|
||||||
RARCH_LOG("[CPUID]: NEON: %d\n", cpu->neon);
|
if(cpu_flags & ANDROID_CPU_ARM_FEATURE_NEON)
|
||||||
|
cpu->simd |= RARCH_SIMD_NEON;
|
||||||
|
|
||||||
|
RARCH_LOG("[CPUID]: NEON: %d\n", (cpu->simd & RARCH_SIMD_NEON) == RARCH_SIMD_NEON);
|
||||||
|
#elif defined(__CELLOS_LV2__)
|
||||||
|
cpu->simd |= RARCH_SIMD_VMX;
|
||||||
|
|
||||||
|
RARCH_LOG("[CPUID]: VMX: %d\n", (cpu->simd & RARCH_SIMD_VMX) == RARCH_SIMD_VMX);
|
||||||
|
#elif defined(XBOX360)
|
||||||
|
cpu->simd |= RARCH_SIMD_VMX128;
|
||||||
|
|
||||||
|
RARCH_LOG("[CPUID]: VMX128: %d\n", (cpu->simd & RARCH_SIMD_VMX128) == RARCH_SIMD_VMX128);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,13 +42,17 @@ void rarch_perf_log(void);
|
||||||
|
|
||||||
struct rarch_cpu_features
|
struct rarch_cpu_features
|
||||||
{
|
{
|
||||||
bool sse;
|
uint32_t simd;
|
||||||
bool sse2;
|
|
||||||
bool vmx;
|
|
||||||
bool avx;
|
|
||||||
bool neon;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Id values for SIMD CPU features
|
||||||
|
#define RARCH_SIMD_SSE (1 << 0)
|
||||||
|
#define RARCH_SIMD_SSE2 (1 << 1)
|
||||||
|
#define RARCH_SIMD_VMX (1 << 2)
|
||||||
|
#define RARCH_SIMD_VMX128 (1 << 3)
|
||||||
|
#define RARCH_SIMD_AVX (1 << 4)
|
||||||
|
#define RARCH_SIMD_NEON (1 << 5)
|
||||||
|
|
||||||
void rarch_get_cpu_features(struct rarch_cpu_features *cpu);
|
void rarch_get_cpu_features(struct rarch_cpu_features *cpu);
|
||||||
|
|
||||||
#ifdef PERF_TEST
|
#ifdef PERF_TEST
|
||||||
|
|
|
@ -2594,15 +2594,15 @@ static void validate_cpu_features(void)
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#ifdef __SSE__
|
#ifdef __SSE__
|
||||||
if (!cpu.sse)
|
if ((cpu.simd & RARCH_SIMD_SSE) != RARCH_SIMD_SSE)
|
||||||
FAIL_CPU("SSE");
|
FAIL_CPU("SSE");
|
||||||
#endif
|
#endif
|
||||||
#ifdef __SSE2__
|
#ifdef __SSE2__
|
||||||
if (!cpu.sse2)
|
if ((cpu.simd & RARCH_SIMD_SSE2) != RARCH_SIMD_SSE2)
|
||||||
FAIL_CPU("SSE2");
|
FAIL_CPU("SSE2");
|
||||||
#endif
|
#endif
|
||||||
#ifdef __AVX__
|
#ifdef __AVX__
|
||||||
if (!cpu.avx)
|
if ((cpu.simd & RARCH_SIMD_AVX) != RARCH_SIMD_AVX)
|
||||||
FAIL_CPU("AVX");
|
FAIL_CPU("AVX");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue