/* See if the CPU capabilities are being overridden by the environment */
env = getenv("AOM_SIMD_CAPS"); if (env && *env) return (int)strtol(env, NULL, 0);
// bits 27 (OSXSAVE) & 28 (256-bit AVX) if (FEATURE_SET(reg_ecx, AVX)) { // Check for OS-support of YMM state. Necessary for AVX and AVX2. if ((xgetbv() & 0x6) == 0x6) {
flags |= HAS_AVX; if (max_cpuid_val >= 7) { /* Get the leaf 7 feature flags. Needed to check for AVX2 support */
cpuid(7, 0, reg_eax, reg_ebx, reg_ecx, reg_edx);
flags |= FEATURE_SET(reg_ebx, AVX2) ? HAS_AVX2 : 0; // Check for OS-support of ZMM and YMM state. Necessary for AVX512. // Only set HAS_AVX512 flag if AVX512_DL feature are supported. // Older AVX512 implementations (such as Skylake) have turbo curves that // are currently problematic for mixed AVX512/AVX2 code if ((xgetbv() & 0xe6) == 0xe6) {
flags |=
FEATURE_SET(reg_ebx, AVX512) && FEATURE_SET(reg_ecx, AVX512_DL)
? HAS_AVX512
: 0;
}
}
}
}
(void)reg_eax; // Avoid compiler warning on unused-but-set variable. return flags & mask;
}
// Fine-Grain Measurement Functions // // If you are timing a small region of code, access the timestamp counter // (TSC) via: // // unsigned int start = x86_tsc_start(); // ... // unsigned int end = x86_tsc_end(); // unsigned int diff = end - start; // // The start/end functions introduce a few more instructions than using // x86_readtsc directly, but prevent the CPU's out-of-order execution from // affecting the measurement (by having earlier/later instructions be evaluated // in the time interval). See the white paper, "How to Benchmark Code // Execution Times on Intel(R) IA-32 and IA-64 Instruction Set Architectures" by // Gabriele Paoloni for more information. // // If you are timing a large function (CPU time > a couple of seconds), use // x86_readtsc64 to read the timestamp counter in a 64-bit integer. The // out-of-order leakage that can occur is minimal compared to total runtime. staticinlineunsignedint x86_readtsc(void) { #ifdefined(__GNUC__) unsignedint tsc;
__asm__ __volatile__("rdtsc\n\t" : "=a"(tsc) :); return tsc; #elifdefined(__SUNPRO_C) || defined(__SUNPRO_CC) unsignedint tsc; asmvolatile("rdtsc\n\t" : "=a"(tsc) :); return tsc; #else #if AOM_ARCH_X86_64 return (unsignedint)__rdtsc(); #else
__asm rdtsc; #endif #endif
} // 64-bit CPU cycle counter staticinline uint64_t x86_readtsc64(void) { #ifdefined(__GNUC__)
uint32_t hi, lo;
__asm__ __volatile__("rdtsc" : "=a"(lo), "=d"(hi)); return ((uint64_t)hi << 32) | lo; #elifdefined(__SUNPRO_C) || defined(__SUNPRO_CC)
uint_t hi, lo; asmvolatile("rdtsc\n\t" : "=a"(lo), "=d"(hi)); return ((uint64_t)hi << 32) | lo; #else #if AOM_ARCH_X86_64 return (uint64_t)__rdtsc(); #else
__asm rdtsc; #endif #endif
}
staticinlineunsignedint x87_set_double_precision(void) { unsignedint mode = x87_get_control_word(); // Intel 64 and IA-32 Architectures Developer's Manual: Vol. 1 // https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-vol-1-manual.pdf // 8.1.5.2 Precision Control Field // Bits 8 and 9 (0x300) of the x87 FPU Control Word ("Precision Control") // determine the number of bits used in floating point calculations. To match // later SSE instructions restrict x87 operations to Double Precision (0x200). // Precision PC Field // Single Precision (24-Bits) 00B // Reserved 01B // Double Precision (53-Bits) 10B // Extended Precision (64-Bits) 11B
x87_set_control_word((mode & ~0x300u) | 0x200u); return mode;
}
#ifdef __cplusplus
} // extern "C" #endif
#endif// AOM_AOM_PORTS_X86_H_
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-08-24)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.