Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.5)
project(STREAMVBYTE VERSION "2.0.0")

set(STREAMVBYTE_LIB_VERSION "2.0.0" CACHE STRING "streamvbyte library version")
Expand Down Expand Up @@ -97,11 +97,6 @@ if(MSVC)
add_definitions("-D__restrict__=__restrict")
endif()

# test for arm
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)")
set(BASE_FLAGS ${BASE_FLAGS} "-D__ARM_NEON__")
endif()

set(STREAMVBYTE_SRCS
${PROJECT_SOURCE_DIR}/src/streamvbyte_encode.c
${PROJECT_SOURCE_DIR}/src/streamvbyte_decode.c
Expand Down
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@

PROCESSOR:=$(shell uname -m)

ifeq ($(PROCESSOR), aarch64)
# for 64-bit ARM processors (e.g., Linux), they may fail to defined __ARM_NEON__
CFLAGS = -fPIC -std=c99 -O3 -Wall -Wextra -pedantic -Wshadow -D__ARM_NEON__
else

CFLAGS = -fPIC -std=c99 -O3 -Wall -Wextra -pedantic -Wshadow
endif
LDFLAGS = -shared
LIBNAME=libstreamvbyte.so.0.0.1
LNLIBNAME=libstreamvbyte.so
Expand Down
6 changes: 3 additions & 3 deletions src/streamvbyte_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#pragma clang diagnostic ignored "-Wdeclaration-after-statement"
#endif

#ifdef __ARM_NEON__
#ifdef STREAMVBYTE_IS_ARM64
#include "streamvbyte_arm_decode.c"
#endif

Expand Down Expand Up @@ -76,7 +76,7 @@ size_t streamvbyte_decode(const uint8_t *in, uint32_t *out, uint32_t count) {
keyPtr += (count/4) & ~ 7U;
count &= 31;
}
#elif defined(__ARM_NEON__)
#elif defined(STREAMVBYTE_IS_ARM64)
dataPtr = svb_decode_vector(out, keyPtr, dataPtr, count);
out += count - (count & 3);
keyPtr += count/4;
Expand Down Expand Up @@ -105,7 +105,7 @@ bool streamvbyte_validate_stream(const uint8_t *in, size_t inCount,
const uint8_t *keyPtr = in;
uint64_t encodedSize = 0;

#if defined(__ARM_NEON__)
#if defined(STREAMVBYTE_IS_ARM64)
encodedSize = svb_validate_vector(&keyPtr, &outCount);
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/streamvbyte_encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static uint8_t *svb_encode_scalar(const uint32_t *in,
}


#ifdef __ARM_NEON__
#ifdef STREAMVBYTE_IS_ARM64
#include "streamvbyte_arm_encode.c"
#endif

Expand Down Expand Up @@ -120,7 +120,7 @@ size_t streamvbyte_encode(const uint32_t *in, uint32_t count, uint8_t *out) {
uint32_t keyLen = (count + 3) / 4; // 2-bits rounded to full byte
uint8_t *dataPtr = keyPtr + keyLen; // variable byte data after all keys

#if defined(__ARM_NEON__)
#if defined(STREAMVBYTE_IS_ARM64)

uint32_t count_quads = count / 4;
count -= 4 * count_quads;
Expand Down
10 changes: 6 additions & 4 deletions src/streamvbyte_isadetection.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include <stdbool.h>
#include <stdlib.h>


#if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
#define STREAMVBYTE_IS_ARM64 1
#endif // defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
#if defined(_MSC_VER)
/* Microsoft C/C++-compatible compiler */
#include <intrin.h>
Expand All @@ -52,7 +54,7 @@ POSSIBILITY OF SUCH DAMAGE.
#elif defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__))
/* GCC-compatible compiler, targeting x86/x86-64 */
#include <x86intrin.h>
#elif defined(__GNUC__) && defined(__ARM_NEON__)
#elif defined(__GNUC__) && defined(STREAMVBYTE_IS_ARM64)
/* GCC-compatible compiler, targeting ARM with NEON */
#include <arm_neon.h>
#elif defined(__GNUC__) && defined(__IWMMXT__)
Expand Down Expand Up @@ -263,9 +265,9 @@ static inline uint32_t streamvbyte_detect_supported_architectures(void) {
}
#endif

#ifdef __ARM_NEON__
#ifdef STREAMVBYTE_IS_ARM64
#define STREAMVBYTE_ARM
#endif
#endif // STREAMVBYTE_IS_ARM64

#ifdef STREAMVBYTE_X64
// this is almost standard?
Expand Down
2 changes: 1 addition & 1 deletion tests/unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -2827,7 +2827,7 @@ int main(void) {
} else {
printf("Code was not vectorized (x64).\n");
}
#elif defined(__ARM_NEON__)
#elif defined(STREAMVBYTE_IS_ARM64)
printf("Code was vectorized (ARM NEON).\n");
#else
printf("Warning: you tested non-vectorized code.\n");
Expand Down