From: Stephen Chen Date: Tue, 16 May 2017 17:06:47 +0000 (-0700) Subject: gate sse42 implementation of checksum for x86 only X-Git-Tag: v2017.05.22.00~13 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=1a1ce79ed7c22c3227c17fe797bd6213e4e4ef11 gate sse42 implementation of checksum for x86 only Summary: folly/detail/ChecksumDetail.h gets included in Checksum.h and it unconditionally includes . This doesn't compile on aarch64 platform. Add #ifdefs for this. Reviewed By: yfeldblum Differential Revision: D5048636 fbshipit-source-id: d2074eb1b01487b02d95f3e2eebe683237d918fe --- diff --git a/folly/Checksum.cpp b/folly/Checksum.cpp index cbc99913..4e5f7768 100644 --- a/folly/Checksum.cpp +++ b/folly/Checksum.cpp @@ -21,7 +21,7 @@ #include #include -#if FOLLY_X64 && (__SSE4_2__ || defined(__clang__) || __GNUC_PREREQ(4, 9)) +#if FOLLY_SSE_PREREQ(4, 2) #include #endif @@ -31,7 +31,7 @@ namespace detail { uint32_t crc32c_sw(const uint8_t* data, size_t nbytes, uint32_t startingChecksum); -#if FOLLY_X64 && (__SSE4_2__ || defined(__clang__) || __GNUC_PREREQ(4, 9)) +#if FOLLY_SSE_PREREQ(4, 2) // Fast SIMD implementation of CRC-32C for x86 with SSE 4.2 FOLLY_TARGET_ATTRIBUTE("sse4.2") @@ -111,6 +111,11 @@ uint32_t crc32c_hw(const uint8_t *data, size_t nbytes, throw std::runtime_error("crc32_hw is not implemented on this platform"); } +uint32_t crc32_hw(const uint8_t *data, size_t nbytes, + uint32_t startingChecksum) { + throw std::runtime_error("crc32_hw is not implemented on this platform"); +} + bool crc32c_hw_supported() { return false; } diff --git a/folly/detail/ChecksumDetail.cpp b/folly/detail/ChecksumDetail.cpp index 4d1a9c02..7a1f5923 100644 --- a/folly/detail/ChecksumDetail.cpp +++ b/folly/detail/ChecksumDetail.cpp @@ -115,6 +115,8 @@ namespace folly { namespace detail { +#if FOLLY_SSE_PREREQ(4, 2) + uint32_t crc32_hw_aligned(uint32_t remainder, const __m128i* p, size_t vec_count) { /* Constants precomputed by gen_crc32_multipliers.c. Do not edit! */ @@ -269,5 +271,7 @@ _128_bits_at_a_time: x0 = _mm_clmulepi64_si128(_mm_and_si128(x0, mask32), barrett_reduction_constants, 0x10); return _mm_cvtsi128_si32(_mm_srli_si128(_mm_xor_si128(x0, x1), 4)); } + +#endif } } // namespace diff --git a/folly/detail/ChecksumDetail.h b/folly/detail/ChecksumDetail.h index 97ad4519..05a6f22c 100644 --- a/folly/detail/ChecksumDetail.h +++ b/folly/detail/ChecksumDetail.h @@ -16,7 +16,12 @@ #pragma once +#include + +#if FOLLY_SSE_PREREQ(4, 2) #include +#endif + #include #include @@ -68,8 +73,10 @@ uint32_t crc32c_sw(const uint8_t* data, size_t nbytes, uint32_t crc32_hw(const uint8_t* data, size_t nbytes, uint32_t startingChecksum = ~0U); +#if FOLLY_SSE_PREREQ(4, 2) uint32_t crc32_hw_aligned(uint32_t remainder, const __m128i* p, size_t vec_count); +#endif /** * Check whether a hardware-accelerated CRC-32 implementation is