| 147 | #error "megdnn at least needs sse2, please compile with -msse2 or higher" |
| 148 | #endif |
| 149 | bool x86::is_supported(SIMDType type) { |
| 150 | if (type >= disabled_simd_type_thresh) |
| 151 | return false; |
| 152 | |
| 153 | switch (type) { |
| 154 | case SIMDType::SSE: |
| 155 | return bit(cpuid.edx, 25); |
| 156 | case SIMDType::SSE2: |
| 157 | return bit(cpuid.edx, 26); |
| 158 | case SIMDType::SSE3: |
| 159 | return bit(cpuid.ecx, 0); |
| 160 | case SIMDType::SSE4_1: |
| 161 | return bit(cpuid.ecx, 19); |
| 162 | case SIMDType::SSE4_2: |
| 163 | return bit(cpuid.ecx, 20); |
| 164 | case SIMDType::AVX: |
| 165 | return is_avx_supported; |
| 166 | case SIMDType::FMA: |
| 167 | return is_fma_supported; |
| 168 | case SIMDType::AVX2: |
| 169 | return is_avx2_supported; |
| 170 | case SIMDType::VNNI: |
| 171 | return is_vnni_supported; |
| 172 | default: |
| 173 | break; |
| 174 | } |
| 175 | megdnn_throw("unknown cpu feature"); |
| 176 | } |
| 177 | |
| 178 | void x86::disable_simd_type(SIMDType type) { |
| 179 | disabled_simd_type_thresh = type; |