Skip to content

Commit

Permalink
Fix: Detecting Ice Lake
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvardanian committed Mar 24, 2024
1 parent c85e098 commit 098cd90
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
14 changes: 12 additions & 2 deletions cpp/bench.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,29 @@ void vdot_f64c_blas(simsimd_f64_t const* a, simsimd_f64_t const* b, simsimd_size
#endif

int main(int argc, char** argv) {
simsimd_capability_t runtime_caps = simsimd_capabilities();

// Log supported functionality
char const* flags[2] = {"false", "true"};
std::printf("Benchmarking Similarity Measures\n");
std::printf("- Compiler supports F16: %s\n", flags[SIMSIMD_NATIVE_F16]);
std::printf("- Benchmark against CBLAS: %s\n", flags[SIMSIMD_BUILD_BENCHMARKS_WITH_CBLAS]);
std::printf("\n");
std::printf("Compile-time settings:\n");
std::printf("- Arm NEON support enabled: %s\n", flags[SIMSIMD_TARGET_NEON]);
std::printf("- Arm SVE support enabled: %s\n", flags[SIMSIMD_TARGET_SVE]);
std::printf("- x86 Haswell support enabled: %s\n", flags[SIMSIMD_TARGET_HASWELL]);
std::printf("- x86 Skylake support enabled: %s\n", flags[SIMSIMD_TARGET_SKYLAKE]);
std::printf("- x86 Ice Lake support enabled: %s\n", flags[SIMSIMD_TARGET_ICE]);
std::printf("- x86 Sapphire Rapids support enabled: %s\n", flags[SIMSIMD_TARGET_SAPPHIRE]);
std::printf("- Compiler supports F16: %s\n", flags[SIMSIMD_NATIVE_F16]);
std::printf("- Benchmark against CBLAS: %s\n", flags[SIMSIMD_BUILD_BENCHMARKS_WITH_CBLAS]);
std::printf("\n");
std::printf("Run-time settings:\n");
std::printf("- Arm NEON support enabled: %s\n", flags[(runtime_caps & simsimd_cap_neon_k) != 0]);
std::printf("- Arm SVE support enabled: %s\n", flags[(runtime_caps & simsimd_cap_sve_k) != 0]);
std::printf("- x86 Haswell support enabled: %s\n", flags[(runtime_caps & simsimd_cap_haswell_k) != 0]);
std::printf("- x86 Skylake support enabled: %s\n", flags[(runtime_caps & simsimd_cap_skylake_k) != 0]);
std::printf("- x86 Ice Lake support enabled: %s\n", flags[(runtime_caps & simsimd_cap_ice_k) != 0]);
std::printf("- x86 Sapphire Rapids support enabled: %s\n", flags[(runtime_caps & simsimd_cap_sapphire_k) != 0]);
std::printf("\n");

// Run the benchmarks
Expand Down
19 changes: 10 additions & 9 deletions include/simsimd/simsimd.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,19 @@ SIMSIMD_PUBLIC simsimd_capability_t simsimd_capabilities(void) {
// Check for AVX512F (Function ID 7, EBX register)
// https://github.com/llvm/llvm-project/blob/50598f0ff44f3a4e75706f8c53f3380fe7faa896/clang/lib/Headers/cpuid.h#L155
unsigned supports_avx512f = (info7.named.ebx & 0x00010000) != 0;
unsigned supports_avx512ifma = (info7.named.ebx & 0x00200000) != 0;
// Check for AVX512FP16 (Function ID 7, EDX register)
// https://github.com/llvm/llvm-project/blob/50598f0ff44f3a4e75706f8c53f3380fe7faa896/clang/lib/Headers/cpuid.h#L198C9-L198C23
unsigned supports_avx512fp16 = (info7.named.edx & 0x00800000) != 0;
// Check for VPOPCNTDQ (Function ID 1, ECX register)
// https://github.com/llvm/llvm-project/blob/50598f0ff44f3a4e75706f8c53f3380fe7faa896/clang/lib/Headers/cpuid.h#L182C30-L182C40
unsigned supports_avx512vpopcntdq = (info1.named.ecx & 0x00004000) != 0;
unsigned supports_avx512vbmi2 = (info1.named.ecx & 0x00000040) != 0;
// Check for VNNI (Function ID 1, ECX register)
// https://github.com/llvm/llvm-project/blob/50598f0ff44f3a4e75706f8c53f3380fe7faa896/clang/lib/Headers/cpuid.h#L180
unsigned supports_avx512vnni = (info1.named.ecx & 0x00000800) != 0;
unsigned supports_avx512bitalg = (info1.named.ecx & 0x00001000) != 0;
// Check for AVX512VNNI (Function ID 7, ECX register)
unsigned supports_avx512vnni = (info7.named.ecx & 0x00000800) != 0;
// Check for AVX512IFMA (Function ID 7, EBX register)
unsigned supports_avx512ifma = (info7.named.ebx & 0x00200000) != 0;
// Check for AVX512BITALG (Function ID 7, ECX register)
unsigned supports_avx512bitalg = (info7.named.ecx & 0x00001000) != 0;
// Check for AVX512VBMI2 (Function ID 7, ECX register)
unsigned supports_avx512vbmi2 = (info7.named.ecx & 0x00000040) != 0;
// Check for AVX512VPOPCNTDQ (Function ID 7, ECX register)
unsigned supports_avx512vpopcntdq = (info7.named.ecx & 0x00004000) != 0;

// Convert specific features into CPU generations
unsigned supports_haswell = supports_avx2 && supports_f16c && supports_fma;
Expand Down

0 comments on commit 098cd90

Please sign in to comment.