Skip to content

Commit

Permalink
[WIP] Use libblastrampoline to forward to a user-defined BLAS at runt…
Browse files Browse the repository at this point in the history
…ime (#39455)
  • Loading branch information
ViralBShah authored Feb 25, 2021
1 parent 95a34a9 commit dc81980
Show file tree
Hide file tree
Showing 29 changed files with 602 additions and 477 deletions.
72 changes: 1 addition & 71 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,9 @@ USE_SYSTEM_P7ZIP:=0
# Link to the LLVM shared library
USE_LLVM_SHLIB := 1

## Settings for various Intel tools
# Set to 1 to use MKL
USE_INTEL_MKL ?= 0
# Set to 1 to use Intel LIBM
USE_INTEL_LIBM ?= 0
# Set to 1 to enable profiling with Intel VTune Amplifier
USE_INTEL_JITEVENTS ?= 0
# Set to 1 to use Intel C, C++, and FORTRAN compilers
USEICC ?= 0
USEIFC ?= 0

# Enable threading with one thread
JULIA_THREADS := 1

ifeq ($(USE_MKL), 1)
$(warning "The julia make variable USE_MKL has been renamed to USE_INTEL_MKL")
USE_INTEL_MKL := 1
endif

# Set to 1 to enable profiling with OProfile
USE_OPROFILE_JITEVENTS ?= 0

Expand Down Expand Up @@ -1068,11 +1052,7 @@ endif
# Use ILP64 BLAS interface when building openblas from source on 64-bit architectures
ifeq ($(BINARY), 64)
ifeq ($(USE_SYSTEM_BLAS), 1)
ifeq ($(USE_INTEL_MKL), 1)
USE_BLAS64 ?= 1
else # non MKL system blas is most likely LP64
USE_BLAS64 ?= 0
endif
else
USE_BLAS64 ?= 1
endif
Expand Down Expand Up @@ -1168,7 +1148,7 @@ BB_TRIPLET_CXXABI := $(subst $(SPACE),-,$(filter-out libgfortran%,$(subst -,$(SP
BB_TRIPLET := $(subst $(SPACE),-,$(filter-out cxx%,$(filter-out libgfortran%,$(subst -,$(SPACE),$(BB_TRIPLET_LIBGFORTRAN_CXXABI)))))

# This is the set of projects that BinaryBuilder dependencies are hooked up for.
BB_PROJECTS := OPENBLAS LLVM SUITESPARSE OPENLIBM GMP MBEDTLS LIBSSH2 NGHTTP2 MPFR CURL LIBGIT2 PCRE LIBUV LIBUNWIND DSFMT OBJCONV ZLIB P7ZIP CSL
BB_PROJECTS := BLASTRAMPOLINE OPENBLAS LLVM SUITESPARSE OPENLIBM GMP MBEDTLS LIBSSH2 NGHTTP2 MPFR CURL LIBGIT2 PCRE LIBUV LIBUNWIND DSFMT OBJCONV ZLIB P7ZIP CSL
define SET_BB_DEFAULT
# First, check to see if BB is disabled on a global setting
ifeq ($$(USE_BINARYBUILDER),0)
Expand Down Expand Up @@ -1332,63 +1312,13 @@ ifeq ($(USE_PERF_JITEVENTS), 1)
JCPPFLAGS += -DJL_USE_PERF_JITEVENTS
endif


# Intel libraries

ifeq ($(USE_INTEL_LIBM), 1)
USE_SYSTEM_LIBM := 1
LIBM := -L$(MKLROOT)/../compiler/lib/intel64 -limf
LIBMNAME := libimf
endif

ifeq ($(USE_INTEL_MKL), 1)
ifeq ($(USE_BLAS64), 1)
export MKL_INTERFACE_LAYER := ILP64
MKLLIB := $(MKLROOT)/lib/intel64
else
MKLLIB := $(MKLROOT)/lib/ia32
endif
USE_SYSTEM_BLAS:=1
USE_SYSTEM_LAPACK:=1
LIBBLASNAME := libmkl_rt
LIBLAPACKNAME := libmkl_rt
MKL_LDFLAGS := -L$(MKLLIB) -lmkl_rt
ifneq ($(strip $(MKLLIB)),)
ifeq ($(OS), Linux)
RPATH_MKL := -Wl,-rpath,$(MKLLIB)
RPATH += $(RPATH_MKL)
MKL_LDFLAGS += $(RPATH_MKL)
endif
endif
LIBBLAS := $(MKL_LDFLAGS)
LIBLAPACK := $(MKL_LDFLAGS)
endif

ifeq ($(HAVE_SSP),1)
JCPPFLAGS += -DHAVE_SSP=1
ifeq ($(USEGCC),1)
OSLIBS += -lssp
endif
endif

# ATLAS

# ATLAS must have been previously installed to usr/lib/libatlas
# (built as a shared library, for your platform, single threaded)
USE_ATLAS := 0
ATLAS_LIBDIR := $(build_libdir)
#or ATLAS_LIBDIR := /path/to/system/atlas/lib

ifeq ($(USE_ATLAS), 1)
USE_BLAS64 := 0
USE_SYSTEM_BLAS := 1
USE_SYSTEM_LAPACK := 1
LIBBLAS := -L$(ATLAS_LIBDIR) -lsatlas
LIBLAPACK := $(LIBBLAS)
LIBBLASNAME := libsatlas
LIBLAPACKNAME := $(LIBBLASNAME)
endif

# Renaming OpenBLAS symbols, see #4923 and #8734
ifeq ($(USE_SYSTEM_BLAS), 0)
ifeq ($(USE_BLAS64), 1)
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ JL_TARGETS += julia-debug
endif

# private libraries, that are installed in $(prefix)/lib/julia
JL_PRIVATE_LIBS-0 := libccalltest libllvmcalltest libjulia-internal
JL_PRIVATE_LIBS-0 := libccalltest libllvmcalltest libjulia-internal libblastrampoline
ifeq ($(BUNDLE_DEBUG_LIBS),1)
JL_PRIVATE_LIBS-0 += libjulia-internal-debug
endif
Expand Down Expand Up @@ -356,7 +356,7 @@ endif
$(call stringreplace,$${DEBUG_TARGET},sys-debug.$(SHLIB_EXT)$$,$(private_libdir_rel)/sys-debug.$(SHLIB_EXT)); \
fi;
endif

# Set rpath for libjulia-internal, which is moving from `../lib` to `../lib/julia`. We only need to do this for Linux/FreeBSD
ifneq (,$(findstring $(OS),Linux FreeBSD))
$(PATCHELF) --set-rpath '$$ORIGIN:$$ORIGIN/$(reverse_private_libdir_rel)' $(DESTDIR)$(private_libdir)/libjulia-internal.$(SHLIB_EXT)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ Standard library changes

#### LinearAlgebra

* Use [Libblastrampoline](https://github.com/staticfloat/libblastrampoline/) to pick a BLAS and LAPACK at runtime. By default it forwards to OpenBLAS in the Julia distribution. The forwarding mechanism can be used by packages to replace the BLAS and LAPACK with user preferences. ([#39455])
* On aarch64, OpenBLAS now uses an ILP64 BLAS like all other 64-bit platforms. ([#39436])
* OpenBLAS is updated to 0.3.13. ([#39216])
* SuiteSparse is updated to 5.8.1. ([#39455])

#### Markdown

Expand Down
2 changes: 1 addition & 1 deletion contrib/refresh_checksums.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CLANG_TRIPLETS=$(filter %-darwin %-freebsd,$(TRIPLETS))
NON_CLANG_TRIPLETS=$(filter-out %-darwin %-freebsd,$(TRIPLETS))

# These are the projects currently using BinaryBuilder; both GCC-expanded and non-GCC-expanded:
BB_PROJECTS=mbedtls libssh2 nghttp2 mpfr curl libgit2 pcre libuv unwind llvmunwind dsfmt objconv p7zip zlib suitesparse openlibm
BB_PROJECTS=mbedtls libssh2 nghttp2 mpfr curl libgit2 pcre libuv unwind llvmunwind dsfmt objconv p7zip zlib suitesparse openlibm blastrampoline
BB_GCC_EXPANDED_PROJECTS=openblas csl
BB_CXX_EXPANDED_PROJECTS=gmp llvm clang llvm-tools
# These are non-BB source-only deps
Expand Down
10 changes: 7 additions & 3 deletions deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ BUILDDIR := $(BUILDDIR)$(MAYBE_HOST)
# if you are adding a new target, it can help to copy an similar, existing target
#
# autoconf configure-driven scripts: pcre unwind gmp mpfr patchelf libuv curl
# custom Makefile rules: openlibm dsfmt suitesparse-wrapper suitesparse lapack openblas utf8proc objconv libwhich
# custom Makefile rules: openlibm dsfmt suitesparse-wrapper suitesparse lapack blastrampoline openblas utf8proc objconv libwhich
# CMake libs: llvm llvmunwind libgit2 libssh2 mbedtls
#
# downloadable via git: llvm-svn, libuv, libopenlibm, utf8proc, libgit2, libssh2
Expand All @@ -39,6 +39,9 @@ unexport CONFIG_SITE

DEP_LIBS :=

# Always use libblastrampoline
DEP_LIBS += blastrampoline

ifeq ($(USE_SYSTEM_CSL), 0)
DEP_LIBS += csl
endif
Expand Down Expand Up @@ -184,7 +187,7 @@ install: $(addprefix install-, $(DEP_LIBS))
cleanall: $(addprefix clean-, $(DEP_LIBS))
distcleanall: $(addprefix distclean-, $(DEP_LIBS))
rm -rf $(build_prefix)
getall: get-llvm get-libuv get-pcre get-openlibm get-dsfmt get-openblas get-lapack get-suitesparse get-unwind get-gmp get-mpfr get-patchelf get-utf8proc get-objconv get-mbedtls get-libssh2 get-nghttp2 get-curl get-libgit2 get-libwhich get-zlib get-p7zip get-csl
getall: get-llvm get-libuv get-pcre get-openlibm get-dsfmt get-blastrampoline get-openblas get-lapack get-suitesparse get-unwind get-gmp get-mpfr get-patchelf get-utf8proc get-objconv get-mbedtls get-libssh2 get-nghttp2 get-curl get-libgit2 get-libwhich get-zlib get-p7zip get-csl

# If we're building for MacOS, no matter what, `getall` should include `llvmunwind`
ifeq ($(OS),Darwin)
Expand All @@ -203,7 +206,8 @@ include $(SRCDIR)/pcre.mk
include $(SRCDIR)/openlibm.mk
include $(SRCDIR)/dsfmt.mk
include $(SRCDIR)/objconv.mk
include $(SRCDIR)/blas.mk
include $(SRCDIR)/blastrampoline.mk
include $(SRCDIR)/openblas.mk
include $(SRCDIR)/utf8proc.mk
include $(SRCDIR)/suitesparse.mk
include $(SRCDIR)/unwind.mk
Expand Down
6 changes: 5 additions & 1 deletion deps/Versions.make
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ OBJCONV_VER := 2.49.1
OBJCONV_JLL_NAME := Objconv
OBJCONV_JLL_VER := 2.49.1+0

# blastrampoline
BLASTRAMPOLINE_VER := 3.0.0
BLASTRAMPOLINE_JLL_NAME := libblastrampoline

# OpenBLAS
OPENBLAS_VER := 0.3.13
OPENBLAS_JLL_NAME := OpenBLAS
Expand All @@ -93,7 +97,7 @@ PCRE_VER := 10.36
PCRE_JLL_NAME := PCRE2

# SuiteSparse
SUITESPARSE_VER := 5.4.0
SUITESPARSE_VER := 5.8.1
SUITESPARSE_JLL_NAME := SuiteSparse

# unwind
Expand Down
37 changes: 37 additions & 0 deletions deps/blastrampoline.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## blastrampoline ##

ifneq ($(USE_BINARYBUILDER_BLASTRAMPOLINE),1)

BLASTRAMPOLINE_GIT_URL := git://github.com/staticfloat/libblastrampoline.git
BLASTRAMPOLINE_TAR_URL = https://api.github.com/repos/staticfloat/libblastrampoline/tarball/$1
$(eval $(call git-external,blastrampoline,BLASTRAMPOLINE,,,$(BUILDDIR)))

$(BUILDDIR)/$(BLASTRAMPOLINE_SRC_DIR)/build-configured: $(BUILDDIR)/$(BLASTRAMPOLINE_SRC_DIR)/source-extracted
mkdir -p $(dir $@)
echo 1 > $@

$(BUILDDIR)/$(BLASTRAMPOLINE_SRC_DIR)/build-compiled: $(BUILDDIR)/$(BLASTRAMPOLINE_SRC_DIR)/build-configured
cd $(dir $@)/src && $(MAKE) $(MAKE_COMMON)
echo 1 > $@

define BLASTRAMPOLINE_INSTALL
$(MAKE) -C $(BUILDDIR)/$(BLASTRAMPOLINE_SRC_DIR)/src $(MAKE_COMMON) install
endef
$(eval $(call staged-install, \
blastrampoline,$(BLASTRAMPOLINE_SRC_DIR), \
BLASTRAMPOLINE_INSTALL,, \
$$(BLASTRAMPOLINE_OBJ_TARGET), \
$$(INSTALL_NAME_CMD)libblastrampoline.$$(SHLIB_EXT) $$(build_shlibdir)/libblastrampoline.$$(SHLIB_EXT)))

get-blastrampoline: $(BLASTRAMPOLINE_SRC_FILE)
extract-blastrampoline: $(BUILDDIR)/$(BLASTRAMPOLINE_SRC_DIR)/source-extracted
configure-blastrampoline: extract-blastrampoline
compile-blastrampoline: $(BUILDDIR)/$(BLASTRAMPOLINE_SRC_DIR)/build-compiled
fastcheck-blastrampoline: check-blastrampoline
check-blastrampoline: compile-blastrampoline

else

$(eval $(call bb-install,blastrampoline,BLASTRAMPOLINE,false))

endif # USE_BINARYBUILDER_BLASTRAMPOLINE
2 changes: 2 additions & 0 deletions deps/blastrampoline.version
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BLASTRAMPOLINE_BRANCH=main
BLASTRAMPOLINE_SHA1=45f4a20ffdba5d368db66d71885312f5f73c2dc7
34 changes: 34 additions & 0 deletions deps/checksums/blastrampoline
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
blastrampoline-45f4a20ffdba5d368db66d71885312f5f73c2dc7.tar.gz/md5/00f14fabf8f36a99f97dd42110b21dd5
blastrampoline-45f4a20ffdba5d368db66d71885312f5f73c2dc7.tar.gz/sha512/e72d14e35ca512e42cd44060c4ccc300df9b82a0e0aa03f85fea3651fc6cc235fc8c4270fe3c93a75a7af20f38e9fe59bcbbdba4c3d62cd747cca2214dfce256
libblastrampoline.v3.0.0+0.aarch64-apple-darwin.tar.gz/md5/82fecf5e70db5573e3389c5deccdf92c
libblastrampoline.v3.0.0+0.aarch64-apple-darwin.tar.gz/sha512/559ace7a345ead6cafc52ff41748909c86abf75fe2ba272217d259fd2017f7237f675b9075320e31b37fd51d783577a8831744df286f39bd08f6748013d23a63
libblastrampoline.v3.0.0+0.aarch64-linux-gnu.tar.gz/md5/ea07fcd4b0923403e99420cfe882fa76
libblastrampoline.v3.0.0+0.aarch64-linux-gnu.tar.gz/sha512/098f67a9054a130d001e015f767113ace893caa8df28cfdb875d52eef36c252e512dd806d46b6dda625101edc613b55497462a1fd7351d907938f607f09ea1ed
libblastrampoline.v3.0.0+0.aarch64-linux-musl.tar.gz/md5/ba3ac2cac82777429f30d445dd8e8138
libblastrampoline.v3.0.0+0.aarch64-linux-musl.tar.gz/sha512/b30842126adcd308e1b9254075a8cddf534124b6022a5bd6b39c622cb3480af05786d73d698c102b9aeb58045099457fd28a43a8fb1453c4fb1008fbca147cff
libblastrampoline.v3.0.0+0.armv6l-linux-gnueabihf.tar.gz/md5/de3b0e86010239c794aa331d76f855c4
libblastrampoline.v3.0.0+0.armv6l-linux-gnueabihf.tar.gz/sha512/a94a33e076ce111d63832b6831e02582bf7982ea8866611c14d9d26d74881daa2d9df3ca2ccf01719ecf3f05564239a45fb9efebe34eb4b0dd340bce94617056
libblastrampoline.v3.0.0+0.armv6l-linux-musleabihf.tar.gz/md5/34c193f72ec4962ec5b4f724e43f46d8
libblastrampoline.v3.0.0+0.armv6l-linux-musleabihf.tar.gz/sha512/8ccba9921b6baa495c1f17689ad3c3a36042230d14100647dac260c907616f73e971578904a5b7d50b9e53698d65dc8660a2b4f46c41d7432acbf805a9293cea
libblastrampoline.v3.0.0+0.armv7l-linux-gnueabihf.tar.gz/md5/81936b0e9ac1e741864d373dcf3a71a1
libblastrampoline.v3.0.0+0.armv7l-linux-gnueabihf.tar.gz/sha512/23b74f6efb223919d9ef16396c970ae8dab8c418032a82890cfb34a06c6493cddf8a26ec83c35225c06861aa42375055143fa317bbb0cff1febe745ea411092c
libblastrampoline.v3.0.0+0.armv7l-linux-musleabihf.tar.gz/md5/6648bda00959b1b402d595611ded6335
libblastrampoline.v3.0.0+0.armv7l-linux-musleabihf.tar.gz/sha512/719b2d4772df813a5606c26f7dfd73b8ee72ab3d57cb978ad155cd23303a7e4e15446756243ced00da800013082ea12fdb6882f475db02d45e6a203e44ec4685
libblastrampoline.v3.0.0+0.i686-linux-gnu.tar.gz/md5/00a94da0c79ae709e0016aaf12772097
libblastrampoline.v3.0.0+0.i686-linux-gnu.tar.gz/sha512/8a99f8692362c832e7c90bb150c8c07ac9698b64cc352283d11251ebd16f59f66952967f6a48fcc5649f374b724421fadbcb3f48cee18e034b0450f55a3c8d7e
libblastrampoline.v3.0.0+0.i686-linux-musl.tar.gz/md5/68d4c314fb2c71b089af553f6aa0cfa8
libblastrampoline.v3.0.0+0.i686-linux-musl.tar.gz/sha512/b1623b421a30169cdca496014b734b783600319bc93d426dc2f513de64b86fab9e0a649b6cc64a0f2d415643083cd0c7672ab64bf1064e8780e03a130e24ae20
libblastrampoline.v3.0.0+0.i686-w64-mingw32.tar.gz/md5/c4f075c445f0694fa0794972902db6e3
libblastrampoline.v3.0.0+0.i686-w64-mingw32.tar.gz/sha512/c6a37da8c7a44bb250ded247c98dbe20e43373e9f45c41c70060411666273e2d21ffffbb94d7e89f326f48a212c9df9c1d27b9abcc8bc1545409e09260438c15
libblastrampoline.v3.0.0+0.powerpc64le-linux-gnu.tar.gz/md5/01159456203e67912e4db9a3ffde81c4
libblastrampoline.v3.0.0+0.powerpc64le-linux-gnu.tar.gz/sha512/854edaf69df8d044a9994579e493732163a0d393e6a19e363568cc3682f9d9fbf6e63104710173603dc7687670d4a9164a554f6e1130791ce66072e303f4a3a7
libblastrampoline.v3.0.0+0.x86_64-apple-darwin.tar.gz/md5/80a6e19c518846246b6e3c4d5fd31be8
libblastrampoline.v3.0.0+0.x86_64-apple-darwin.tar.gz/sha512/f5c52f496fab2c9eb1812b5ffe587a2f018ed92e311ad263fb84080341badda1279e2748798070df8b412b087430bdee12d3dfbafda207eb6a17a71eb6cc22bd
libblastrampoline.v3.0.0+0.x86_64-linux-gnu.tar.gz/md5/e7599dee593200c77114d0fee8783ecd
libblastrampoline.v3.0.0+0.x86_64-linux-gnu.tar.gz/sha512/f3eb3b9517200eb39146bc361476f244aac1ad4b1ffa5757a8f2399ac7d88252862ac9550d727b0e392cd2715f1018c7cdf998d7afc2948ba7fe16a1c2a6ce4a
libblastrampoline.v3.0.0+0.x86_64-linux-musl.tar.gz/md5/2f6eaf5684219ec985d3fe171f162d2f
libblastrampoline.v3.0.0+0.x86_64-linux-musl.tar.gz/sha512/33336fc7b3844c9b4c30351cbfbd48042d4a085799ec61b74925ba2943639da3e476a5de128d431e62a82a0973615d42299619a9705e43ef2e4ea2ff963edf4d
libblastrampoline.v3.0.0+0.x86_64-unknown-freebsd.tar.gz/md5/a9a52349cb509d75d91aa232b6005f66
libblastrampoline.v3.0.0+0.x86_64-unknown-freebsd.tar.gz/sha512/d2e57a6c7c7b0f08f0767c08b5e4e933eb78195b266377fbf9e95f3890a01654e4b97994fb7e575e2f48b821bad1b02c5fcdbafb6a6efda05622f124199e6ecc
libblastrampoline.v3.0.0+0.x86_64-w64-mingw32.tar.gz/md5/dcc3af7f8bb050ed45d14464f710a013
libblastrampoline.v3.0.0+0.x86_64-w64-mingw32.tar.gz/sha512/0f95e4eac7e0cd6cb7e86b040574c9404d802f4a4c090e2d27f903ff445b0e5afb5e9dc0e463c56e6c0b296faceb66db66f0d68ce7e493ffd9373e696445178c
File renamed without changes.
16 changes: 5 additions & 11 deletions deps/suitesparse.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ ifeq ($(USE_BLAS64), 1)
UMFPACK_CONFIG := -DLONGBLAS='long long'
CHOLMOD_CONFIG := -DLONGBLAS='long long'
SPQR_CONFIG := -DLONGBLAS='long long'
ifeq ($(OPENBLAS_SYMBOLSUFFIX), 64_)
UMFPACK_CONFIG += -DSUN64
CHOLMOD_CONFIG += -DSUN64
SPQR_CONFIG += -DSUN64
endif
endif

# Disable trying to link against libmetis
# Disable linking to libmetis
CHOLMOD_CONFIG += -DNPARTITION

ifneq ($(USE_BINARYBUILDER_SUITESPARSE), 1)
Expand All @@ -23,7 +21,7 @@ SUITE_SPARSE_LIB := $(LDFLAGS) -L"$(abspath $(BUILDDIR))/SuiteSparse-$(SUITESPAR
ifeq ($(OS), Darwin)
SUITE_SPARSE_LIB += $(RPATH_ESCAPED_ORIGIN)
endif
SUITESPARSE_MFLAGS := CC="$(CC)" CXX="$(CXX)" F77="$(FC)" AR="$(AR)" RANLIB="$(RANLIB)" BLAS="$(LIBBLAS)" LAPACK="$(LIBLAPACK)" \
SUITESPARSE_MFLAGS := CC="$(CC)" CXX="$(CXX)" F77="$(FC)" AR="$(AR)" RANLIB="$(RANLIB)" BLAS="-L$(build_shlibdir) -lblastrampoline" LAPACK="-L$(build_shlibdir) -lblastrampoline" \
LDFLAGS="$(SUITE_SPARSE_LIB)" CFOPENMP="" CUDA=no CUDA_PATH="" \
UMFPACK_CONFIG="$(UMFPACK_CONFIG)" CHOLMOD_CONFIG="$(CHOLMOD_CONFIG)" SPQR_CONFIG="$(SPQR_CONFIG)"
ifeq ($(OS),WINNT)
Expand Down Expand Up @@ -53,11 +51,7 @@ $(BUILDDIR)/SuiteSparse-$(SUITESPARSE_VER)/SuiteSparse-shlib.patch-applied: $(BU
$(BUILDDIR)/SuiteSparse-$(SUITESPARSE_VER)/build-compiled: $(BUILDDIR)/SuiteSparse-$(SUITESPARSE_VER)/SuiteSparse-winclang.patch-applied
$(BUILDDIR)/SuiteSparse-$(SUITESPARSE_VER)/build-compiled: $(BUILDDIR)/SuiteSparse-$(SUITESPARSE_VER)/SuiteSparse-shlib.patch-applied

ifeq ($(USE_SYSTEM_BLAS), 0)
$(BUILDDIR)/SuiteSparse-$(SUITESPARSE_VER)/build-compiled: | $(build_prefix)/manifest/openblas
else ifeq ($(USE_SYSTEM_LAPACK), 0)
$(BUILDDIR)/SuiteSparse-$(SUITESPARSE_VER)/build-compiled: | $(build_prefix)/manifest/lapack
endif
$(BUILDDIR)/SuiteSparse-$(SUITESPARSE_VER)/build-compiled: | $(build_prefix)/manifest/blastrampoline

$(BUILDDIR)/SuiteSparse-$(SUITESPARSE_VER)/build-compiled: $(BUILDDIR)/SuiteSparse-$(SUITESPARSE_VER)/source-extracted
$(MAKE) -C $(dir $<)SuiteSparse_config library config $(SUITESPARSE_MFLAGS)
Expand Down Expand Up @@ -153,6 +147,6 @@ clean-suitesparse-wrapper: clean-suitesparse
distclean-suitesparse-wrapper: distclean-suitesparse
install-suitesparse-wrapper: install-suitesparse

# suitesparse depends on OpenBLAS
compile-suitesparse: | $(build_prefix)/manifest/openblas
# suitesparse depends on blastrampoline
compile-suitesparse: | $(build_prefix)/manifest/blastrampoline
endif
32 changes: 5 additions & 27 deletions stdlib/Distributed/test/distributed_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1005,30 +1005,8 @@ end

# Test addprocs enable_threaded_blas parameter

const get_num_threads = function() # anonymous so it will be serialized when called
blas = LinearAlgebra.BLAS.vendor()
# Wrap in a try to catch unsupported blas versions
try
if blas == :openblas
return ccall((:openblas_get_num_threads, Base.libblas_name), Cint, ())
elseif blas == :openblas64
return ccall((:openblas_get_num_threads64_, Base.libblas_name), Cint, ())
elseif blas == :mkl
return ccall((:MKL_Get_Max_Num_Threads, Base.libblas_name), Cint, ())
end

# OSX BLAS looks at an environment variable
if Sys.isapple()
return tryparse(Cint, get(ENV, "VECLIB_MAXIMUM_THREADS", "1"))
end
catch
end

return nothing
end

function get_remote_num_threads(processes_added)
return [remotecall_fetch(get_num_threads, proc_id) for proc_id in processes_added]
return [remotecall_fetch(BLAS.get_num_threads, proc_id) for proc_id in processes_added]
end

function test_blas_config(pid, expected)
Expand All @@ -1041,7 +1019,7 @@ function test_blas_config(pid, expected)
end

function test_add_procs_threaded_blas()
master_blas_thread_count = get_num_threads()
master_blas_thread_count = BLAS.get_num_threads()
if master_blas_thread_count === nothing
@warn "Skipping blas num threads tests due to unsupported blas version"
return
Expand All @@ -1055,7 +1033,7 @@ function test_add_procs_threaded_blas()
end

# Master thread should not have changed
@test get_num_threads() == master_blas_thread_count
@test BLAS.get_num_threads() == master_blas_thread_count

# Threading disabled in children by default
thread_counts_by_process = get_remote_num_threads(processes_added)
Expand All @@ -1069,9 +1047,9 @@ function test_add_procs_threaded_blas()
test_blas_config(proc_id, true)
end

@test get_num_threads() == master_blas_thread_count
@test BLAS.get_num_threads() == master_blas_thread_count

# BLAS.set_num_threads(`num`) doesn't cause get_num_threads to return `num`
# BLAS.set_num_threads(`num`) doesn't cause BLAS.get_num_threads to return `num`
# depending on the machine, the BLAS version, and BLAS configuration, so
# we need a very lenient test.
thread_counts_by_process = get_remote_num_threads(processes_added)
Expand Down
1 change: 1 addition & 0 deletions stdlib/LinearAlgebra/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[deps]
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
libblastrampoline_jll = "8e850b90-86db-534c-a0d3-1478176c7d93"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
Loading

0 comments on commit dc81980

Please sign in to comment.