Giter Club home page Giter Club logo

Comments (3)

luoming17 avatar luoming17 commented on June 3, 2024

By the way, is there any way to explicit specify which register I want to use in an nsimd::pack?
I means I compile my project with

add_compile_options(-DAVX512_SKYLAKE -DFMA -march=skylake-avx512)

And I have two function. In function A, I want use 512-bits registers, but in function B, I want use 128-bits registers.

from nsimd.

gquintin avatar gquintin commented on June 3, 2024

Hi @luoming17

Horizontal sum

Indeed the addv operator doe snot support integers yet. The reason is that there is two "ways" to do it:

  • saturated horizontal sum
  • standard C horizontal sum (with possible overflows/underflows)

Since then we have decided what to do but did not manage to find time to actually implement it:

  • The addv operator will perform standard C horizontal sum.
  • A new addvs operator will perform saturated horizontal sum.

If you already have implementations, we would really appreciate to include them. You see the documentation on how to add a new operator if you wish.

Use 128-bits registers when compiling for AVX-512

You can of course use 128-bits registers when compiling for AVX/AVX2 or AVX-512:

#include <nsimd/nsimd-all.hpp>

void foo() {
    // Native SIMD register:
    // - __m128 when targeting SSE
    // - __m256 when targeting AVX
    // - __m512 when targeting AVX-512
    nsimd::pack<float> a;

    // __m128 whatever the target is
    nsimd::pack<float, 1, nsimd::sse42> b;
}

Let me however warn you about this. This will make you code non portable. I do not know your use case but maybe what follows will apply to you:

#if defined(NSIMD_X86)
  typedef nsimd::pack<float> pack_t;
  typedef nsimd::pack<float, 1, nsimd::sse2> pack128_t;
#if defined(NSIMD_ARM)
  #if NSIMD_WORD_SIZE == 32
    typedef nsimd::pack<float> pack_t;
    typedef nsimd::pack<float, 1, nsimd::neon128> pack128_t;
  #else
    typedef nsimd::pack<float> pack_t;
    typedef nsimd::pack<float, 1, nsimd::aarch64> pack128_t;
  #endif
#else
  #error "Unsupported architecture"
#endif

This is not the first time we see this kind of demand. When we worked on GROMACS we add to write something like the above because GROMACS needs a 128-bits SIMD type. Maybe we should think of adding this into NSIMD. I have not though about this so I do not know if it is wise or not.

from nsimd.

luoming17 avatar luoming17 commented on June 3, 2024

Thank you, I have solved my problem.

from nsimd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.