360d99b809
Build tested for openblas and openblas64 on macOS Monterey Approved by thomas.orgis
124 lines
4 KiB
Text
124 lines
4 KiB
Text
# $NetBSD: Makefile.common,v 1.7 2022/02/03 19:28:19 bacon Exp $
|
|
#
|
|
# used by math/openblas_pthread/Makefile
|
|
# used by math/openblas_openmp/Makefile
|
|
# used by math/openblas/Makefile
|
|
# used by math/openblas64_pthread/Makefile
|
|
# used by math/openblas64_openmp/Makefile
|
|
# used by math/openblas64/Makefile
|
|
#
|
|
# This is the common Makefile for OpenBLAS builds. It depends on
|
|
# OPENBLAS_VARIANT = (openblas|openblas_pthread|openblas_openmp)
|
|
# being set.
|
|
|
|
DISTNAME= OpenBLAS-${OPENBLAS_VERSION}
|
|
PKGNAME= ${OPENBLAS_VARIANT}-${OPENBLAS_VERSION}
|
|
DIST_SUBDIR= openblas-${OPENBLAS_VERSION}
|
|
CATEGORIES= math
|
|
MASTER_SITES= ${MASTER_SITE_GITHUB:=xianyi/} \
|
|
http://www.netlib.org/lapack/timing/
|
|
DISTFILES= ${DISTNAME}.tar.gz ${LARGE_FILE} ${TIMING_FILE}
|
|
LARGE_FILE= large.tgz
|
|
TIMING_FILE= timing.tgz
|
|
GITHUB_PROJECT= OpenBLAS
|
|
GITHUB_TAG= v${OPENBLAS_VERSION}
|
|
|
|
DISTINFO_FILE= ${.CURDIR}/../../math/openblas/distinfo
|
|
PATCHDIR= ${.CURDIR}/../../math/openblas/patches
|
|
|
|
HOMEPAGE= https://github.com/xianyi/OpenBLAS
|
|
COMMENT= Optimized BLAS library based on GotoBLAS2 (variant ${OPENBLAS_VARIANT})
|
|
LICENSE= modified-bsd
|
|
|
|
# Darwin has a .so/.dylib PLIST issue
|
|
# Untested on other platforms
|
|
ONLY_FOR_PLATFORM= Darwin-*-* Linux-*-* NetBSD-*-*
|
|
|
|
USE_LANGUAGES= c fortran
|
|
USE_TOOLS+= gmake perl:build
|
|
|
|
NO_CONFIGURE= yes
|
|
|
|
TEST_TARGET= tests
|
|
|
|
# Also set compilers explicitly, overriding Makefile.rule
|
|
MAKE_FLAGS+= CC=${CC:Q}
|
|
MAKE_FLAGS+= CXX=${CXX:Q}
|
|
MAKE_FLAGS+= FC=${FC:Q}
|
|
|
|
# You may override the autodetected thread count limit.
|
|
# Default is detected from build host, which may differ from run host.
|
|
BUILD_DEFS+= OPENBLAS_THREAD_LIMIT
|
|
|
|
.include "../../mk/bsd.prefs.mk"
|
|
|
|
# Using conservative default of 32 threads as that matches the
|
|
# limit for related stack arrays in OpenBLAS. Might raise it
|
|
# in future, anyway. There some memory usage/efficiency tradeoff
|
|
# when this number is excessively high.
|
|
OPENBLAS_THREAD_LIMIT?= 32
|
|
.if !empty(OPENBLAS_THREAD_LIMIT)
|
|
MAKE_FLAGS+= NUM_THREADS=${OPENBLAS_THREAD_LIMIT:Q}
|
|
.endif
|
|
BENCHMARK_MAXTHREADS?= 8
|
|
|
|
.if empty(LP64PLATFORMS:@.PLAT.@${MACHINE_PLATFORM:M${.PLAT.}}@)
|
|
MAKE_FLAGS+= BINARY32=1
|
|
. if !empty(OPENBLAS_VARIANT:M*64*)
|
|
PKG_FAIL_REASON+= "${OPENBLAS_VARIANT} incompatible with non-64-bit platform"
|
|
. endif
|
|
.else
|
|
MAKE_FLAGS+= BINARY64=1
|
|
.endif
|
|
|
|
# Build with the C APIs, as do other optimized libraries.
|
|
#MAKE_FLAGS+= NO_CBLAS=0 NO_LAPACKE=0
|
|
|
|
# Separate headers and cmake stuff.
|
|
MAKE_FLAGS+= OPENBLAS_INCLUDE_DIR=${PREFIX}/include/${OPENBLAS_VARIANT}
|
|
MAKE_FLAGS+= OPENBLAS_CMAKE_DIR=${PREFIX}/lib/cmake/${OPENBLAS_VARIANT}
|
|
|
|
# Settled on no sumbol suffix for 64 bit.
|
|
MAKE_FLAGS+= FIXED_LIBNAME=1
|
|
.if ${OPENBLAS_VARIANT} == openblas || ${OPENBLAS_VARIANT} == openblas64
|
|
MAKE_FLAGS+= USE_OPENMP=0 USE_THREAD=0 USE_LOCKING=1
|
|
BENCHMARK_ENV= USE_SIMPLE_THREADED_LEVEL3=1
|
|
.elif !empty(OPENBLAS_VARIANT:Mopenblas*_pthread)
|
|
MAKE_FLAGS+= LIBNAMESUFFIX=pthread
|
|
MAKE_FLAGS+= USE_OPENMP=0 USE_THREAD=1
|
|
BENCHMARK_ENV= OPENBLAS_NUM_THREADS=${BENCHMARK_MAXTHREADS}
|
|
.elif !empty(OPENBLAS_VARIANT:Mopenblas*_openmp)
|
|
MAKE_FLAGS+= LIBNAMESUFFIX=openmp
|
|
MAKE_FLAGS+= USE_OPENMP=1 NO_AFFINITY=1
|
|
BENCHMARK_ENV= OMP_NUM_THREADS=${BENCHMARK_MAXTHREADS}
|
|
.endif
|
|
|
|
.if !empty(OPENBLAS_VARIANT:M*64*)
|
|
MAKE_FLAGS+= INTERFACE64=1 LIBSONAMEBASE=openblas64
|
|
.endif
|
|
|
|
SUBST_CLASSES+= threads
|
|
SUBST_STAGE.threads= pre-build
|
|
SUBST_SED.threads+= -e "s+OPENBLAS_NUM_THREADS+OMP_NUM_THREADS+g"
|
|
SUBST_FILES.threads+= test/Makefile
|
|
SUBST_FILES.threads+= ctest/Makefile
|
|
|
|
PLIST_SRC= ${.CURDIR}/../../math/openblas/PLIST
|
|
PLIST_SUBST+= OPENBLAS_VARIANT=${OPENBLAS_VARIANT}
|
|
|
|
post-extract:
|
|
rm ${WRKSRC}/relapack/src/lapack_wrappers.c.orig
|
|
(cd ${DISTDIR}/${DIST_SUBDIR} && \
|
|
${CP} ${LARGE_FILE} ${TIMING_FILE} ${WRKSRC})
|
|
|
|
# This builds some benchmark programs you can call from ${WRKSRC} afterwards.
|
|
.PHONY: benchmark
|
|
benchmark: build
|
|
(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${BENCHMARK_ENV} \
|
|
${MAKE_PROGRAM} ${MAKE_FLAGS} hpl)
|
|
(cd ${WRKSRC}/benchmark && ${SETENV} ${MAKE_ENV} \
|
|
${BENCHMARK_ENV} ${MAKE_PROGRAM} ${MAKE_FLAGS})
|
|
|
|
.include "../../math/openblas/version.mk"
|
|
|
|
.include "options.mk"
|