Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: SSSE3 #79

Open
easyaspi314 opened this issue Jan 29, 2019 · 3 comments
Open

Question: SSSE3 #79

easyaspi314 opened this issue Jan 29, 2019 · 3 comments

Comments

@easyaspi314
Copy link
Contributor

easyaspi314 commented Jan 29, 2019

HighwayHash can easily be adapted to SSSE3 with only a few changes:

  1. Remove the min, max, and stream functions in vector128.h. We don't use them.
  2. Change V128<uint64_t>::operator== to this:
  // There are no greater-than comparison instructions for unsigned T.
  HH_INLINE V128 operator==(const V128& other) const {
#ifdef __SSE4_1__
    return V128(_mm_cmpeq_epi64(v_, other.v_));
#else 
    // Do a 32-bit equality comparison, then AND the high bits and the low bits. If the
    // vectors are equal, the result will be
    //    0xFFFFFFFFFFFFFFFF & 0xFFFFFFFFFFFFFFFF == 0xFFFFFFFFFFFFFFFF
    // and if not, it will be
    //    0xFFFFFFFF00000000 & 0x00000000FFFFFFFF = 0x0000000000000000
    __m128i cmp = _mm_cmpeq_epi32(v_, other.v_);
    return V128(_mm_and_si128(cmp, _mm_shuffle_epi32(cmp, _MM_SHUFFLE(2, 3, 0, 1))));
#endif
  }
  1. Change the _mm_insert_epi32 in HHStateSSE41::UpdateRemainder to this:
      packetH = V2x64U(_mm_insert_epi16(_mm_insert_epi16(packetH, last4 & 0xFFFF, 6), last4 >> 16, 7));
  1. Change the second _mm_insert_epi32 in HHStateSSE41::XorByShift128Left12 to this:
    const V2x64U sign_bit128(_mm_insert_epi16(zero, 0x8000u, 7));

Done.

If we add it, the only issue I see is what do we name it, and what do we do with the SSE41 target?

@jan-wassenberg
Copy link
Member

@easyaspi314
These look like reasonable workarounds, we could rely on #if inside the same file, but generally we are targeting SSE4.1 as a minimum baseline (Penryn was launched in 2008). Can you help me understand if/why SSSE3 support is required?

@johnplatts
Copy link
Contributor

simdhwyhash, which is an implementation of the HighwayHash algorithm that uses the Google Highway library, supports some additional SIMD targets such as SSE2, SSSE3, AVX3 (AVX512F+AVX512CD+AVX512VL+AVX512BW+AVX512DQ), RVV, SVE, and Z14.

The simdhwyhash implementation can be found at https://github.com/johnplatts/simdhwyhash.

@jan-wassenberg
Copy link
Member

I warmly endorse @johnplatts's simdhwyhash implementation :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants