openwrt-packages/libs/openblas/Makefile

124 lines
3.1 KiB
Makefile
Raw Normal View History

#
# Copyright (C) 2021 Alexandru Ardelean <ardeleanalex@gmail.com>
#
include $(TOPDIR)/rules.mk
PKG_NAME:=OpenBLAS
PKG_VERSION:=0.3.27
PKG_RELEASE:=1
PKG_SOURCE:=OpenBLAS-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/xianyi/OpenBLAS/releases/download/v$(PKG_VERSION)/
PKG_HASH:=aa2d68b1564fe2b13bc292672608e9cdeeeb6dc34995512e65c3b10f4599e897
PKG_LICENSE:=BSD-3-Clause
PKG_CPE_ID:=cpe:/a:openblas_project:openblas
PKG_MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
PKG_BUILD_PARALLEL:=1
PKG_INSTALL:=1
include $(INCLUDE_DIR)/package.mk
define Package/openblas
SECTION:=libs
CATEGORY:=Libraries
TITLE:=An optimized library for BLAS (Basic Linear Algebra Subprograms)
URL:=https://www.openblas.net/
DEPENDS:= \
@!arc \
@!powerpc \
@!SOFT_FLOAT \
+INSTALL_GFORTRAN:libgfortran
endef
define Package/openblas/description
OpenBLAS is an optimized BLAS (Basic Linear Algebra Subprograms) library
based on GotoBLAS2 1.13 BSD version.
endef
define Package/openblas/config
menu "Configuration"
depends on PACKAGE_openblas
config OPENBLAS_TARGET_OVERRIDE
string
prompt "Manual CPU target override (from the OpenBLAS TargetList.txt file)"
endmenu
endef
OPENBLAS_TARGET=$(call qstrip,$(CONFIG_OPENBLAS_TARGET_OVERRIDE))
ifeq ($(OPENBLAS_TARGET),)
# initialize to GENERIC as default
OPENBLAS_TARGET:=GENERIC
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
else ifeq ($(ARCH),mips)
openblas: default to MIPS24K target for all mips32 targets Reported via: https://github.com/openwrt/packages/pull/16823#issuecomment-945312460 This fails in mips_mip32 targets with the output listed below. Using the MIPS24K target works fine. ``` mips-openwrt-linux-musl-gcc -c -Os -pipe -mno-branch-likely -mips32 -mtune=mips32 -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -ffile-prefix-map=/builder/shared-workdir/build/sdk/build_dir/target-mips_mips32_musl/OpenBLAS-0.3.18=OpenBLAS-0.3.18 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-mips_mips32_gcc-11.2.0_musl/usr/include -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-mips_mips32_gcc-11.2.0_musl/include/fortify -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-mips_mips32_gcc-11.2.0_musl/include -DMAX_STACK_ALLOC=2048 -Wall -mabi=32 -DF_INTERFACE_GFORT -fPIC -DNO_LAPACK -DNO_LAPACKE -DNO_AVX512 -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=2 -DMAX_PARALLEL_NUMBER=1 -DBUILD_SINGLE=1 -DBUILD_DOUBLE=1 -DBUILD_COMPLEX=1 -DBUILD_COMPLEX16=1 -DVERSION=\"0.3.18\" -UASMNAME -UASMFNAME -UNAME -UCNAME -UCHAR_NAME -UCHAR_CNAME -DASMNAME= -DASMFNAME=_ -DNAME=_ -DCNAME= -DCHAR_NAME=\"_\" -DCHAR_CNAME=\"\" -DNO_AFFINITY -I. -DMAX_STACK_ALLOC=2048 -Wall -mabi=32 -DF_INTERFACE_GFORT -fPIC -DNO_LAPACK -DNO_LAPACKE -DNO_AVX512 -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=2 -DMAX_PARALLEL_NUMBER=1 -DBUILD_SINGLE=1 -DBUILD_DOUBLE=1 -DBUILD_COMPLEX=1 -DBUILD_COMPLEX16=1 -DVERSION=\"0.3.18\" -UASMNAME -UASMFNAME -UNAME -UCNAME -UCHAR_NAME -UCHAR_CNAME -DASMNAME=sgemm -DASMFNAME=sgemm_ -DNAME=sgemm_ -DCNAME=sgemm -DCHAR_NAME=\"sgemm_\" -DCHAR_CNAME=\"sgemm\" -DNO_AFFINITY -I.. -I. -UDOUBLE -UCOMPLEX gemm.c -o sgemm.o In file included from ../common.h:581, from gemm.c:41: gemm.c: In function 'sgemm_': ../param.h:3477:25: error: 'sgemm_p' undeclared (first use in this function); did you mean 'sgemm_'? 3477 | #define SGEMM_DEFAULT_P sgemm_p | ^~~~~~~ ../common_param.h:1334:25: note: in expansion of macro 'SGEMM_DEFAULT_P' 1334 | #define SGEMM_P SGEMM_DEFAULT_P | ^~~~~~~~~~~~~~~ ../common_param.h:1482:33: note: in expansion of macro 'SGEMM_P' 1482 | #define GEMM_P SGEMM_P | ^~~~~~~ gemm.c:494:37: note: in expansion of macro 'GEMM_P' 494 | sb = (XFLOAT *)(((BLASLONG)sa + ((GEMM_P * GEMM_Q * COMPSIZE * SIZE + GEMM_ALIGN) & ~GEMM_ALIGN)) + GEMM_OFFSET_B); | ^~~~~~ ../param.h:3477:25: note: each undeclared identifier is reported only once for each function it appears in 3477 | #define SGEMM_DEFAULT_P sgemm_p | ^~~~~~~ ../common_param.h:1334:25: note: in expansion of macro 'SGEMM_DEFAULT_P' 1334 | #define SGEMM_P SGEMM_DEFAULT_P | ^~~~~~~~~~~~~~~ ../common_param.h:1482:33: note: in expansion of macro 'SGEMM_P' 1482 | #define GEMM_P SGEMM_P | ^~~~~~~ gemm.c:494:37: note: in expansion of macro 'GEMM_P' 494 | sb = (XFLOAT *)(((BLASLONG)sa + ((GEMM_P * GEMM_Q * COMPSIZE * SIZE + GEMM_ALIGN) & ~GEMM_ALIGN)) + GEMM_OFFSET_B); | ^~~~~~ make[5]: *** [Makefile:1295: sgemm.o] Error 1 make[5]: Leaving directory '/builder/shared-workdir/ ``` Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2021-11-05 13:01:28 +01:00
OPENBLAS_TARGET:=MIPS24K
else ifeq ($(ARCH),mipsel)
openblas: default to MIPS24K target for all mips32 targets Reported via: https://github.com/openwrt/packages/pull/16823#issuecomment-945312460 This fails in mips_mip32 targets with the output listed below. Using the MIPS24K target works fine. ``` mips-openwrt-linux-musl-gcc -c -Os -pipe -mno-branch-likely -mips32 -mtune=mips32 -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -ffile-prefix-map=/builder/shared-workdir/build/sdk/build_dir/target-mips_mips32_musl/OpenBLAS-0.3.18=OpenBLAS-0.3.18 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-mips_mips32_gcc-11.2.0_musl/usr/include -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-mips_mips32_gcc-11.2.0_musl/include/fortify -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-mips_mips32_gcc-11.2.0_musl/include -DMAX_STACK_ALLOC=2048 -Wall -mabi=32 -DF_INTERFACE_GFORT -fPIC -DNO_LAPACK -DNO_LAPACKE -DNO_AVX512 -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=2 -DMAX_PARALLEL_NUMBER=1 -DBUILD_SINGLE=1 -DBUILD_DOUBLE=1 -DBUILD_COMPLEX=1 -DBUILD_COMPLEX16=1 -DVERSION=\"0.3.18\" -UASMNAME -UASMFNAME -UNAME -UCNAME -UCHAR_NAME -UCHAR_CNAME -DASMNAME= -DASMFNAME=_ -DNAME=_ -DCNAME= -DCHAR_NAME=\"_\" -DCHAR_CNAME=\"\" -DNO_AFFINITY -I. -DMAX_STACK_ALLOC=2048 -Wall -mabi=32 -DF_INTERFACE_GFORT -fPIC -DNO_LAPACK -DNO_LAPACKE -DNO_AVX512 -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=2 -DMAX_PARALLEL_NUMBER=1 -DBUILD_SINGLE=1 -DBUILD_DOUBLE=1 -DBUILD_COMPLEX=1 -DBUILD_COMPLEX16=1 -DVERSION=\"0.3.18\" -UASMNAME -UASMFNAME -UNAME -UCNAME -UCHAR_NAME -UCHAR_CNAME -DASMNAME=sgemm -DASMFNAME=sgemm_ -DNAME=sgemm_ -DCNAME=sgemm -DCHAR_NAME=\"sgemm_\" -DCHAR_CNAME=\"sgemm\" -DNO_AFFINITY -I.. -I. -UDOUBLE -UCOMPLEX gemm.c -o sgemm.o In file included from ../common.h:581, from gemm.c:41: gemm.c: In function 'sgemm_': ../param.h:3477:25: error: 'sgemm_p' undeclared (first use in this function); did you mean 'sgemm_'? 3477 | #define SGEMM_DEFAULT_P sgemm_p | ^~~~~~~ ../common_param.h:1334:25: note: in expansion of macro 'SGEMM_DEFAULT_P' 1334 | #define SGEMM_P SGEMM_DEFAULT_P | ^~~~~~~~~~~~~~~ ../common_param.h:1482:33: note: in expansion of macro 'SGEMM_P' 1482 | #define GEMM_P SGEMM_P | ^~~~~~~ gemm.c:494:37: note: in expansion of macro 'GEMM_P' 494 | sb = (XFLOAT *)(((BLASLONG)sa + ((GEMM_P * GEMM_Q * COMPSIZE * SIZE + GEMM_ALIGN) & ~GEMM_ALIGN)) + GEMM_OFFSET_B); | ^~~~~~ ../param.h:3477:25: note: each undeclared identifier is reported only once for each function it appears in 3477 | #define SGEMM_DEFAULT_P sgemm_p | ^~~~~~~ ../common_param.h:1334:25: note: in expansion of macro 'SGEMM_DEFAULT_P' 1334 | #define SGEMM_P SGEMM_DEFAULT_P | ^~~~~~~~~~~~~~~ ../common_param.h:1482:33: note: in expansion of macro 'SGEMM_P' 1482 | #define GEMM_P SGEMM_P | ^~~~~~~ gemm.c:494:37: note: in expansion of macro 'GEMM_P' 494 | sb = (XFLOAT *)(((BLASLONG)sa + ((GEMM_P * GEMM_Q * COMPSIZE * SIZE + GEMM_ALIGN) & ~GEMM_ALIGN)) + GEMM_OFFSET_B); | ^~~~~~ make[5]: *** [Makefile:1295: sgemm.o] Error 1 make[5]: Leaving directory '/builder/shared-workdir/ ``` Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2021-11-05 13:01:28 +01:00
OPENBLAS_TARGET:=MIPS24K
else ifeq ($(ARCH),powerpc)
OPENBLAS_TARGET:=PPC440
else ifeq ($(ARCH),riscv64)
OPENBLAS_TARGET:=RISCV64_GENERIC
endif
endif # ifeq ($(OPENBLAS_TARGET),)
ifeq ($(CONFIG_ARCH_64BIT),y)
OPENBLAS_BINARY:=64
else
OPENBLAS_BINARY:=32
endif
MAKE_FLAGS += \
CROSS=1 \
CC=$(TARGET_CC_NOCACHE) \
CXX=$(TARGET_CXX_NOCACHE) \
HOSTCC=$(HOSTCC_NOCACHE) \
CROSS_SUFFIX=$(TARGET_CROSS) \
BINARY=$(OPENBLAS_BINARY) \
MAKE_NB_JOBS=-1 \
NUM_THREADS=2 \
PREFIX=/usr \
COMMON_OPT="" \
ONLY_CBLAS=1 \
TARGET=$(call qstrip,$(OPENBLAS_TARGET))
ifneq ($(CONFIG_INSTALL_GFORTRAN),y)
MAKE_FLAGS += NOFORTRAN=1
endif
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
$(INSTALL_DIR) $(1)/usr/include
$(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/* $(1)/usr/lib/pkgconfig/
endef
define Package/openblas/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libopenblas*.so* $(1)/usr/lib/
endef
$(eval $(call BuildPackage,openblas))