package/highway: new package

Highway is a C++ library that provides portable SIMD/vector intrinsics.

https://github.com/google/highway

Signed-off-by: Julien Olivain <ju.o@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
Julien Olivain 2022-11-24 23:05:51 +01:00 committed by Thomas Petazzoni
parent 89710c804e
commit 4733f9bd57
7 changed files with 174 additions and 0 deletions

View File

@ -1687,6 +1687,7 @@ F: package/fluid-soundfont/
F: package/fluidsynth/
F: package/glslsandbox-player/
F: package/gnupg2/
F: package/highway/
F: package/octave/
F: package/ola/
F: package/perftest/
@ -1709,6 +1710,7 @@ F: support/testing/tests/package/sample_python_gnupg.py
F: support/testing/tests/package/sample_python_pyalsa.py
F: support/testing/tests/package/sample_python_spake2.py
F: support/testing/tests/package/test_gnupg2.py
F: support/testing/tests/package/test_highway.py
F: support/testing/tests/package/test_hwloc.py
F: support/testing/tests/package/test_ncdu.py
F: support/testing/tests/package/test_octave.py

View File

@ -2034,6 +2034,7 @@ menu "Other"
source "package/gsl/Config.in"
source "package/gtest/Config.in"
source "package/gumbo-parser/Config.in"
source "package/highway/Config.in"
source "package/jemalloc/Config.in"
source "package/lapack/Config.in"
source "package/libabseil-cpp/Config.in"

View File

@ -0,0 +1,62 @@
From 491e3b1c2b8c44a2cfd35db117b02ef0fdf6a8e5 Mon Sep 17 00:00:00 2001
From: Julien Olivain <ju.o@free.fr>
Date: Wed, 23 Nov 2022 23:27:11 +0100
Subject: [PATCH] Check for the presence of <sys/auxv.h>
Not all gcc versions are providing <sys/auxv.h>. Checking for
HWY_ARCH_ARM && HWY_COMPILER_GCC_ACTUAL && HWY_OS_LINUX is not
sufficient and fail to build in some situations (it was observed for
some gcc armv7m toolchains).
This patch adds a check for <sys/auxv.h> and include it only if present.
Signed-off-by: Julien Olivain <ju.o@free.fr>
---
CMakeLists.txt | 3 +++
hwy/detect_targets.h | 2 +-
hwy/targets.cc | 2 +-
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b6b14ab..df6b5ab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -84,6 +84,9 @@ check_cxx_source_compiles(
HWY_RISCV
)
+include(CheckIncludeFile)
+check_include_file(sys/auxv.h HAVE_SYS_AUXV_H)
+
if (HWY_ENABLE_CONTRIB)
# Glob all the traits so we don't need to modify this file when adding
# additional special cases.
diff --git a/hwy/detect_targets.h b/hwy/detect_targets.h
index 7f7e179..f0c6f94 100644
--- a/hwy/detect_targets.h
+++ b/hwy/detect_targets.h
@@ -392,7 +392,7 @@
#define HWY_HAVE_RUNTIME_DISPATCH 1
// On Arm, currently only GCC does, and we require Linux to detect CPU
// capabilities.
-#elif HWY_ARCH_ARM && HWY_COMPILER_GCC_ACTUAL && HWY_OS_LINUX
+#elif HWY_ARCH_ARM && HWY_COMPILER_GCC_ACTUAL && HWY_OS_LINUX && HAVE_SYS_AUXV_H
#define HWY_HAVE_RUNTIME_DISPATCH 1
#else
#define HWY_HAVE_RUNTIME_DISPATCH 0
diff --git a/hwy/targets.cc b/hwy/targets.cc
index 2fde4db..abd6a94 100644
--- a/hwy/targets.cc
+++ b/hwy/targets.cc
@@ -42,7 +42,7 @@
#include <cpuid.h>
#endif // HWY_COMPILER_MSVC
-#elif HWY_ARCH_ARM && HWY_OS_LINUX
+#elif HWY_ARCH_ARM && HWY_OS_LINUX && HAVE_SYS_AUXV_H
#include <asm/hwcap.h>
#include <sys/auxv.h>
#endif // HWY_ARCH_*
--
2.38.1

34
package/highway/Config.in Normal file
View File

