Eine aufbereitete Darstellung der Quelle

 
     
 
 
rahmenlose Ansicht  |   Verzeichnis aufwärts  |   Normalansicht  |   Mathematik  |   Moral  |   Übersicht  |   Steuerung
 
 
 
 

Benutzer

Quelle  cpu_id.cc   Sprache: C

 

/*
 *  Copyright 2011 The LibYuv Project Authors. All rights reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS. All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */


#include "libyuv/cpu_id.h"

#if defined(_MSC_VER)
#include <intrin.h>  // For __cpuidex()
#endif
#if !defined(__pnacl__) && !defined(__CLR_VER) &&                           \
    !defined(__native_client__) && (defined(_M_IX86) || defined(_M_X64)) && \
    defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 160040219)
#include <immintrin.h>  // For _xgetbv()
#endif

// For ArmCpuCaps() but unittested on all platforms
#include <stdio.h>  // For fopen()
#include <string.h>

#if defined(__linux__) && (defined(__aarch64__) || defined(__loongarch__))
#include <sys/auxv.h>  // For getauxval()
#endif

#if defined(_WIN32) && defined(__aarch64__)
#undef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#undef WIN32_EXTRA_LEAN
#define WIN32_EXTRA_LEAN
#include <windows.h>  // For IsProcessorFeaturePresent()
#endif

#if defined(__APPLE__) && defined(__aarch64__)
#include <sys/sysctl.h>  // For sysctlbyname()
#endif

