41 #include "CAVectorUnit.h"
44 #include <sys/sysctl.h>
50 int gCAVectorUnitType = kVecUninitialized;
55 static SInt32 IsSSE2Available()
67 return_value = (r_edx >> 26) & 0x1;
74 static SInt32 IsSSE3Available()
86 return_value = r_ecx & 0x1;
94 static bool IsCpuidAvailable()
96 SInt32 return_value = 0x0;
107 je end_cpuid_identify ;
108 mov return_value, 0x1;
117 SInt32 CAVectorUnit_Examine()
119 int result = kVecNone;
125 int status = ippStaticInit();
126 if ( status == ippStsNonIntelCpu )
128 IppCpuType cpuType = ippGetCpuType();
129 if ( cpuType >= ippCpuSSE || cpuType <= ippCpuSSE42 )
130 ippStaticInitCpu( cpuType );
136 if (IsCpuidAvailable())
138 if(IsSSE3Available())
142 else if(IsSSE2Available())
150 if (getenv(
"CA_NoVector")) {
151 fprintf(stderr,
"CA_NoVector set; Vector unit optimized routines will be bypassed\n");
157 #if (TARGET_CPU_PPC || TARGET_CPU_PPC64)
158 int sels[2] = { CTL_HW, HW_VECTORUNIT };
160 size_t length =
sizeof(vType);
161 int error = sysctl(sels, 2, &vType, &length, NULL, 0);
162 if (!error && vType > 0)
163 result = kVecAltivec;
164 #elif (TARGET_CPU_X86 || TARGET_CPU_X86_64)
166 size_t length =
sizeof(answer);
167 int error = sysctlbyname(
"hw.optional.sse3", &answer, &length, NULL, 0);
168 if (!error && answer)
172 length =
sizeof(answer);
173 error = sysctlbyname(
"hw.optional.sse2", &answer, &length, NULL, 0);
174 if (!error && answer)
180 gCAVectorUnitType = result;