mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 09:32:52 +00:00
(performance.c ) Cleanups
This commit is contained in:
parent
7a0ff5911d
commit
f49dcd0739
118
performance.c
118
performance.c
@ -16,16 +16,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include "libretro.h"
|
||||
#include "performance.h"
|
||||
#include "general.h"
|
||||
#include "compat/strl.h"
|
||||
#include "verbosity.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define PERF_LOG_FMT "[PERF]: Avg (%s): %I64u ticks, %I64u runs.\n"
|
||||
#else
|
||||
#define PERF_LOG_FMT "[PERF]: Avg (%s): %llu ticks, %llu runs.\n"
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <direct.h>
|
||||
@ -33,6 +23,8 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <compat/strl.h>
|
||||
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
#include <windows.h>
|
||||
#include <intrin.h>
|
||||
@ -387,53 +379,53 @@ uint64_t cpu_features_get(void)
|
||||
len = sizeof(size_t);
|
||||
if (sysctlbyname("hw.optional.mmx", NULL, &len, NULL, 0) == 0)
|
||||
{
|
||||
cpu |= CPU_FEATURE_MMX;
|
||||
cpu |= CPU_FEATURE_MMXEXT;
|
||||
cpu |= RETRO_SIMD_MMX;
|
||||
cpu |= RETRO_SIMD_MMXEXT;
|
||||
}
|
||||
|
||||
len = sizeof(size_t);
|
||||
if (sysctlbyname("hw.optional.sse", NULL, &len, NULL, 0) == 0)
|
||||
cpu |= CPU_FEATURE_SSE;
|
||||
cpu |= RETRO_SIMD_SSE;
|
||||
|
||||
len = sizeof(size_t);
|
||||
if (sysctlbyname("hw.optional.sse2", NULL, &len, NULL, 0) == 0)
|
||||
cpu |= CPU_FEATURE_SSE2;
|
||||
cpu |= RETRO_SIMD_SSE2;
|
||||
|
||||
len = sizeof(size_t);
|
||||
if (sysctlbyname("hw.optional.sse3", NULL, &len, NULL, 0) == 0)
|
||||
cpu |= CPU_FEATURE_SSE3;
|
||||
cpu |= RETRO_SIMD_SSE3;
|
||||
|
||||
len = sizeof(size_t);
|
||||
if (sysctlbyname("hw.optional.supplementalsse3", NULL, &len, NULL, 0) == 0)
|
||||
cpu |= CPU_FEATURE_SSSE3;
|
||||
cpu |= RETRO_SIMD_SSSE3;
|
||||
|
||||
len = sizeof(size_t);
|
||||
if (sysctlbyname("hw.optional.sse4_1", NULL, &len, NULL, 0) == 0)
|
||||
cpu |= CPU_FEATURE_SSE4;
|
||||
cpu |= RETRO_SIMD_SSE4;
|
||||
|
||||
len = sizeof(size_t);
|
||||
if (sysctlbyname("hw.optional.sse4_2", NULL, &len, NULL, 0) == 0)
|
||||
cpu |= CPU_FEATURE_SSE42;
|
||||
cpu |= RETRO_SIMD_SSE42;
|
||||
|
||||
len = sizeof(size_t);
|
||||
if (sysctlbyname("hw.optional.aes", NULL, &len, NULL, 0) == 0)
|
||||
cpu |= CPU_FEATURE_AES;
|
||||
cpu |= RETRO_SIMD_AES;
|
||||
|
||||
len = sizeof(size_t);
|
||||
if (sysctlbyname("hw.optional.avx1_0", NULL, &len, NULL, 0) == 0)
|
||||
cpu |= CPU_FEATURE_AVX;
|
||||
cpu |= RETRO_SIMD_AVX;
|
||||
|
||||
len = sizeof(size_t);
|
||||
if (sysctlbyname("hw.optional.avx2_0", NULL, &len, NULL, 0) == 0)
|
||||
cpu |= CPU_FEATURE_AVX2;
|
||||
cpu |= RETRO_SIMD_AVX2;
|
||||
|
||||
len = sizeof(size_t);
|
||||
if (sysctlbyname("hw.optional.altivec", NULL, &len, NULL, 0) == 0)
|
||||
cpu |= CPU_FEATURE_VMX;
|
||||
cpu |= RETRO_SIMD_VMX;
|
||||
|
||||
len = sizeof(size_t);
|
||||
if (sysctlbyname("hw.optional.neon", NULL, &len, NULL, 0) == 0)
|
||||
cpu |= CPU_FEATURE_NEON;
|
||||
cpu |= RETRO_SIMD_NEON;
|
||||
|
||||
#elif defined(CPU_X86)
|
||||
(void)avx_flags;
|
||||
@ -458,52 +450,52 @@ uint64_t cpu_features_get(void)
|
||||
x86_cpuid(1, flags);
|
||||
|
||||
if (flags[3] & (1 << 23))
|
||||
cpu |= CPU_FEATURE_MMX;
|
||||
cpu |= RETRO_SIMD_MMX;
|
||||
|
||||
if (flags[3] & (1 << 25))
|
||||
{
|
||||
/* SSE also implies MMXEXT (according to FFmpeg source). */
|
||||
cpu |= CPU_FEATURE_SSE;
|
||||
cpu |= CPU_FEATURE_MMXEXT;
|
||||
cpu |= RETRO_SIMD_SSE;
|
||||
cpu |= RETRO_SIMD_MMXEXT;
|
||||
}
|
||||
|
||||
|
||||
if (flags[3] & (1 << 26))
|
||||
cpu |= CPU_FEATURE_SSE2;
|
||||
cpu |= RETRO_SIMD_SSE2;
|
||||
|
||||
if (flags[2] & (1 << 0))
|
||||
cpu |= CPU_FEATURE_SSE3;
|
||||
cpu |= RETRO_SIMD_SSE3;
|
||||
|
||||
if (flags[2] & (1 << 9))
|
||||
cpu |= CPU_FEATURE_SSSE3;
|
||||
cpu |= RETRO_SIMD_SSSE3;
|
||||
|
||||
if (flags[2] & (1 << 19))
|
||||
cpu |= CPU_FEATURE_SSE4;
|
||||
cpu |= RETRO_SIMD_SSE4;
|
||||
|
||||
if (flags[2] & (1 << 20))
|
||||
cpu |= CPU_FEATURE_SSE42;
|
||||
cpu |= RETRO_SIMD_SSE42;
|
||||
|
||||
if ((flags[2] & (1 << 23)))
|
||||
cpu |= CPU_FEATURE_POPCNT;
|
||||
cpu |= RETRO_SIMD_POPCNT;
|
||||
|
||||
if (vendor_is_intel && (flags[2] & (1 << 22)))
|
||||
cpu |= CPU_FEATURE_MOVBE;
|
||||
cpu |= RETRO_SIMD_MOVBE;
|
||||
|
||||
if (flags[2] & (1 << 25))
|
||||
cpu |= CPU_FEATURE_AES;
|
||||
cpu |= RETRO_SIMD_AES;
|
||||
|
||||
|
||||
/* Must only perform xgetbv check if we have
|
||||
* AVX CPU support (guaranteed to have at least i686). */
|
||||
if (((flags[2] & avx_flags) == avx_flags)
|
||||
&& ((xgetbv_x86(0) & 0x6) == 0x6))
|
||||
cpu |= CPU_FEATURE_AVX;
|
||||
cpu |= RETRO_SIMD_AVX;
|
||||
|
||||
if (max_flag >= 7)
|
||||
{
|
||||
x86_cpuid(7, flags);
|
||||
if (flags[1] & (1 << 5))
|
||||
cpu |= CPU_FEATURE_AVX2;
|
||||
cpu |= RETRO_SIMD_AVX2;
|
||||
}
|
||||
|
||||
x86_cpuid(0x80000000, flags);
|
||||
@ -512,55 +504,55 @@ uint64_t cpu_features_get(void)
|
||||
{
|
||||
x86_cpuid(0x80000001, flags);
|
||||
if (flags[3] & (1 << 23))
|
||||
cpu |= CPU_FEATURE_MMX;
|
||||
cpu |= RETRO_SIMD_MMX;
|
||||
if (flags[3] & (1 << 22))
|
||||
cpu |= CPU_FEATURE_MMXEXT;
|
||||
cpu |= RETRO_SIMD_MMXEXT;
|
||||
}
|
||||
#elif defined(__linux__)
|
||||
cpu_flags = linux_get_cpu_features();
|
||||
|
||||
if (cpu_flags & CPU_ARM_FEATURE_NEON)
|
||||
{
|
||||
cpu |= CPU_FEATURE_NEON;
|
||||
cpu |= RETRO_SIMD_NEON;
|
||||
#ifdef __ARM_NEON__
|
||||
arm_enable_runfast_mode();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (cpu_flags & CPU_ARM_FEATURE_VFPv3)
|
||||
cpu |= CPU_FEATURE_VFPV3;
|
||||
cpu |= RETRO_SIMD_VFPV3;
|
||||
|
||||
#elif defined(__ARM_NEON__)
|
||||
cpu |= CPU_FEATURE_NEON;
|
||||
cpu |= RETRO_SIMD_NEON;
|
||||
arm_enable_runfast_mode();
|
||||
#elif defined(__ALTIVEC__)
|
||||
cpu |= CPU_FEATURE_VMX;
|
||||
cpu |= RETRO_SIMD_VMX;
|
||||
#elif defined(XBOX360)
|
||||
cpu |= CPU_FEATURE_VMX128;
|
||||
cpu |= RETRO_SIMD_VMX128;
|
||||
#elif defined(PSP)
|
||||
cpu |= CPU_FEATURE_VFPU;
|
||||
cpu |= RETRO_SIMD_VFPU;
|
||||
#elif defined(GEKKO)
|
||||
cpu |= CPU_FEATURE_PS;
|
||||
cpu |= RETRO_SIMD_PS;
|
||||
#endif
|
||||
|
||||
if (cpu & CPU_FEATURE_MMX) strlcat(buf, " MMX", sizeof(buf));
|
||||
if (cpu & CPU_FEATURE_MMXEXT) strlcat(buf, " MMXEXT", sizeof(buf));
|
||||
if (cpu & CPU_FEATURE_SSE) strlcat(buf, " SSE", sizeof(buf));
|
||||
if (cpu & CPU_FEATURE_SSE2) strlcat(buf, " SSE2", sizeof(buf));
|
||||
if (cpu & CPU_FEATURE_SSE3) strlcat(buf, " SSE3", sizeof(buf));
|
||||
if (cpu & CPU_FEATURE_SSSE3) strlcat(buf, " SSSE3", sizeof(buf));
|
||||
if (cpu & CPU_FEATURE_SSE4) strlcat(buf, " SSE4", sizeof(buf));
|
||||
if (cpu & CPU_FEATURE_SSE42) strlcat(buf, " SSE4.2", sizeof(buf));
|
||||
if (cpu & CPU_FEATURE_AES) strlcat(buf, " AES", sizeof(buf));
|
||||
if (cpu & CPU_FEATURE_AVX) strlcat(buf, " AVX", sizeof(buf));
|
||||
if (cpu & CPU_FEATURE_AVX2) strlcat(buf, " AVX2", sizeof(buf));
|
||||
if (cpu & CPU_FEATURE_NEON) strlcat(buf, " NEON", sizeof(buf));
|
||||
if (cpu & CPU_FEATURE_VFPV3) strlcat(buf, " VFPv3", sizeof(buf));
|
||||
if (cpu & CPU_FEATURE_VFPV4) strlcat(buf, " VFPv4", sizeof(buf));
|
||||
if (cpu & CPU_FEATURE_VMX) strlcat(buf, " VMX", sizeof(buf));
|
||||
if (cpu & CPU_FEATURE_VMX128) strlcat(buf, " VMX128", sizeof(buf));
|
||||
if (cpu & CPU_FEATURE_VFPU) strlcat(buf, " VFPU", sizeof(buf));
|
||||
if (cpu & CPU_FEATURE_PS) strlcat(buf, " PS", sizeof(buf));
|
||||
if (cpu & RETRO_SIMD_MMX) strlcat(buf, " MMX", sizeof(buf));
|
||||
if (cpu & RETRO_SIMD_MMXEXT) strlcat(buf, " MMXEXT", sizeof(buf));
|
||||
if (cpu & RETRO_SIMD_SSE) strlcat(buf, " SSE", sizeof(buf));
|
||||
if (cpu & RETRO_SIMD_SSE2) strlcat(buf, " SSE2", sizeof(buf));
|
||||
if (cpu & RETRO_SIMD_SSE3) strlcat(buf, " SSE3", sizeof(buf));
|
||||
if (cpu & RETRO_SIMD_SSSE3) strlcat(buf, " SSSE3", sizeof(buf));
|
||||
if (cpu & RETRO_SIMD_SSE4) strlcat(buf, " SSE4", sizeof(buf));
|
||||
if (cpu & RETRO_SIMD_SSE42) strlcat(buf, " SSE4.2", sizeof(buf));
|
||||
if (cpu & RETRO_SIMD_AES) strlcat(buf, " AES", sizeof(buf));
|
||||
if (cpu & RETRO_SIMD_AVX) strlcat(buf, " AVX", sizeof(buf));
|
||||
if (cpu & RETRO_SIMD_AVX2) strlcat(buf, " AVX2", sizeof(buf));
|
||||
if (cpu & RETRO_SIMD_NEON) strlcat(buf, " NEON", sizeof(buf));
|
||||
if (cpu & RETRO_SIMD_VFPV3) strlcat(buf, " VFPv3", sizeof(buf));
|
||||
if (cpu & RETRO_SIMD_VFPV4) strlcat(buf, " VFPv4", sizeof(buf));
|
||||
if (cpu & RETRO_SIMD_VMX) strlcat(buf, " VMX", sizeof(buf));
|
||||
if (cpu & RETRO_SIMD_VMX128) strlcat(buf, " VMX128", sizeof(buf));
|
||||
if (cpu & RETRO_SIMD_VFPU) strlcat(buf, " VFPU", sizeof(buf));
|
||||
if (cpu & RETRO_SIMD_PS) strlcat(buf, " PS", sizeof(buf));
|
||||
|
||||
return cpu;
|
||||
}
|
||||
|
@ -26,28 +26,6 @@ typedef uint64_t retro_perf_tick_t;
|
||||
typedef uint64_t retro_time_t;
|
||||
#endif
|
||||
|
||||
/* ID values for CPU features */
|
||||
#define CPU_FEATURE_SSE (1 << 0)
|
||||
#define CPU_FEATURE_SSE2 (1 << 1)
|
||||
#define CPU_FEATURE_VMX (1 << 2)
|
||||
#define CPU_FEATURE_VMX128 (1 << 3)
|
||||
#define CPU_FEATURE_AVX (1 << 4)
|
||||
#define CPU_FEATURE_NEON (1 << 5)
|
||||
#define CPU_FEATURE_SSE3 (1 << 6)
|
||||
#define CPU_FEATURE_SSSE3 (1 << 7)
|
||||
#define CPU_FEATURE_MMX (1 << 8)
|
||||
#define CPU_FEATURE_MMXEXT (1 << 9)
|
||||
#define CPU_FEATURE_SSE4 (1 << 10)
|
||||
#define CPU_FEATURE_SSE42 (1 << 11)
|
||||
#define CPU_FEATURE_AVX2 (1 << 12)
|
||||
#define CPU_FEATURE_VFPU (1 << 13)
|
||||
#define CPU_FEATURE_PS (1 << 14)
|
||||
#define CPU_FEATURE_AES (1 << 15)
|
||||
#define CPU_FEATURE_VFPV3 (1 << 16)
|
||||
#define CPU_FEATURE_VFPV4 (1 << 17)
|
||||
#define CPU_FEATURE_POPCNT (1 << 18)
|
||||
#define CPU_FEATURE_MOVBE (1 << 19)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user