-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: I3044a89bae619968e340636996f014a0134f1030 Signed-off-by: Yuqi Gu <[email protected]>
- Loading branch information
Showing
5 changed files
with
288 additions
and
17 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 |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// 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_ARMCE_UTIL_H | ||
#define ARROW_UTIL_ARMCE_UTIL_H | ||
|
||
#include "my_config.h" | ||
|
||
namespace arrow { | ||
|
||
#if defined(__GNUC__) && defined(__linux__) && defined(ARROW_HAVE_ARMCE) | ||
|
||
#include <sys/auxv.h> | ||
#include <asm/hwcap.h> | ||
#ifndef HWCAP_CRC32 | ||
#define HWCAP_CRC32 (1 << 7) | ||
#endif | ||
static inline uint32_t crc32c_runtime_check(void) | ||
{ | ||
unsigned long auxv = getauxval(AT_HWCAP); | ||
return (auxv & HWCAP_CRC32) != 0; | ||
} | ||
|
||
#ifdef HAVE_ARMV8_CRC_INTRINSICS | ||
// compiler intrinsics. | ||
#include <arm_acle.h> | ||
#include <arm_neon.h> | ||
|
||
#define ARMCE_crc32_u8 __crc32cb | ||
#define ARMCE_crc32_u16 __crc32ch | ||
#define ARMCE_crc32_u32 __crc32cw | ||
#define ARMCE_crc32_u64 __crc32cd | ||
|
||
#else | ||
// Request crc extension capabilities from the assembler | ||
asm(".arch_extension crc"); | ||
|
||
// define our own implementations of the intrinsics instead. | ||
static inline uint32_t ARMCE_crc32_u8(uint32_t crc, uint8_t value) { | ||
__asm__("crc32cb %w[c], %w[c], %w[v]":[c]"+r"(crc):[v]"r"(value)); | ||
return crc; | ||
} | ||
|
||
static inline uint32_t ARMCE_crc32_u16(uint32_t crc, uint16_t value) { | ||
__asm__("crc32ch %w[c], %w[c], %w[v]":[c]"+r"(crc):[v]"r"(value)); | ||
return crc; | ||
} | ||
|
||
static inline uint32_t ARMCE_crc32_u32(uint32_t crc, uint32_t value) { | ||
__asm__("crc32cw %w[c], %w[c], %w[v]":[c]"+r"(crc):[v]"r"(value)); | ||
return crc; | ||
} | ||
|
||
static inline uint32_t ARMCE_crc32_u64(uint32_t crc, uint64_t value) { | ||
uint64_t result = crc; | ||
__asm__("crc32cx %w[c], %w[c], %x[v]":[c]"+r"(crc):[v]"r"(value)); | ||
return static_cast<uint32_t>(result); | ||
} | ||
#endif // HAVE_ARMV8_CRC_INTRINSICS | ||
|
||
#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_ARMCE) | ||
|
||
} // namespace arrow | ||
|
||
#endif // ARROW_UTIL_ARMCE_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* 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. | ||
|
||
This module sets the following variables in your project:: | ||
|
||
arrow_FOUND - true if arrow found on the system */ | ||
|
||
/* my_config.h file expanded by Cmake for build */ | ||
|
||
|
||
#ifndef MY_CONFIG_H | ||
#define MY_CONFIG_H | ||
|
||
/* Support Armv8 CRC instructions */ | ||
#cmakedefine ARROW_HAVE_ARMCE 1 | ||
#cmakedefine HAVE_ARMV8_CRC_INTRINSICS 1 | ||
|
||
#endif /* MY_CONFIG_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