@ -0,0 +1,34 @@
config BR2_PACKAGE_HIGHWAY
bool "highway"
depends on BR2_TOOLCHAIN_HAS_ATOMIC
depends on BR2_INSTALL_LIBSTDCPP
# For gcc bug 58969, see:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58969
depends on BR2_TOOLCHAIN_GCC_AT_LEAST_7 # C++11, GCC_BUG_58969
help
Highway is a C++ library that provides portable SIMD/vector
intrinsics.
https://github.com/google/highway
if BR2_PACKAGE_HIGHWAY
config BR2_PACKAGE_HIGHWAY_CONTRIB
bool "Enable Contrib"
help
Build Highway contrib library which contains extra
SIMD-related utilities: an image class with aligned rows, a
math library (16 functions already implemented, mostly
trigonometry), and functions for computing dot products and
sorting.
config BR2_PACKAGE_HIGHWAY_EXAMPLES
bool "Enable Examples"
help
Build Highway examples
endif
comment "highway needs a toolchain w/ C++, gcc >= 7"
depends on BR2_TOOLCHAIN_HAS_ATOMIC
depends on !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_GCC_AT_LEAST_7

View File

@ -0,0 +1,3 @@
# Locally computed:
sha256 e8ef71236ac0d97f12d553ec1ffc5b6375d57b5f0b860c7447dd69b6ed1072db highway-1.0.2.tar.gz
sha256 43070e2d4e532684de521b885f385d0841030efa2b1a20bafb76133a5e1379c1 LICENSE

View File

@ -0,0 +1,50 @@
################################################################################
#
# highway
#
################################################################################
HIGHWAY_VERSION = 1.0.2
HIGHWAY_SITE = $(call github,google,highway,$(HIGHWAY_VERSION))
HIGHWAY_LICENSE = Apache-2.0
HIGHWAY_LICENSE_FILES = LICENSE
HIGHWAY_INSTALL_STAGING = YES
HIGHWAY_CXXFLAGS = $(TARGET_CXXFLAGS)
ifeq ($(BR2_PACKAGE_HIGHWAY_CONTRIB),y)
HIGHWAY_CONF_OPTS += -DHWY_ENABLE_CONTRIB=ON
else
HIGHWAY_CONF_OPTS += -DHWY_ENABLE_CONTRIB=OFF
endif
ifeq ($(BR2_PACKAGE_HIGHWAY_EXAMPLES),y)
HIGHWAY_CONF_OPTS += -DHWY_ENABLE_EXAMPLES=ON
# Examples are not installed by cmake. This binary can be useful for
# quick testing and debug.
define HIGHWAY_INSTALL_EXAMPLES
$(INSTALL) -m 0755 \
$(@D)/examples/hwy_benchmark \
$(TARGET_DIR)/usr/bin/hwy_benchmark
endef
HIGHWAY_POST_INSTALL_TARGET_HOOKS += HIGHWAY_INSTALL_EXAMPLES
else
HIGHWAY_CONF_OPTS += -DHWY_ENABLE_EXAMPLES=OFF
endif
ifeq ($(BR2_ARM_FPU_VFPV4),y)
HIGHWAY_CONF_OPTS += -DHWY_CMAKE_ARM7=ON
else
HIGHWAY_CONF_OPTS += -DHWY_CMAKE_ARM7=OFF
endif
# Workaround for gcc bug 104028 on m68k.
# See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104028
ifeq ($(BR2_TOOLCHAIN_HAS_GCC_BUG_104028),y)
HIGHWAY_CXXFLAGS += -O0
endif
HIGHWAY_CONF_OPTS += \
-DCMAKE_CXX_FLAGS="$(HIGHWAY_CXXFLAGS)"
$(eval $(cmake-package))

View File

@ -0,0 +1,22 @@
import os
import infra.basetest
class TestHighway(infra.basetest.BRTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
BR2_PACKAGE_HIGHWAY=y
BR2_PACKAGE_HIGHWAY_EXAMPLES=y
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
def test_run(self):
cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
self.emulator.boot(arch="armv5",
kernel="builtin",
options=["-initrd", cpio_file])
self.emulator.login()
self.assertRunOk("hwy_benchmark", timeout=20)