mirror of
https://github.com/BLAKE3-team/BLAKE3
synced 2024-05-11 17:56:21 +02:00
Make the C implementation default to using NEON on aarch64
This commit is contained in:
parent
faddc5af5c
commit
c5941a2731
|
@ -42,6 +42,10 @@ EXTRAFLAGS += -DBLAKE3_USE_NEON
|
||||||
TARGETS += blake3_neon.o
|
TARGETS += blake3_neon.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef BLAKE3_NO_NEON
|
||||||
|
EXTRAFLAGS += -DBLAKE3_NO_NEON
|
||||||
|
endif
|
||||||
|
|
||||||
all: blake3.c blake3_dispatch.c blake3_portable.c main.c $(TARGETS)
|
all: blake3.c blake3_dispatch.c blake3_portable.c main.c $(TARGETS)
|
||||||
$(CC) $(CFLAGS) $(EXTRAFLAGS) $^ -o $(NAME) $(LDFLAGS)
|
$(CC) $(CFLAGS) $(EXTRAFLAGS) $^ -o $(NAME) $(LDFLAGS)
|
||||||
|
|
||||||
|
|
15
c/README.md
15
c/README.md
|
@ -250,15 +250,24 @@ gcc -shared -O3 -o libblake3.so -DBLAKE3_NO_SSE2 -DBLAKE3_NO_SSE41 -DBLAKE3_NO_A
|
||||||
|
|
||||||
## ARM NEON
|
## ARM NEON
|
||||||
|
|
||||||
The NEON implementation is not enabled by default on ARM, since not all
|
The NEON implementation is enabled by default on AARCH64, but not on
|
||||||
ARM targets support it. To enable it, set `BLAKE3_USE_NEON=1`. Here's an
|
other ARM targets, since not all of them support it. To enable it, set
|
||||||
example of building a shared library on ARM Linux with NEON support:
|
`BLAKE3_USE_NEON=1`. Here's an example of building a shared library on
|
||||||
|
ARM Linux with NEON support:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gcc -shared -O3 -o libblake3.so -DBLAKE3_USE_NEON blake3.c blake3_dispatch.c \
|
gcc -shared -O3 -o libblake3.so -DBLAKE3_USE_NEON blake3.c blake3_dispatch.c \
|
||||||
blake3_portable.c blake3_neon.c
|
blake3_portable.c blake3_neon.c
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To explicitiy disable using NEON instructions on AARCH64, set
|
||||||
|
`BLAKE3_NO_NEON=1`.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gcc -shared -O3 -o libblake3.so -DBLAKE3_NO_NEON blake3.c blake3_dispatch.c \
|
||||||
|
blake3_portable.c
|
||||||
|
```
|
||||||
|
|
||||||
Note that on some targets (ARMv7 in particular), extra flags may be
|
Note that on some targets (ARMv7 in particular), extra flags may be
|
||||||
required to activate NEON support in the compiler. If you see an error
|
required to activate NEON support in the compiler. If you see an error
|
||||||
like...
|
like...
|
||||||
|
|
|
@ -45,6 +45,10 @@ enum blake3_flags {
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__aarch64__) && !defined(BLAKE3_NO_NEON) && !defined(BLAKE3_USE_NEON)
|
||||||
|
#define BLAKE3_USE_NEON
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(IS_X86)
|
#if defined(IS_X86)
|
||||||
#define MAX_SIMD_DEGREE 16
|
#define MAX_SIMD_DEGREE 16
|
||||||
#elif defined(BLAKE3_USE_NEON)
|
#elif defined(BLAKE3_USE_NEON)
|
||||||
|
|
Loading…
Reference in New Issue