Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add avx10 detect #250

Open
fbarchard opened this issue Jun 28, 2024 · 0 comments
Open

Add avx10 detect #250

fbarchard opened this issue Jun 28, 2024 · 0 comments

Comments

@fbarchard
Copy link
Contributor

Add AVX10.1 detect

I tested the basic cpuid in libyuv with this logic:

#if defined(_MSC_VER)
#include <intrin.h>  // For __cpuidex()
#endif
static SAFEBUFFERS int GetCpuFlags(void) {
  int cpu_info = 0;
#if !defined(__pnacl__) && !defined(__CLR_VER) &&                   \
    (defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || \
     defined(_M_IX86))
  int cpu_info0[4] = {0, 0, 0, 0};
  int cpu_info1[4] = {0, 0, 0, 0};
  int cpu_info7[4] = {0, 0, 0, 0};
  int cpu_einfo7[4] = {0, 0, 0, 0};
  CpuId(0, 0, cpu_info0);
  CpuId(1, 0, cpu_info1);
  if (cpu_info0[0] >= 7) {
    CpuId(7, 0, cpu_info7);
    CpuId(7, 1, cpu_einfo7);
  }

  // AVX requires OS saves YMM registers.
  if (((cpu_info1[2] & 0x1c000000) == 0x1c000000) &&  // AVX and OSXSave
      ((GetXCR0() & 6) == 6)) {  // Test AVX registers are supports (YMM)
    if ((GetXCR0() & 0xe0) == 0xe0) {   // Test OS saves 32 registers
      cpu_info |= (cpu_einfo7[3] & 0x00080000) ? kCpuHasAVX10 : 0;   /// <---- AVX10
    }
  }

  
 where CpuId wraps the cpuid instruction as inline where necessary
// Low level cpuid for X86.
void CpuId(int info_eax, int info_ecx, int* cpu_info) {
  int info_ebx, info_edx;
  asm volatile(
      "cpuid                                     \n"
      : "=b"(info_ebx),
        "+a"(info_eax), "+c"(info_ecx), "=d"(info_edx));
  cpu_info[0] = info_eax;
  cpu_info[1] = info_ebx;
  cpu_info[2] = info_ecx;
  cpu_info[3] = info_edx;
}

  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant