Skip to content

How to Vectorize C++20 Transcendental Std Math Functions? #52

Description

@ax3l

Hi @mattkretz,

Our physics modeling in ImpactX uses a lot of trigonometric and generally transcendental functions like sin, cos, sinh, cosh, exp, pow, etc.

What is the status from your end for vectorizing them in vir-simd / ISO C++?
I read online and tested that auto-vectorizers are very good at this now, but I see no vectorization being picked up for them for my std::simd/vir-simd code written, and fallbacks to scalar ops.

Being so far only able to use C++20, I am exploring drafts (hacks?) like this (#53) right now (used here and here), but I was of course hoping vir-simd can solve this for physics-heavy code? :) Even on AVX2, this gives me a 2.37x speed-up in real-world use cases that we need, instead of mid-SIMD path unwrapping and sequentially solving the heavy math I came to use SIMD for.

I was also made aware that C++26 has vectorized these math functions now (?):

but I will need to get this into our C++20 code base and can maybe in 2-4 years switch to C++26 compilers due to HPC systems and large community stacks being slower (HPC systems in DOE, Helmholtz, Conda-Forge, etc.). What's the best way to pull in the vectorized transcendental math for now?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions