Skip to content

Commit

Permalink
Merge pull request #2 from mkitti/wizard/Blosc2-v1.9.9_9653de69
Browse files Browse the repository at this point in the history
Blosc2: Patch armv7l code for proper neon hardware detection
  • Loading branch information
waralex authored May 19, 2021
2 parents 38d88fc + 641ce20 commit c4fdea2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
4 changes: 3 additions & 1 deletion B/Blosc2/build_tarballs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ version = v"1.9.9"

# Collection of sources required to build Blosc2
sources = [
GitSource("https://github.com/Blosc/c-blosc2.git", "f06319ce93654e7cada64a75778fb50e8ddc6667")
GitSource("https://github.com/Blosc/c-blosc2.git", "f06319ce93654e7cada64a75778fb50e8ddc6667"),
DirectorySource("bundled")
]

# Bash recipe for building across all platforms
script = raw"""
cd $WORKSPACE/srcdir
cd c-blosc2/
git apply ../patches/blosc_armv7l.patch
mkdir build
cd build/
CMAKE_FLAGS=(-DCMAKE_INSTALL_PREFIX=$prefix -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} -DCMAKE_BUILD_TYPE=Release)
Expand Down
34 changes: 34 additions & 0 deletions B/Blosc2/bundled/patches/blosc_armv7l.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
diff --git a/blosc/CMakeLists.txt b/blosc/CMakeLists.txt
index 6fdf399..412d475 100644
--- a/blosc/CMakeLists.txt
+++ b/blosc/CMakeLists.txt
@@ -194,7 +194,7 @@ if(COMPILER_SUPPORT_NEON)
# Only armv7l needs special -mfpu=neon flag; aarch64 doesn't.
set_source_files_properties(
shuffle-neon.c bitshuffle-neon.c
- PROPERTIES COMPILE_FLAGS "-mfpu=neon")
+ PROPERTIES COMPILE_FLAGS "-mfpu=neon -flax-vector-conversions")
endif()
# Define a symbol for the shuffle-dispatch implementation
# so it knows NEON is supported even though that file is
diff --git a/blosc/shuffle.c b/blosc/shuffle.c
index cb166ee..586b039 100644
--- a/blosc/shuffle.c
+++ b/blosc/shuffle.c
@@ -15,6 +15,7 @@
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
+#include <sys/auxv.h>


#if !defined(__clang__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && \
@@ -251,7 +252,7 @@ static blosc_cpu_features blosc_get_cpu_features(void) {
/* aarch64 always has NEON */
cpu_features |= BLOSC_HAVE_NEON;
#else
- if (getauxval(AT_HWCAP) & HWCAP_NEON) {
+ if (getauxval(AT_HWCAP) & HWCAP_ARM_NEON) {
cpu_features |= BLOSC_HAVE_NEON;
}
#endif

0 comments on commit c4fdea2

Please sign in to comment.