1
0
Fork 0
mirror of https://github.com/BLAKE3-team/BLAKE3 synced 2024-04-26 15:55:01 +02:00

Use BLAKE3_USE_NEON=0 instead of BLAKE3_NO_NEON def

This commit is contained in:
rsdy 2021-10-12 23:23:25 +01:00
parent f4d5c6e785
commit 2aa7c963be
4 changed files with 16 additions and 11 deletions

View File

@ -38,12 +38,12 @@ ASM_TARGETS += blake3_avx512_x86-64_unix.S
endif
ifdef BLAKE3_USE_NEON
EXTRAFLAGS += -DBLAKE3_USE_NEON
EXTRAFLAGS += -DBLAKE3_USE_NEON=1
TARGETS += blake3_neon.o
endif
ifdef BLAKE3_NO_NEON
EXTRAFLAGS += -DBLAKE3_NO_NEON
EXTRAFLAGS += -DBLAKE3_USE_NEON=0
endif
all: blake3.c blake3_dispatch.c blake3_portable.c main.c $(TARGETS)

View File

@ -256,15 +256,15 @@ other ARM targets, since not all of them support it. To enable it, set
ARM Linux with NEON support:
```bash
gcc -shared -O3 -o libblake3.so -DBLAKE3_USE_NEON blake3.c blake3_dispatch.c \
gcc -shared -O3 -o libblake3.so -DBLAKE3_USE_NEON=1 blake3.c blake3_dispatch.c \
blake3_portable.c blake3_neon.c
```
To explicitiy disable using NEON instructions on AARCH64, set
`BLAKE3_NO_NEON=1`.
`BLAKE3_USE_NEON=0`.
```bash
gcc -shared -O3 -o libblake3.so -DBLAKE3_NO_NEON blake3.c blake3_dispatch.c \
gcc -shared -O3 -o libblake3.so -DBLAKE3_USE_NEON=0 blake3.c blake3_dispatch.c \
blake3_portable.c
```

View File

@ -232,7 +232,7 @@ void blake3_hash_many(const uint8_t *const *inputs, size_t num_inputs,
#endif
#endif
#if defined(BLAKE3_USE_NEON)
#if BLAKE3_USE_NEON == 1
blake3_hash_many_neon(inputs, num_inputs, blocks, key, counter,
increment_counter, flags, flags_start, flags_end, out);
return;
@ -269,7 +269,7 @@ size_t blake3_simd_degree(void) {
}
#endif
#endif
#if defined(BLAKE3_USE_NEON)
#if BLAKE3_USE_NEON == 1
return 4;
#endif
return 1;

View File

@ -49,13 +49,18 @@ enum blake3_flags {
#include <immintrin.h>
#endif
#if defined(IS_AARCH64) && !defined(BLAKE3_NO_NEON) && !defined(BLAKE3_USE_NEON)
#define BLAKE3_USE_NEON
#if !defined(BLAKE3_USE_NEON)
// If BLAKE3_USE_NEON not manually set, autodetect based on AArch64ness
#if defined(IS_AARCH64)
#define BLAKE3_USE_NEON 1
#else
#define BLAKE3_USE_NEON 0
#endif
#endif
#if defined(IS_X86)
#define MAX_SIMD_DEGREE 16
#elif defined(BLAKE3_USE_NEON)
#elif BLAKE3_USE_NEON == 1
#define MAX_SIMD_DEGREE 4
#else
#define MAX_SIMD_DEGREE 1
@ -265,7 +270,7 @@ void blake3_hash_many_avx512(const uint8_t *const *inputs, size_t num_inputs,
#endif
#endif
#if defined(BLAKE3_USE_NEON)
#if BLAKE3_USE_NEON == 1
void blake3_hash_many_neon(const uint8_t *const *inputs, size_t num_inputs,
size_t blocks, const uint32_t key[8],
uint64_t counter, bool increment_counter,