openblas: enable ARM-specific optimizations
authorkrant <aleksey.vasilenko@gmail.com>
Fri, 16 Feb 2024 12:46:45 +0000 (14:46 +0200)
committerJosef Schlehofer <pepe.schlehofer@gmail.com>
Sat, 17 Feb 2024 13:51:58 +0000 (14:51 +0100)
OpenBLAS allows to specify per-family CPU optimizations during build stage.
This package supports manual specification of a family during configuration.
This commit adds automatic detection of target family, while keeping manual
override as a backup.

Automatically detected ARM families:
 - Cortex-A9 without NEON
 - Cortex-A9 with NEON
 - Cortex-A15
 - Cortex-A53
 - Cortex-A72

Signed-off-by: krant <aleksey.vasilenko@gmail.com>
libs/openblas/Makefile

index 3a44db40df3167559bca4b6e51611482e6cc7683..715d35e1303b04e3aaecee3548aa51989db9a342 100644 (file)
@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=OpenBLAS
 PKG_VERSION:=0.3.26
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=OpenBLAS-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://github.com/xianyi/OpenBLAS/releases/download/v$(PKG_VERSION)/
@@ -49,13 +49,26 @@ endmenu
 endef
 
 OPENBLAS_TARGET=$(call qstrip,$(CONFIG_OPENBLAS_TARGET_OVERRIDE))
-CPU_TYPE=$(call qstrip,$(CONFIG_CPU_TYPE))
 
 ifeq ($(OPENBLAS_TARGET),)
 # initialize to GENERIC as default
 OPENBLAS_TARGET:=GENERIC
 
-ifeq ($(ARCH),aarch64)
+ifneq ($(findstring cortex-a9,$(CONFIG_CPU_TYPE)),)
+       ifneq ($(findstring neon,$(CONFIG_CPU_TYPE)),)
+               # CORTEXA9 relies on NEON
+               OPENBLAS_TARGET:=CORTEXA9
+       else
+               # Fallback for CPUs without NEON
+               OPENBLAS_TARGET:=ARMV7
+       endif
+else ifneq ($(findstring cortex-a15,$(CONFIG_CPU_TYPE)),)
+       OPENBLAS_TARGET:=CORTEXA15
+else ifneq ($(findstring cortex-a53,$(CONFIG_CPU_TYPE)),)
+       OPENBLAS_TARGET:=CORTEXA53
+else ifneq ($(findstring cortex-a72,$(CONFIG_CPU_TYPE)),)
+       OPENBLAS_TARGET:=CORTEXA72
+else ifeq ($(ARCH),aarch64)
   OPENBLAS_TARGET:=ARMV8
 else ifeq ($(ARCH),arm)
   OPENBLAS_TARGET:=ARMV5