-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARROW-3849: [C++] Leverage Armv8 crc32 extension instructions to acce…
…lerate the hash computation for Arm64 The 'Hash utility' leverages SSE4 to accelerate the Crc32 data hash computation for x86. Correspondingly, we will leverage the Arm crc32 extension instructions to accelerate the hash computation for Arm64. 1. Add Arm hardware Crc32 support. 2. Add the hash computing mode respectively: - USE_DEFAULT: Murmur2-64 - USE_SSE42 - USE_ARMCRC 3. Modify the cmake configuration to detect whether the Arm architecture is supported or not on compiling phase. The code will also do a Crc32 run time check(only available for Linux). Author: Yuqi Gu <yuqi.gu@arm.com> Closes #3010 from guyuqi/ARROW-3849 and squashes the following commits: 6b99d20 <Yuqi Gu> Fix the coding style 1cf378a <Yuqi Gu> Rebase the patch to master fcf972e <Yuqi Gu> ARROW-3849 Leverage Armv8 crc32 extension instructions to accelerate the hash computation for Arm64
- Loading branch information
Showing
4 changed files
with
165 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ install(FILES | |
logging.h | ||
macros.h | ||
memory.h | ||
neon-util.h | ||
parallel.h | ||
rle-encoding.h | ||
sse-util.h | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
#ifndef ARROW_UTIL_NEON_UTIL_H | ||
#define ARROW_UTIL_NEON_UTIL_H | ||
|
||
namespace arrow { | ||
|
||
#if defined(__aarch64__) || defined(__AARCH64__) | ||
#ifdef __ARM_FEATURE_CRC32 | ||
#define ARROW_HAVE_ARM_CRC | ||
#include <arm_acle.h> | ||
#endif | ||
#endif | ||
|
||
#if defined(__GNUC__) && defined(__linux__) && defined(ARROW_HAVE_ARM_CRC) | ||
|
||
#include <asm/hwcap.h> | ||
#include <sys/auxv.h> | ||
#ifndef HWCAP_CRC32 | ||
#define HWCAP_CRC32 (1 << 7) | ||
#endif | ||
static inline uint32_t crc32c_runtime_check(void) { | ||
uint64_t auxv = getauxval(AT_HWCAP); | ||
return (auxv & HWCAP_CRC32) != 0; | ||
} | ||
|
||
static inline uint32_t ARMCE_crc32_u8(uint32_t crc, uint8_t v) { | ||
return __crc32cb(crc, v); | ||
} | ||
|
||
static inline uint32_t ARMCE_crc32_u16(uint32_t crc, uint16_t v) { | ||
return __crc32ch(crc, v); | ||
} | ||
|
||
static inline uint32_t ARMCE_crc32_u32(uint32_t crc, uint32_t v) { | ||
return __crc32cw(crc, v); | ||
} | ||
|
||
static inline uint32_t ARMCE_crc32_u64(uint32_t crc, uint64_t v) { | ||
return __crc32cd(crc, v); | ||
} | ||
|
||
#else | ||
|
||
static inline uint32_t crc32c_runtime_check(void) { | ||
DCHECK(false) << "Arm crc32 support is not enabled"; | ||
return 0; | ||
} | ||
|
||
static inline uint32_t ARMCE_crc32_u8(uint32_t, uint8_t) { | ||
DCHECK(false) << "Arm crc32 support is not enabled"; | ||
return 0; | ||
} | ||
|
||
static inline uint32_t ARMCE_crc32_u16(uint32_t, uint16_t) { | ||
DCHECK(false) << "Arm crc32 is not enabled"; | ||
return 0; | ||
} | ||
|
||
static inline uint32_t ARMCE_crc32_u32(uint32_t, uint32_t) { | ||
DCHECK(false) << "Arm crc32 support is not enabled"; | ||
return 0; | ||
} | ||
|
||
static inline uint32_t ARMCE_crc32_u64(uint32_t, uint64_t) { | ||
DCHECK(false) << "Arm crc32 support is not enabled"; | ||
return 0; | ||
} | ||
|
||
#endif // defined(__GNUC__) && defined(__linux__) && defined(ARROW_HAVE_ARM_CRC) | ||
|
||
} // namespace arrow | ||
|
||
#endif // ARROW_UTIL_NEON_UTIL_H |