Update spdk crc32c.c with ARM CRC32 intrinsics

Implement spdk_crc32c_update() with ARM CRC32 intrinsics.

Change-Id: I1daf7f21012aab02290f88a65bbae619eedf5087
Signed-off-by: Richael Zhuang <richael.zhuang@arm.com>
Reviewed-on: https://review.gerrithub.io/c/437218
Reviewed-by: Ziye Yang <optimistyzy@gmail.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Richael Zhuang 2018-12-13 15:24:48 +08:00 committed by Ben Walker
parent e816c8fda8
commit e3910413b2
3 changed files with 41 additions and 3 deletions

View File

@ -45,6 +45,17 @@
extern "C" {
#endif
#if defined(__aarch64__) || defined(__AARCH64__)
#ifdef __ARM_FEATURE_CRC32
#define SPDK_HAVE_ARM_CRC
#include <arm_acle.h>
#endif
#endif
#if defined(__x86_64__) && defined(__SSE4_2__)
#define SPDK_HAVE_SSE4_2
#include <x86intrin.h>
#endif
/**
* IEEE CRC-32 polynomial (bit reflected)
*/

View File

@ -33,8 +33,7 @@
#include "spdk/crc32.h"
#if defined(__x86_64__) && defined(__SSE4_2__)
#include <x86intrin.h>
#ifdef SPDK_HAVE_SSE4_2
uint32_t
spdk_crc32c_update(const void *buf, size_t len, uint32_t crc)
@ -70,7 +69,32 @@ spdk_crc32c_update(const void *buf, size_t len, uint32_t crc)
return crc;
}
#else /* SSE 4.2 (CRC32 instruction) not available */
#elif defined(SPDK_HAVE_ARM_CRC)
uint32_t
spdk_crc32c_update(const void *buf, size_t len, uint32_t crc)
{
size_t count;
count = len / 8;
while (count--) {
uint64_t block;
memcpy(&block, buf, sizeof(block));
crc = __crc32cd(crc, block);
buf += sizeof(block);
}
count = len & 7;
while (count--) {
crc = __crc32cb(crc, *(const uint8_t *)buf);
buf++;
}
return crc;
}
#else /* Neither SSE 4.2 nor ARM CRC32 instructions available */
static struct spdk_crc32_table g_crc32c_table;

View File

@ -81,6 +81,9 @@ endif
ifeq ($(TARGET_MACHINE),x86_64)
COMMON_CFLAGS += -march=native
endif
ifeq ($(TARGET_MACHINE),aarch64)
COMMON_CFLAGS += -march=armv8-a+crc
endif
ifeq ($(CONFIG_WERROR), y)
COMMON_CFLAGS += -Werror