Mac M1 crc32 intrinsics ARM64 check support proposal (#7893)
Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/7893 Reviewed By: ajkr Differential Revision: D26050966 Pulled By: jay-zhuang fbshipit-source-id: 9df2bb65d82defd7fad49d5369979b03e22d39c2
This commit is contained in:
parent
cc34da75b5
commit
7a3444bf1f
@ -19,6 +19,9 @@
|
|||||||
#ifndef HWCAP_PMULL
|
#ifndef HWCAP_PMULL
|
||||||
#define HWCAP_PMULL (1 << 4)
|
#define HWCAP_PMULL (1 << 4)
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_ARM64_CRYPTO
|
#ifdef HAVE_ARM64_CRYPTO
|
||||||
/* unfolding to compute 8 * 3 = 24 bytes parallelly */
|
/* unfolding to compute 8 * 3 = 24 bytes parallelly */
|
||||||
@ -43,6 +46,7 @@
|
|||||||
extern bool pmull_runtime_flag;
|
extern bool pmull_runtime_flag;
|
||||||
|
|
||||||
uint32_t crc32c_runtime_check(void) {
|
uint32_t crc32c_runtime_check(void) {
|
||||||
|
#if !defined(__APPLE__)
|
||||||
uint64_t auxv = 0;
|
uint64_t auxv = 0;
|
||||||
#if defined(ROCKSDB_AUXV_GETAUXVAL_PRESENT)
|
#if defined(ROCKSDB_AUXV_GETAUXVAL_PRESENT)
|
||||||
auxv = getauxval(AT_HWCAP);
|
auxv = getauxval(AT_HWCAP);
|
||||||
@ -50,9 +54,16 @@ uint32_t crc32c_runtime_check(void) {
|
|||||||
elf_aux_info(AT_HWCAP, &auxv, sizeof(auxv));
|
elf_aux_info(AT_HWCAP, &auxv, sizeof(auxv));
|
||||||
#endif
|
#endif
|
||||||
return (auxv & HWCAP_CRC32) != 0;
|
return (auxv & HWCAP_CRC32) != 0;
|
||||||
|
#else
|
||||||
|
int r;
|
||||||
|
size_t l = sizeof(r);
|
||||||
|
if (sysctlbyname("hw.optional.armv8_crc32", &r, &l, NULL, 0) == -1) return 0;
|
||||||
|
return r == 1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool crc32c_pmull_runtime_check(void) {
|
bool crc32c_pmull_runtime_check(void) {
|
||||||
|
#if !defined(__APPLE__)
|
||||||
uint64_t auxv = 0;
|
uint64_t auxv = 0;
|
||||||
#if defined(ROCKSDB_AUXV_GETAUXVAL_PRESENT)
|
#if defined(ROCKSDB_AUXV_GETAUXVAL_PRESENT)
|
||||||
auxv = getauxval(AT_HWCAP);
|
auxv = getauxval(AT_HWCAP);
|
||||||
@ -60,6 +71,9 @@ bool crc32c_pmull_runtime_check(void) {
|
|||||||
elf_aux_info(AT_HWCAP, &auxv, sizeof(auxv));
|
elf_aux_info(AT_HWCAP, &auxv, sizeof(auxv));
|
||||||
#endif
|
#endif
|
||||||
return (auxv & HWCAP_PMULL) != 0;
|
return (auxv & HWCAP_PMULL) != 0;
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ROCKSDB_UBSAN_RUN
|
#ifdef ROCKSDB_UBSAN_RUN
|
||||||
|
Loading…
x
Reference in New Issue
Block a user