ashvardanian / SimSIMD

Up to 200x Faster Dot Products & Similarity Metrics ā€” for Python, Rust, C, JS, and Swift, supporting f64, f32, f16 real & complex, i8, and bit vectors using SIMD for both AVX2, AVX-512, NEON, SVE, & SVE2 šŸ“
https://ashvardanian.com/posts/simsimd-faster-scipy/
Apache License 2.0
999 stars 59 forks source link

Is it bug in dynamic dispatch? #136

Closed MBkkt closed 5 months ago

MBkkt commented 5 months ago

Order looks incorrect, SKYLAKE probably should checked before haswell

#if SIMSIMD_TARGET_HASWELL
        if (viable & simsimd_cap_haswell_k)
            switch (kind) {
            case simsimd_metric_dot_k: *m = (m_t)&simsimd_dot_f32c_haswell, *c = simsimd_cap_haswell_k; return;
            case simsimd_metric_vdot_k: *m = (m_t)&simsimd_vdot_f32c_haswell, *c = simsimd_cap_haswell_k; return;
            default: break;
            }
#endif
#if SIMSIMD_TARGET_SKYLAKE
        if (viable & simsimd_cap_skylake_k)
            switch (kind) {
            case simsimd_metric_dot_k: *m = (m_t)&simsimd_dot_f32c_skylake, *c = simsimd_cap_skylake_k; return;
            case simsimd_metric_vdot_k: *m = (m_t)&simsimd_vdot_f32c_skylake, *c = simsimd_cap_skylake_k; return;
            default: break;
            }
#endif
#if SIMSIMD_TARGET_HASWELL
        if (viable & simsimd_cap_haswell_k)
            switch (kind) {
            case simsimd_metric_dot_k: *m = (m_t)&simsimd_dot_f16c_haswell, *c = simsimd_cap_haswell_k; return;
            case simsimd_metric_vdot_k: *m = (m_t)&simsimd_vdot_f16c_haswell, *c = simsimd_cap_haswell_k; return;
            default: break;
            }
#endif
#if SIMSIMD_TARGET_SAPPHIRE
        if (viable & simsimd_cap_sapphire_k)
            switch (kind) {
            case simsimd_metric_dot_k: *m = (m_t)&simsimd_dot_f16c_sapphire, *c = simsimd_cap_sapphire_k; return;
            case simsimd_metric_vdot_k: *m = (m_t)&simsimd_vdot_f16c_sapphire, *c = simsimd_cap_sapphire_k; return;
            default: break;
            }
#endif
ashvardanian commented 5 months ago

You are right! Can you please submit a patch for the main-dev branch?

MBkkt commented 5 months ago

Ok. https://github.com/ashvardanian/SimSIMD/pull/137