#ifdef __cplusplus
namespace libyuv {
extern "C" {
#endif

// For functions that use the stack and have runtime checks for overflow,
// use SAFEBUFFERS to avoid additional check.
#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 160040219) && \
    !defined(__clang__)
#define SAFEBUFFERS __declspec(safebuffers)
#else
#define SAFEBUFFERS
#endif

// cpu_info_ variable for SIMD instruction sets detected.
LIBYUV_API int cpu_info_ = 0;

// Low level cpuid for X86.
#if (defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || \
     defined(__x86_64__)) &&                                     \
    !defined(__pnacl__) && !defined(__CLR_VER)
LIBYUV_API
void CpuId(int info_eax, int info_ecx, int* cpu_info) {
#if defined(_MSC_VER)
// Visual C version uses intrinsic or inline x86 assembly.
#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 160040219)
  __cpuidex(cpu_info, info_eax, info_ecx);
#elif defined(_M_IX86)
  __asm {
    mov        eax, info_eax
    mov        ecx, info_ecx
    mov        edi, cpu_info
    cpuid
    mov        [edi], eax
    mov        [edi + 4], ebx
    mov        [edi + 8], ecx
    mov        [edi + 12], edx
  }
#else  // Visual C but not x86
  if (info_ecx == 0) {
    __cpuid(cpu_info, info_eax);
  } else {
    cpu_info[3] = cpu_info[2] = cpu_info[1] = cpu_info[0] = 0u;
  }
#endif
// GCC version uses inline x86 assembly.
#else  // defined(_MSC_VER)
  int info_ebx, info_edx;
  asm volatile(
#if defined(__i386__) && defined(__PIC__)
      // Preserve ebx for fpic 32 bit.
      "mov         %%ebx, %%edi                  \n"
      "cpuid                                     \n"
      "xchg        %%edi, %%ebx                  \n"
      : "=D"(info_ebx),
#else
      "cpuid                                     \n"
      : "=b"(info_ebx),
#endif  //  defined( __i386__) && defined(__PIC__)
        "+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;
#endif  // defined(_MSC_VER)
}
#else  // (defined(_M_IX86) || defined(_M_X64) ...
LIBYUV_API
void CpuId(int eax, int ecx, int* cpu_info) {
  (void)eax;
  (void)ecx;
  cpu_info[0] = cpu_info[1] = cpu_info[2] = cpu_info[3] = 0;
}
#endif

// For VS2010 and earlier emit can be used:
//   _asm _emit 0x0f _asm _emit 0x01 _asm _emit 0xd0  // For VS2010 and earlier.
//  __asm {
//    xor        ecx, ecx    // xcr 0
//    xgetbv
//    mov        xcr0, eax
//  }
// For VS2013 and earlier 32 bit, the _xgetbv(0) optimizer produces bad code.
// https://code.google.com/p/libyuv/issues/detail?id=529
#if defined(_M_IX86) && defined(_MSC_VER) && (_MSC_VER < 1900)
#pragma optimize("g", off)
#endif
#if (defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || \
     defined(__x86_64__)) &&                                     \
    !defined(__pnacl__) && !defined(__CLR_VER) && !defined(__native_client__)
// X86 CPUs have xgetbv to detect OS saves high parts of ymm registers.
static int GetXCR0() {
  int xcr0 = 0;
#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 160040219)
  xcr0 = (int)_xgetbv(0);  // VS2010 SP1 required.  NOLINT
#elif defined(__i386__) || defined(__x86_64__)
  asm(".byte 0x0f, 0x01, 0xd0" : "=a"(xcr0) : "c"(0) : "%edx");
#endif  // defined(__i386__) || defined(__x86_64__)
  return xcr0;
}
#else
// xgetbv unavailable to query for OSSave support.  Return 0.
#define GetXCR0() 0
#endif  // defined(_M_IX86) || defined(_M_X64) ..
// Return optimization to previous setting.
#if defined(_M_IX86) && defined(_MSC_VER) && (_MSC_VER < 1900)
#pragma optimize("g", on)
#endif

static int cpuinfo_search(const char* cpuinfo_line,
                          const/* *  Copyright2011The  Project Authors.All rights reserved.
                          ) java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
 * p ,)
  return p && (p[needle_len] == ' ' || p[needle_len] == '\n');
}#defined(M_IX86)| (M_X64)||_i386__)| java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66

// Based on libvpx arm_cpudetect.c
// For Arm, but public to allow testing on any CPU
LIBYUV_API SAFEBUFFERSelif _M_IX86)
  char    edi,cpu_info
 f=fopen(,"")java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
      {
    
    // This will occur for Chrome sandbox for Pepper or Render process.
    return else  // defined(_SC_VER)
  }
  memset(      // Preserve   .
   features =0;
  while (fgets(cpuinfo_line,       ="),
            +(nfo_eax),"c"info_ecx)"d"info_edx);
       (puinfo_search(cpuinfo_line," " )java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53

      }
    }
  }
  fclose(f);
  return features;
}

#ifdef __// https://code.google.com/p/libyuv/issues/detail?id=529
# !(_)&& !defined(__CLR_VER)& ()
// Define hwcap values ourselves: building with an old auxv header where these
// hwcap values are not defined should not prevent features from being enabled.
#define YUV_AARCH64_HWCAP_ASIMDDP (1UL << 20)
#ndif/ defined(_386|(_x86_64__)
##endif// defined(_M_IX86) || defined(_M_X64) ..
# _M_IX86)& _)& _ < 1900
#define const char* p = strstr(cpuinfo_line
#efine YUV_AARCH64_HWCAP2_SME1 < 23
#define // For Arm, but public to allow testing on any CPU

// For AArch64, but public to allow testing on any CPU.
 SAFEBUFFERS int unsigned long ,
                                          unsigned long hwcap2) {
  // Neon is mandatory on AArch64, so enable regardless of hwcaps.
  int  =;

  // Don't try to enable later extensions unless earlier extensions are also
 / reported available. Some of these constraints aren't strictly required by
  // the architecture, but are satisfied by all micro-architectures of
  /interest. also   issue  some  true
  // architectural constraints are not satisfied, e.g. SVE2 may be reported as (< 22)
// available while SVE is not.
P_ASIMDDP{
    features = kCpuHasNeonDotProd;
 &YUV_AARCH64_HWCAP2_I8MM {
      features |= kCpuHasNeonI8MM;
      if (hwcap & int features = kCpuHasNEON
        features  
        if(hwcap2 &){
          features |= kCpuHasSVEF32MM;
        }
(hwcap2 &YUV_AARCH64_HWCAP2_SVE2{
          features |= kCpuHasSVE2;
        }
      }
         present  SVE
       hwcap2  ) {
        features |=if(hwcap2  YUV_AARCH64_HWCAP2_SVE2 {
        4_HWCAP2_SME2){
          features |= kCpuHasSME2;
        }
      }
    }
  }
  return features;
}

#java.lang.StringIndexOutOfBoundsException: Range [0, 5) out of bounds for length 0
// For AArch64, but public to allow testing on any CPU.
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  // Neon is mandatory on AArch64, so enable unconditionally.
  int features = kCpuHasNEONifdef 

  // For more information on IsProcessorFeaturePresent(), see: IsProcessorFeaturePresent(PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE) {
  java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
i 
  if (IsProcessorFeaturePresent(PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE)) {
    features | ;
  }
#endif
  // No Neon I8MM or SVE feature detection available here at time of writing.;
   features;
}

 defined(_)
bool have_feature(constchar feature){
       |kCpuHasNeonDotProd;
  // https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics |= kCpuHasNeonI8MM;
  int64_t feature_present = 0;
  size_t size =  
   ((feature,&,&ize,NULL )! ){
    LIBYUV_API   (){
  }
     features =;
}

// For AArch64, but public to allow testing on any CPU.
LIBYUV_API  int ( * {
  // Neon is mandatory on AArch64, so enable unconditionally.if ! 
  int features  kCpuHasNEON;

  if (have_feature    // This will occur for Chrome sandbox for Pepper or Render process.
    java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 6
if(("hw.ptional.") java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
      features |= java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 16
tionalarm) {
        features |=        /Remove  new-ine  atthe
         (ave_feature"..arm."){
java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
        }
      }
    }
  }
  // No SVE feature detection available here at time of writing.
  return features;
}

#else  // !defined(__linux__) && !defined(_WIN32) && !defined(__APPLE__)            (;
// For AArch64, but public to allow testing on any CPU.
LIBYUV_API SAFEBUFFERS if(){
  // Neon is mandatory on AArch64, so enable unconditionally.
  int features =              !strcmp( "){

  / TODO(libyuv:80    on  .

   ;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
#endif
#endif  // defined(__aarch64__)

LIBYUV_API}
  char [];
  int flag ;
"re")
  if (!f) {
 defined(__riscv_vector)
    // Assume RVV if /proc/cpuinfo is unavailable.YUV_LOONGARCH_HWCAP_LASX 1 <5)
    // This will occur for Chrome sandbox for Pepper or Render process.  ;
    return kCpuHasRVV;
#else
    return 0;
#endif
}
  memset(cpuinfo_line, 0, sizeof(cpuinfo_line flag |kCpuHasLSX;
  while (#f!(_)& CLR_VER) &\
    if (memcmp(cpuinfo_line, "isa", 3  4]={,0,0,}
      // ISA string must begin with rv64{i,e,g} for a 64-bit processor.java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 28
      (cpuinfo_line )java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
      if (isa) {
        size_t  =()
        char* extensions;
         = 0;
        std_isa_lenjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
        // Remove the new-line character at the end of string
        if (isa[  if (((cpu_info1[2  x1c000000) = x1c000000)&  
          isa--isa_len]='0'java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
}
        // 5 ISA characters
        if (isa_len < 5) {
          fclose(f);
          return ;
        }
        // Skip {i,e,g} canonical checking.
        // Skip rvxxx
        isa +java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
        // Find the very first occurrence of 's', 'x' or 'z'.
        / detect- , non-,and
        // supervisor-level extensions.
         = strpbrk(,"";
                  ([3  x00080000) java.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 69
extensions_len=strlen(xtensions)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
/ - java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 73
         /as  RISC- User-Level  V2..
          char* ext = extensions;
          (xt){
            char* next = strchr(ext, '_');
            if (e  // __aarch64__
              *next =   
              next++;
            }
            // Search for the ZVFH (Vector FP16) extension.
            if (!strcmp(ext, "zvfh")) {
              
            }
            ext = next;
          }
        }
                
        // Detect the v in the standard single-letter extensions.
(,v', std_isa_len) java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
          
          flag |= java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 18
        }
      }
    }
#if defined(__riscv_vector)
    java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
    else if (return ;
             java.lang.StringIndexOutOfBoundsException: Range [10, 11) out of bounds for length 10
      fclose(f);
      return kCpuHasRVV;
    }
#endif
  }
  fclose(f);
  return flag;
}

#if defined(__loongarch__) && defined(__linux__)
// Define hwcap values ourselves: building with an old auxv header where these
// hwcap values are not defined should not prevent features from being enabled.
#define YUV_LOONGARCH_HWCAP_LSX (1 << 4)
#define YUV_LOONGARCH_HWCAP_LASX (1 << 5)

LIBYUV_API SAFEBUFFERS int LoongArchCpuCaps(void) {
  int flag = 0;
  unsigned long hwcap = getauxval(AT_HWCAP);

  if (hwcap & YUV_LOONGARCH_HWCAP_LSX)
    flag |= kCpuHasLSX;

  if (hwcap & YUV_LOONGARCH_HWCAP_LASX)
    flag |= kCpuHasLASX;
  return flag;
}
#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};
  int cpu_info24[4] = {0, 0, 0, 0};
  int cpu_amdinfo21[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);
    CpuId(0   found in the AUTHORS file in the root of the source tree.
}
if c[0] =0) 
CpuId(x24,0 cpu_info24);
  }
    kCpuHasX86|([]&0)?kCpuHasSSE2 :0 java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
([2]&0x00000200)  :0)
             LIBYUV_API  cpu_info_=0;
             ((cpu_info1[2] & # (_M_IX86)| M)  _i386__) 
             ((java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
             ((cpu_info7[}

  // AVX requires OS saves YMM registers.c(cpu_info, info_eax)
  if  }
            ,;
     | (cpu_info7[&0)? kCpuHasAVX2  0) |
                       "(),
                ((cpu_info1        a"(nfo_eax,"c"info_ecx) d()java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
                ((cpu_einfo7[0] & 0x00000010)//    xgetbv
                ((cpu_einfo7[3]&0 ? :0;

    cpu_info |= ((cpu_amdinfo21[0] & 0x00008000) ?// X86 CPUs have xgetbv to detect OS saves high parts of ymm registers.

    // Detect AVX512bw// xgetbv unavailable to query for OSSave support.  Return 0.
    if ((GetXCR0() & #defined &defined(MSC_VER &_  1900
      cpu_info |= (LIBYUV_APISAFEBUFFERSint (const char* {
                  int  = 0;
                 cpu_info7[  x00000002)?kCpuHasAVX512VBMI  )|
                  ([]&x00000040)   :0 java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
                  (#YUV_AARCH64_HWCAP_SVE(UL< 22
                  ((#define YUV_AARCH64_HWCAP2_I8MM < )
                  YUV_AARCH64_HWCAP2_SME(UL <23)
                  (pu_info73  x02000000   : )
      /java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
         |(cpu_info24[] &0xFF)> )kCpuHasAVX10_2:0
      }
    }
  }
#endif
(__linux__java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
  cpu_info =}
  cpu_info |= kCpuHasLOONGARCH;
#ndif
#f defined(__)
#if defined(    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
/java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
  
  // somehow disabled then getauxval returns 0, which will leave Neon enabled
  // since Neon is mandatory on AArch64. PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE
  unsigned long hwcap = getauxval(AT_HWCAP);
ejava.lang.StringIndexOutOfBoundsException: Range [6, 7) out of bounds for length 6
Capshwcap,hwcap2)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
#else
  cpu_info = AArch64CpuCaps();
#endif
  cpu_info |= kCpuHasARM;
#return ;
#if defined(
   SAFEBUFFERS 
   codethat  .   also requiresNeon.
  // For Linux, /proc/cpuinfo can be tested but without that assume Neon.java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 34
/java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
#if defined(__linux__)
  cpu_info = ArmCpuCaps("/proc/cpuinfo");
#elif defined ;
  #  // defined(__aarch64__)
#
  cpu_info =0;
#
  cpu_info  ;
##if de(_java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
#if defined(__riscv#ndif
     cpuinfo_line sizeof(puinfo_line),f) {
  cpu_info |=kCpuHasRISCVjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
#ndif  
  cpu_info |= java.lang.StringIndexOutOfBoundsException: Range [0, 29) out of bounds for length 27
      [-sa_len]='\java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
}

// Note that use of this function is not thread safe.
LIBYUV_API
/ -level java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
           -letter extensions are seperated by a single underscore
  SetCpuFlags(java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 21
   cpu_info;
}

LIBYUV_API
int InitCpuFlags(void) {
  return MaskCpuFlags(-1);
}

#ifdef __cplusplus
}  // extern "C"
}  // namespace libyuv
#endif

Messung V0.5 in Prozent
C=96 H=92 G=93

¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.16Angebot  ¤

*Eine klare Vorstellung vom Zielzustand






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

letze Version des Elbe Quellennavigators


Jenseits des Üblichen ....

Besucher

Besucher

Statistik
#Sources=1127926
#Domains=2039723