Fix use of crc32c 3way on portable builds using MSVC (#10667)

Summary:
Hello,
As discussed previously in this [discussion](https://github.com/facebook/rocksdb/pull/9680#discussion_r853105163), the mentioned PR introduced a regression in portable versions that compile with MSVC - crc_3way optimization won't be used even in cases where it is supported.

This PR aims to fix just that.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/10667

Reviewed By: akankshamahajan15

Differential Revision: D40644592

Pulled By: ajkr

fbshipit-source-id: dadbeb10d57c19800e74288258ec3b96095557dd
main
Daniel Engel 2 years ago committed by Facebook GitHub Bot
parent b8de2291ad
commit 55d58d91e7
  1. 4
      CMakeLists.txt
  2. 2
      util/crc32c.cc

@ -250,6 +250,8 @@ option(FORCE_SSE42 "force building with SSE4.2, even when PORTABLE=ON" OFF)
option(FORCE_AVX "force building with AVX, even when PORTABLE=ON" OFF) option(FORCE_AVX "force building with AVX, even when PORTABLE=ON" OFF)
option(FORCE_AVX2 "force building with AVX2, even when PORTABLE=ON" OFF) option(FORCE_AVX2 "force building with AVX2, even when PORTABLE=ON" OFF)
if(PORTABLE) if(PORTABLE)
add_definitions(-DROCKSDB_PORTABLE)
# MSVC does not need a separate compiler flag to enable SSE4.2; if nmmintrin.h # MSVC does not need a separate compiler flag to enable SSE4.2; if nmmintrin.h
# is available, it is available by default. # is available, it is available by default.
if(FORCE_SSE42 AND NOT MSVC) if(FORCE_SSE42 AND NOT MSVC)
@ -292,7 +294,6 @@ if(NOT MSVC)
set(CMAKE_REQUIRED_FLAGS "-msse4.2 -mpclmul") set(CMAKE_REQUIRED_FLAGS "-msse4.2 -mpclmul")
endif() endif()
if (NOT PORTABLE OR FORCE_SSE42)
CHECK_CXX_SOURCE_COMPILES(" CHECK_CXX_SOURCE_COMPILES("
#include <cstdint> #include <cstdint>
#include <nmmintrin.h> #include <nmmintrin.h>
@ -311,7 +312,6 @@ int main() {
elseif(FORCE_SSE42) elseif(FORCE_SSE42)
message(FATAL_ERROR "FORCE_SSE42=ON but unable to compile with SSE4.2 enabled") message(FATAL_ERROR "FORCE_SSE42=ON but unable to compile with SSE4.2 enabled")
endif() endif()
endif()
# Check if -latomic is required or not # Check if -latomic is required or not
if (NOT MSVC) if (NOT MSVC)

@ -1167,7 +1167,7 @@ static inline Function Choose_Extend() {
#else #else
if (isSSE42()) { if (isSSE42()) {
if (isPCLMULQDQ()) { if (isPCLMULQDQ()) {
#if defined HAVE_SSE42 && defined HAVE_PCLMUL && !defined NO_THREEWAY_CRC32C #if (defined HAVE_SSE42 && defined HAVE_PCLMUL) && !defined NO_THREEWAY_CRC32C
return crc32c_3way; return crc32c_3way;
#else #else
return ExtendImpl<Fast_CRC32>; // Fast_CRC32 will check HAVE_SSE42 itself return ExtendImpl<Fast_CRC32>; // Fast_CRC32 will check HAVE_SSE42 itself

Loading…
Cancel
Save