Commit 625a1801 by Derek Mauro Committed by Copybara-Service

Require 64-bit builds on x86 to use AcceleratedCrcMemcpyEngine

This also ensures that there is only one definition of
GetArchSpecificEngines by moving the condition to a common place.

PiperOrigin-RevId: 500038304
Change-Id: If0c55d701dfdc11a1a9c8c1b34eb220435529ffb
parent 05109783
...@@ -21,6 +21,13 @@ ...@@ -21,6 +21,13 @@
#include "absl/base/config.h" #include "absl/base/config.h"
#include "absl/crc/crc32c.h" #include "absl/crc/crc32c.h"
// Defined if the class AcceleratedCrcMemcpyEngine exists.
#if defined(__x86_64__) && defined(__SSE4_2__)
#define ABSL_INTERNAL_HAVE_X86_64_ACCELERATED_CRC_MEMCPY_ENGINE 1
#elif defined(_MSC_VER) && defined(__AVX__)
#define ABSL_INTERNAL_HAVE_X86_64_ACCELERATED_CRC_MEMCPY_ENGINE 1
#endif
namespace absl { namespace absl {
ABSL_NAMESPACE_BEGIN ABSL_NAMESPACE_BEGIN
namespace crc_internal { namespace crc_internal {
......
...@@ -54,7 +54,7 @@ absl::crc32c_t FallbackCrcMemcpyEngine::Compute(void* __restrict dst, ...@@ -54,7 +54,7 @@ absl::crc32c_t FallbackCrcMemcpyEngine::Compute(void* __restrict dst,
} }
// Compile the following only if we don't have // Compile the following only if we don't have
#ifndef __SSE4_2__ #ifndef ABSL_INTERNAL_HAVE_X86_64_ACCELERATED_CRC_MEMCPY_ENGINE
CrcMemcpy::ArchSpecificEngines CrcMemcpy::GetArchSpecificEngines() { CrcMemcpy::ArchSpecificEngines CrcMemcpy::GetArchSpecificEngines() {
CrcMemcpy::ArchSpecificEngines engines; CrcMemcpy::ArchSpecificEngines engines;
...@@ -68,7 +68,7 @@ std::unique_ptr<CrcMemcpyEngine> CrcMemcpy::GetTestEngine(int /*vector*/, ...@@ -68,7 +68,7 @@ std::unique_ptr<CrcMemcpyEngine> CrcMemcpy::GetTestEngine(int /*vector*/,
return std::make_unique<FallbackCrcMemcpyEngine>(); return std::make_unique<FallbackCrcMemcpyEngine>();
} }
#endif #endif // ABSL_INTERNAL_HAVE_X86_64_ACCELERATED_CRC_MEMCPY_ENGINE
} // namespace crc_internal } // namespace crc_internal
ABSL_NAMESPACE_END ABSL_NAMESPACE_END
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
#include "absl/crc/internal/crc_memcpy.h" #include "absl/crc/internal/crc_memcpy.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#if defined(__SSE4_2__) || (defined(_MSC_VER) && defined(__AVX__)) #ifdef ABSL_INTERNAL_HAVE_X86_64_ACCELERATED_CRC_MEMCPY_ENGINE
namespace absl { namespace absl {
ABSL_NAMESPACE_BEGIN ABSL_NAMESPACE_BEGIN
...@@ -431,4 +431,4 @@ std::unique_ptr<CrcMemcpyEngine> CrcMemcpy::GetTestEngine(int vector, ...@@ -431,4 +431,4 @@ std::unique_ptr<CrcMemcpyEngine> CrcMemcpy::GetTestEngine(int vector,
ABSL_NAMESPACE_END ABSL_NAMESPACE_END
} // namespace absl } // namespace absl
#endif // defined(__SSE4_2__) || (defined(_MSC_VER) && defined(__AVX__)) #endif // ABSL_INTERNAL_HAVE_X86_64_ACCELERATED_CRC_MEMCPY_ENGINE
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment