Ottenere alcune informazioni sulla CPU mediante l'API di Libavutil

Da Gambas-it.org - Wikipedia.
Versione del 31 gen 2016 alle 13:34 di Vuott (Discussione | contributi) (Creata pagina con "Con la libreria '''Libavutil''' è possibile ottenre alcune informazioni sulla CPU. E' necessario aver installato e richiamare in Gambas la libreria inmica condivisa: "''liba...")

(diff) ← Versione meno recente | Versione attuale (diff) | Versione più recente → (diff)

Con la libreria Libavutil è possibile ottenre alcune informazioni sulla CPU.

E' necessario aver installato e richiamare in Gambas la libreria inmica condivisa: "libavutil.so.52.3.0"


Mostriamo un esempio pratico:

Library "libavutil:52.3.0"

' int av_get_cpu_flags(void)
' Return the flags which specify extensions supported by the CPU.
Private Extern av_get_cpu_flags() As Integer


Public Sub Main()
 
 Dim i, i2, c As Integer
 Dim b As Byte
 
  i = av_get_cpu_flags()
  
  While c < &40000000
    i2 = i And c
  
    Select Case i2
      Case 1
        Print "standard MMX"
      Case 2
        Print "SSE integer functions or AMD MMX ext"
      Case 4
        Print "AMD 3DNOW"
      Case 8
        Print "SSE functions"
      Case 16
        Print "PIV SSE2 functions"
      Case 32
        Print "AMD 3DNowExt"
      Case 64
        Print "Prescott SSE3 functions"
      Case 128
        Print "Conroe SSSE3 functions"
      Case 256
        Print "Penryn SSE4.1 functions"
      Case 512
        Print "Nehalem SSE4.2 functions"
      Case 1024
        Print "Bulldozer XOP functions"
      Case 2048
        Print "Bulldozer FMA4 functions"
      Case 4096
        Print "i686 cmov"
      Case 16384
        Print "AVX functions"
      Case 268435456
        Print "Atom processor"
      Case 536870912
        Print "SSE3 supported"
      Case 1073741824
        Print "SSE2 supported"
    End Select
   
    c = 2 ^ b
    Inc b
   
  Wend
  
End



Riferimenti