1 /* Determine CPU support for SIMD
2  * Copyright 2004 Phil Karn, KA9Q
3  */
4 #include <stdio.h>
5 #include "fec.h"
6 
7 /* Various SIMD instruction set names */
8 char *Cpu_modes[] = {"Unknown","Portable C","x86 Multi Media Extensions (MMX)",
9 		   "x86 Streaming SIMD Extensions (SSE)",
10 		   "x86 Streaming SIMD Extensions 2 (SSE2)",
11 		   "PowerPC G4/G5 Altivec/Velocity Engine"};
12 
13 enum cpu_mode Cpu_mode;
14 
find_cpu_mode(void)15 void find_cpu_mode(void){
16 
17   int f;
18   if(Cpu_mode != UNKNOWN)
19     return;
20 
21   /* Figure out what kind of CPU we have */
22   f = cpu_features();
23   if(f & (1<<26)){ /* SSE2 is present */
24     Cpu_mode = SSE2;
25   } else if(f & (1<<25)){ /* SSE is present */
26     Cpu_mode = SSE;
27   } else if(f & (1<<23)){ /* MMX is present */
28     Cpu_mode = MMX;
29   } else { /* No SIMD at all */
30     Cpu_mode = PORT;
31   }
32   fprintf(stderr,"SIMD CPU detect: %s\n",Cpu_modes[Cpu_mode]);
33 }
34