|
SDL
2.0
|
Include dependency graph for SDL_cpuinfo.c:Go to the source code of this file.
Macros | |
| #define | CPU_HAS_RDTSC (1 << 0) |
| #define | CPU_HAS_ALTIVEC (1 << 1) |
| #define | CPU_HAS_MMX (1 << 2) |
| #define | CPU_HAS_3DNOW (1 << 3) |
| #define | CPU_HAS_SSE (1 << 4) |
| #define | CPU_HAS_SSE2 (1 << 5) |
| #define | CPU_HAS_SSE3 (1 << 6) |
| #define | CPU_HAS_SSE41 (1 << 7) |
| #define | CPU_HAS_SSE42 (1 << 8) |
| #define | CPU_HAS_AVX (1 << 9) |
| #define | CPU_HAS_AVX2 (1 << 10) |
| #define | CPU_HAS_NEON (1 << 11) |
| #define | CPU_HAS_AVX512F (1 << 12) |
| #define | CPU_HAS_ARM_SIMD (1 << 13) |
| #define | cpuid(func, a, b, c, d) do { a = b = c = d = 0; (void) a; (void) b; (void) c; (void) d; } while (0) |
| #define | CPU_haveRDTSC() (CPU_CPUIDFeatures[3] & 0x00000010) |
| #define | CPU_haveMMX() (CPU_CPUIDFeatures[3] & 0x00800000) |
| #define | CPU_haveSSE() (CPU_CPUIDFeatures[3] & 0x02000000) |
| #define | CPU_haveSSE2() (CPU_CPUIDFeatures[3] & 0x04000000) |
| #define | CPU_haveSSE3() (CPU_CPUIDFeatures[2] & 0x00000001) |
| #define | CPU_haveSSE41() (CPU_CPUIDFeatures[2] & 0x00080000) |
| #define | CPU_haveSSE42() (CPU_CPUIDFeatures[2] & 0x00100000) |
| #define | CPU_haveAVX() (CPU_OSSavesYMM && (CPU_CPUIDFeatures[2] & 0x10000000)) |
| #define | CPU_FEATURE_AVAILABLE(f) ((SDL_GetCPUFeatures() & f) ? SDL_TRUE : SDL_FALSE) |
Variables | |
| static int | CPU_CPUIDFeatures [4] |
| static int | CPU_CPUIDMaxFunction = 0 |
| static SDL_bool | CPU_OSSavesYMM = SDL_FALSE |
| static SDL_bool | CPU_OSSavesZMM = SDL_FALSE |
| static int | SDL_CPUCount = 0 |
| static Uint32 | SDL_CPUFeatures = 0xFFFFFFFF |
| static Uint32 | SDL_SIMDAlignment = 0xFFFFFFFF |
| static int | SDL_SystemRAM = 0 |
| #define CPU_FEATURE_AVAILABLE | ( | f | ) | ((SDL_GetCPUFeatures() & f) ? SDL_TRUE : SDL_FALSE) |
Definition at line 798 of file SDL_cpuinfo.c.
| #define CPU_HAS_3DNOW (1 << 3) |
Definition at line 106 of file SDL_cpuinfo.c.
| #define CPU_HAS_ALTIVEC (1 << 1) |
Definition at line 104 of file SDL_cpuinfo.c.
| #define CPU_HAS_ARM_SIMD (1 << 13) |
Definition at line 116 of file SDL_cpuinfo.c.
| #define CPU_HAS_AVX (1 << 9) |
Definition at line 112 of file SDL_cpuinfo.c.
| #define CPU_HAS_AVX2 (1 << 10) |
Definition at line 113 of file SDL_cpuinfo.c.
| #define CPU_HAS_AVX512F (1 << 12) |
Definition at line 115 of file SDL_cpuinfo.c.
| #define CPU_HAS_MMX (1 << 2) |
Definition at line 105 of file SDL_cpuinfo.c.
| #define CPU_HAS_NEON (1 << 11) |
Definition at line 114 of file SDL_cpuinfo.c.
| #define CPU_HAS_RDTSC (1 << 0) |
Definition at line 103 of file SDL_cpuinfo.c.
| #define CPU_HAS_SSE (1 << 4) |
Definition at line 107 of file SDL_cpuinfo.c.
| #define CPU_HAS_SSE2 (1 << 5) |
Definition at line 108 of file SDL_cpuinfo.c.
| #define CPU_HAS_SSE3 (1 << 6) |
Definition at line 109 of file SDL_cpuinfo.c.
| #define CPU_HAS_SSE41 (1 << 7) |
Definition at line 110 of file SDL_cpuinfo.c.
| #define CPU_HAS_SSE42 (1 << 8) |
Definition at line 111 of file SDL_cpuinfo.c.
| #define CPU_haveAVX | ( | ) | (CPU_OSSavesYMM && (CPU_CPUIDFeatures[2] & 0x10000000)) |
Definition at line 533 of file SDL_cpuinfo.c.
| #define CPU_haveMMX | ( | ) | (CPU_CPUIDFeatures[3] & 0x00800000) |
Definition at line 527 of file SDL_cpuinfo.c.
| #define CPU_haveRDTSC | ( | ) | (CPU_CPUIDFeatures[3] & 0x00000010) |
Definition at line 526 of file SDL_cpuinfo.c.
| #define CPU_haveSSE | ( | ) | (CPU_CPUIDFeatures[3] & 0x02000000) |
Definition at line 528 of file SDL_cpuinfo.c.
| #define CPU_haveSSE2 | ( | ) | (CPU_CPUIDFeatures[3] & 0x04000000) |
Definition at line 529 of file SDL_cpuinfo.c.
| #define CPU_haveSSE3 | ( | ) | (CPU_CPUIDFeatures[2] & 0x00000001) |
Definition at line 530 of file SDL_cpuinfo.c.
| #define CPU_haveSSE41 | ( | ) | (CPU_CPUIDFeatures[2] & 0x00080000) |
Definition at line 531 of file SDL_cpuinfo.c.
| #define CPU_haveSSE42 | ( | ) | (CPU_CPUIDFeatures[2] & 0x00100000) |
Definition at line 532 of file SDL_cpuinfo.c.
| #define cpuid | ( | func, | |
| a, | |||
| b, | |||
| c, | |||
| d | |||
| ) | do { a = b = c = d = 0; (void) a; (void) b; (void) c; (void) d; } while (0) |
Definition at line 268 of file SDL_cpuinfo.c.
Definition at line 278 of file SDL_cpuinfo.c.
References CPU_CPUIDFeatures, CPU_CPUIDMaxFunction, CPU_haveCPUID(), CPU_OSSavesYMM, CPU_OSSavesZMM, cpuid, d, int(), mov, SDL_FALSE, and SDL_TRUE.
Referenced by SDL_GetCPUFeatures(), and SDL_GetCPUType().
Definition at line 513 of file SDL_cpuinfo.c.
References CPU_CPUIDMaxFunction, cpuid, and d.
Referenced by SDL_GetCPUFeatures().
Definition at line 318 of file SDL_cpuinfo.c.
Referenced by SDL_GetCPUFeatures().
Definition at line 357 of file SDL_cpuinfo.c.
Referenced by SDL_GetCPUFeatures().
Definition at line 536 of file SDL_cpuinfo.c.
References CPU_CPUIDMaxFunction, CPU_OSSavesYMM, cpuid, d, and void.
Referenced by SDL_GetCPUFeatures().
Definition at line 548 of file SDL_cpuinfo.c.
References CPU_CPUIDMaxFunction, CPU_OSSavesZMM, cpuid, d, and void.
Referenced by SDL_GetCPUFeatures().
Definition at line 131 of file SDL_cpuinfo.c.
References done, mov, and pop.
Referenced by CPU_calcCPUIDFeatures().
This function returns the L1 cache line size of the CPU
This is useful for determining multi-threaded structure padding or SIMD prefetch sizes.
Definition at line 712 of file SDL_cpuinfo.c.
References cpuid, d, SDL_CACHELINE_SIZE, SDL_GetCPUType(), SDL_strcmp, and void.
This function returns the number of CPU cores available.
Definition at line 562 of file SDL_cpuinfo.c.
References int(), NULL, and SDL_CPUCount.
Definition at line 733 of file SDL_cpuinfo.c.
References CPU_calcCPUIDFeatures(), CPU_HAS_3DNOW, CPU_HAS_ALTIVEC, CPU_HAS_ARM_SIMD, CPU_HAS_AVX, CPU_HAS_AVX2, CPU_HAS_AVX512F, CPU_HAS_MMX, CPU_HAS_NEON, CPU_HAS_RDTSC, CPU_HAS_SSE, CPU_HAS_SSE2, CPU_HAS_SSE3, CPU_HAS_SSE41, CPU_HAS_SSE42, CPU_have3DNow(), CPU_haveAltiVec(), CPU_haveARMSIMD(), CPU_haveAVX, CPU_haveAVX2(), CPU_haveAVX512F(), CPU_haveMMX, CPU_haveNEON(), CPU_haveRDTSC, CPU_haveSSE, CPU_haveSSE2, CPU_haveSSE3, CPU_haveSSE41, CPU_haveSSE42, SDL_CPUFeatures, SDL_max, and SDL_SIMDAlignment.
Referenced by SDL_SIMDGetAlignment().
|
static |
Definition at line 601 of file SDL_cpuinfo.c.
References CPU_calcCPUIDFeatures(), CPU_CPUIDMaxFunction, cpuid, d, i, SDL_strlcpy, and void.
Referenced by SDL_GetCPUCacheLineSize().
This function returns the amount of RAM configured in the system, in MB.
Definition at line 886 of file SDL_cpuinfo.c.
References int(), NULL, and SDL_SystemRAM.
This function returns true if the CPU has 3DNow! features.
Definition at line 818 of file SDL_cpuinfo.c.
References CPU_FEATURE_AVAILABLE, and CPU_HAS_3DNOW.
This function returns true if the CPU has AltiVec features.
Definition at line 806 of file SDL_cpuinfo.c.
References CPU_FEATURE_AVAILABLE, and CPU_HAS_ALTIVEC.
This function returns true if the CPU has ARM SIMD (ARMv6) features.
Definition at line 872 of file SDL_cpuinfo.c.
References CPU_FEATURE_AVAILABLE, and CPU_HAS_ARM_SIMD.
This function returns true if the CPU has AVX features.
Definition at line 854 of file SDL_cpuinfo.c.
References CPU_FEATURE_AVAILABLE, and CPU_HAS_AVX.
This function returns true if the CPU has AVX2 features.
Definition at line 860 of file SDL_cpuinfo.c.
References CPU_FEATURE_AVAILABLE, and CPU_HAS_AVX2.
This function returns true if the CPU has AVX-512F (foundation) features.
Definition at line 866 of file SDL_cpuinfo.c.
References CPU_FEATURE_AVAILABLE, and CPU_HAS_AVX512F.
This function returns true if the CPU has MMX features.
Definition at line 812 of file SDL_cpuinfo.c.
References CPU_FEATURE_AVAILABLE, and CPU_HAS_MMX.
This function returns true if the CPU has NEON (ARM SIMD) features.
Definition at line 878 of file SDL_cpuinfo.c.
References CPU_FEATURE_AVAILABLE, and CPU_HAS_NEON.
This function returns true if the CPU has the RDTSC instruction.
Definition at line 800 of file SDL_cpuinfo.c.
References CPU_FEATURE_AVAILABLE, and CPU_HAS_RDTSC.
This function returns true if the CPU has SSE features.
Definition at line 824 of file SDL_cpuinfo.c.
References CPU_FEATURE_AVAILABLE, and CPU_HAS_SSE.
This function returns true if the CPU has SSE2 features.
Definition at line 830 of file SDL_cpuinfo.c.
References CPU_FEATURE_AVAILABLE, and CPU_HAS_SSE2.
This function returns true if the CPU has SSE3 features.
Definition at line 836 of file SDL_cpuinfo.c.
References CPU_FEATURE_AVAILABLE, and CPU_HAS_SSE3.
This function returns true if the CPU has SSE4.1 features.
Definition at line 842 of file SDL_cpuinfo.c.
References CPU_FEATURE_AVAILABLE, and CPU_HAS_SSE41.
This function returns true if the CPU has SSE4.2 features.
Definition at line 848 of file SDL_cpuinfo.c.
References CPU_FEATURE_AVAILABLE, and CPU_HAS_SSE42.
Allocate memory in a SIMD-friendly way.
This will allocate a block of memory that is suitable for use with SIMD instructions. Specifically, it will be properly aligned and padded for the system's supported vector instructions.
The memory returned will be padded such that it is safe to read or write an incomplete vector at the end of the memory block. This can be useful so you don't have to drop back to a scalar fallback at the end of your SIMD processing loop to deal with the final elements without overflowing the allocated buffer.
You must free this memory with SDL_FreeSIMD(), not free() or SDL_free() or delete[], etc.
Note that SDL will only deal with SIMD instruction sets it is aware of; for example, SDL 2.0.8 knows that SSE wants 16-byte vectors (SDL_HasSSE()), and AVX2 wants 32 bytes (SDL_HasAVX2()), but doesn't know that AVX-512 wants 64. To be clear: if you can't decide to use an instruction set with an SDL_Has*() function, don't use that instruction set with memory allocated through here.
SDL_AllocSIMD(0) will return a non-NULL pointer, assuming the system isn't out of memory.
| len | The length, in bytes, of the block to allocated. The actual allocated block might be larger due to padding, etc. |
Definition at line 957 of file SDL_cpuinfo.c.
References NULL, ptr, retval, SDL_malloc, and SDL_SIMDGetAlignment().
Deallocate memory obtained from SDL_SIMDAlloc.
It is not valid to use this function on a pointer from anything but SDL_SIMDAlloc(). It can't be used on pointers from malloc, realloc, SDL_malloc, memalign, new[], etc.
However, SDL_SIMDFree(NULL) is a legal no-op.
Definition at line 1026 of file SDL_cpuinfo.c.
Report the alignment this system needs for SIMD allocations.
This will return the minimum number of bytes to which a pointer must be aligned to be compatible with SIMD instructions on the current machine. For example, if the machine supports SSE only, it will return 16, but if it supports AVX-512F, it'll return 64 (etc). This only reports values for instruction sets SDL knows about, so if your SDL build doesn't have SDL_HasAVX512F(), then it might return 16 for the SSE support it sees and not 64 for the AVX-512 instructions that exist but SDL doesn't know about. Plan accordingly.
Definition at line 947 of file SDL_cpuinfo.c.
References SDL_assert, SDL_GetCPUFeatures(), and SDL_SIMDAlignment.
Referenced by SDL_SIMDAlloc(), and SDL_SIMDRealloc().
Reallocate memory obtained from SDL_SIMDAlloc.
It is not valid to use this function on a pointer from anything but SDL_SIMDAlloc(). It can't be used on pointers from malloc, realloc, SDL_malloc, memalign, new[], etc.
| mem | The pointer obtained from SDL_SIMDAlloc. This function also accepts NULL, at which point this function is the same as calling SDL_realloc with a NULL pointer. |
| len | The length, in bytes, of the block to allocated. The actual allocated block might be larger due to padding, etc. Passing 0 will return a non-NULL pointer, assuming the system isn't out of memory. |
Definition at line 974 of file SDL_cpuinfo.c.
References NULL, ptr, retval, SDL_memmove, SDL_realloc, and SDL_SIMDGetAlignment().
|
static |
Definition at line 272 of file SDL_cpuinfo.c.
Referenced by CPU_calcCPUIDFeatures().
|
static |
Definition at line 273 of file SDL_cpuinfo.c.
Referenced by CPU_calcCPUIDFeatures(), CPU_have3DNow(), CPU_haveAVX2(), CPU_haveAVX512F(), and SDL_GetCPUType().
Definition at line 274 of file SDL_cpuinfo.c.
Referenced by CPU_calcCPUIDFeatures(), and CPU_haveAVX2().
Definition at line 275 of file SDL_cpuinfo.c.
Referenced by CPU_calcCPUIDFeatures(), and CPU_haveAVX512F().
|
static |
Definition at line 559 of file SDL_cpuinfo.c.
Referenced by SDL_GetCPUCount().
|
static |
Definition at line 729 of file SDL_cpuinfo.c.
Referenced by SDL_GetCPUFeatures().
|
static |
Definition at line 730 of file SDL_cpuinfo.c.
Referenced by SDL_GetCPUFeatures(), and SDL_SIMDGetAlignment().
|
static |
Definition at line 883 of file SDL_cpuinfo.c.
Referenced by SDL_GetSystemRAM().