/* Copyright (c) 2014, Cisco Systems, INC Written by XiangMingZhu WeiZhou MinPeng YanWang
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
staticvoid cpuid(unsignedint CPUInfo[4], unsignedint InfoType)
{ #ifdefined(CPU_INFO_BY_ASM) #ifdefined(__i386__) && defined(__PIC__) /* %ebx is PIC register in 32-bit, so mustn't clobber it. */
__asm__ __volatile__ ( "xchg %%ebx, %1\n" "cpuid\n" "xchg %%ebx, %1\n": "=a" (CPUInfo[0]), "=r" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3]) : /* We clear ECX to avoid a valgrind false-positive prior to v3.17.0. */ "0" (InfoType), "2" (0)
); #else
__asm__ __volatile__ ( "cpuid": "=a" (CPUInfo[0]), "=b" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3]) : /* We clear ECX to avoid a valgrind false-positive prior to v3.17.0. */ "0" (InfoType), "2" (0)
); #endif #elifdefined(CPU_INFO_BY_C) /* We use __get_cpuid_count to clear ECX to avoid a valgrind false-positive
prior to v3.17.0.*/ if (!__get_cpuid_count(InfoType, 0, &(CPUInfo[0]), &(CPUInfo[1]), &(CPUInfo[2]), &(CPUInfo[3]))) { /* Our function cannot fail, but __get_cpuid{_count} can. Returning all zeroes will effectively disable all SIMD, which is
what we want on CPUs that don't support CPUID. */
CPUInfo[3] = CPUInfo[2] = CPUInfo[1] = CPUInfo[0] = 0;
} #else # error "Configured to use x86 RTCD, but no CPU detection method available. " \ "Reconfigure with --disable-rtcd (or send patches)." #endif
}
#endif
typedefstruct CPU_Feature{ /* SIMD: 128-bit */ int HW_SSE; int HW_SSE2; int HW_SSE41; /* SIMD: 256-bit */ int HW_AVX2;
} CPU_Feature;
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.