Skip to content

Commit c01e415

Browse files
committed
Merge pull request #9050 from JuliaLang/tk/backport-8734
RFC: Should we backport #8734 to release-0.3 ?
2 parents 76522d7 + 8243c5b commit c01e415

8 files changed

+576
-165
lines changed

LICENSE.md

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Julia builds the following libraries by default, but does not use them itself:
7474
Julia's build process uses the following external tools:
7575

7676
- [PATCHELF](http://hydra.nixos.org/build/1524660/download/1/README)
77+
- [OBJCONV](http://www.agner.org/optimize/#objconv)
7778

7879

7980
Julia bundles the following external programs and libraries on some platforms:

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ source-dist: git-submodules
360360
# Create file source-dist.tmp to hold all the filenames that go into the tarball
361361
echo "base/version_git.jl" > source-dist.tmp
362362
git ls-files >> source-dist.tmp
363-
ls deps/*.tar.gz deps/*.tar.bz2 deps/*.tgz >> source-dist.tmp
363+
ls deps/*.tar.gz deps/*.tar.bz2 deps/*.tar.xz deps/*.tgz deps/*.zip >> source-dist.tmp
364364
git submodule --quiet foreach 'git ls-files | sed "s&^&$$path/&"' >> source-dist.tmp
365365

366366
# Remove unwanted files

base/interactiveutil.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ function versioninfo(io::IO=STDOUT, verbose::Bool=false)
172172
Sys.cpu_summary(io)
173173
println(io )
174174
end
175-
if Base.libblas_name == "libopenblas" || blas_vendor() == :openblas
175+
if Base.libblas_name == "libopenblas" || blas_vendor() == :openblas || blas_vendor() == :openblas64
176176
openblas_config = openblas_get_config()
177177
println(io, " BLAS: libopenblas (", openblas_config, ")")
178178
else

base/linalg/blas.jl

+40-39
Large diffs are not rendered by default.

base/linalg/lapack.jl

+117-115
Large diffs are not rendered by default.

base/util.jl

+14-2
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,31 @@ function blas_vendor()
107107
cglobal((:openblas_set_num_threads, Base.libblas_name), Void)
108108
return :openblas
109109
end
110+
try
111+
cglobal((:openblas_set_num_threads64_, Base.libblas_name), Void)
112+
return :openblas64
113+
end
110114
try
111115
cglobal((:MKL_Set_Num_Threads, Base.libblas_name), Void)
112116
return :mkl
113117
end
114118
return :unknown
115119
end
116120

117-
openblas_get_config() = strip(bytestring( ccall((:openblas_get_config, Base.libblas_name), Ptr{Uint8}, () )))
121+
if blas_vendor() == :openblas64
122+
blasfunc(x) = string(x)*"64_"
123+
openblas_get_config() = strip(bytestring( ccall((:openblas_get_config64_, Base.libblas_name), Ptr{Uint8}, () )))
124+
else
125+
blasfunc(x) = string(x)
126+
openblas_get_config() = strip(bytestring( ccall((:openblas_get_config, Base.libblas_name), Ptr{Uint8}, () )))
127+
end
118128

119129
function blas_set_num_threads(n::Integer)
120130
blas = blas_vendor()
121131
if blas == :openblas
122132
return ccall((:openblas_set_num_threads, Base.libblas_name), Void, (Int32,), n)
133+
elseif blas == :openblas64
134+
return ccall((:openblas_set_num_threads64_, Base.libblas_name), Void, (Int32,), n)
123135
elseif blas == :mkl
124136
# MKL may let us set the number of threads in several ways
125137
return ccall((:MKL_Set_Num_Threads, Base.libblas_name), Void, (Cint,), n)
@@ -133,7 +145,7 @@ end
133145

134146
function check_blas()
135147
blas = blas_vendor()
136-
if blas == :openblas
148+
if blas == :openblas || blas == :openblas64
137149
openblas_config = openblas_get_config()
138150
openblas64 = ismatch(r".*USE64BITINT.*", openblas_config)
139151
if Base.USE_BLAS64 != openblas64

deps/Makefile

+69-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ CONFIGURE_COMMON += F77="$(FC)" CC="$(CC)" CXX="$(CXX)"
1919
MAKE_COMMON = DESTDIR="" prefix=$(build_prefix) bindir=$(build_bindir) libdir=$(build_libdir) libexecdir=$(build_libexecdir) datarootdir=$(build_datarootdir) includedir=$(build_includedir) sysconfdir=$(build_sysconfdir)
2020

2121
#autoconf configure-driven scripts: llvm pcre arpack fftw unwind gmp mpfr patchelf uv
22-
#custom Makefile rules: openlibm Rmath double-conversion dsfmt suitesparse-wrapper suitesparse lapack openblas utf8proc
22+
#custom Makefile rules: openlibm Rmath double-conversion dsfmt suitesparse-wrapper suitesparse lapack openblas utf8proc objconv
2323

2424
# prevent installing libs into usr/lib64 on opensuse
2525
unexport CONFIG_SITE
@@ -77,6 +77,11 @@ endif
7777

7878
ifeq ($(USE_SYSTEM_BLAS), 0)
7979
STAGE1_DEPS += openblas
80+
ifeq ($(USE_BLAS64), 1)
81+
ifeq ($(OS), Darwin)
82+
STAGE1_DEPS += objconv
83+
endif
84+
endif
8085
endif
8186

8287
ifeq ($(USE_SYSTEM_FFTW), 0)
@@ -144,7 +149,7 @@ install: $(addprefix install-, $(DEP_LIBS))
144149
cleanall: $(addprefix clean-, $(DEP_LIBS))
145150
distcleanall: $(addprefix distclean-, $(DEP_LIBS))
146151
rm -rf $(build_prefix)
147-
getall: get-llvm get-uv get-pcre get-double-conversion get-openlibm get-openspecfun get-dsfmt get-Rmath get-openblas get-lapack get-fftw get-suitesparse get-arpack get-unwind get-osxunwind get-gmp get-mpfr get-zlib get-patchelf get-utf8proc
152+
getall: get-llvm get-uv get-pcre get-double-conversion get-openlibm get-openspecfun get-dsfmt get-Rmath get-openblas get-lapack get-fftw get-suitesparse get-arpack get-unwind get-osxunwind get-gmp get-mpfr get-zlib get-patchelf get-utf8proc get-objconv
148153

149154
## PATHS ##
150155
# sort is used to remove potential duplicates
@@ -750,6 +755,34 @@ check-Rmath: compile-Rmath
750755
install-Rmath: $(RMATH_OBJ_TARGET)
751756

752757

758+
## objconv ##
759+
760+
OBJCONV_SOURCE = objconv/objconv
761+
OBJCONV_TARGET = $(build_bindir)/objconv
762+
763+
objconv.zip:
764+
$(JLDOWNLOAD) $@ http://www.agner.org/optimize/objconv.zip
765+
objconv/config.status: objconv.zip
766+
unzip -d objconv $<
767+
cd objconv && unzip source.zip
768+
echo 1 > $@
769+
$(OBJCONV_SOURCE): objconv/config.status
770+
cd objconv && $(CXX) -o objconv -O2 *.cpp
771+
$(OBJCONV_TARGET): $(OBJCONV_SOURCE) | $(build_bindir)
772+
cp -f $< $@
773+
774+
clean-objconv:
775+
-rm -f $(OBJCONV_TARGET)
776+
distclean-objconv:
777+
-rm -rf objconv.zip objconv
778+
779+
get-objconv: objconv.zip
780+
configure-objconv: objconv/config.status
781+
compile-objconv: $(OBJCONV_SOURCE)
782+
check-objconv: compile-objconv
783+
install-objconv: $(OBJCONV_TARGET)
784+
785+
753786
## OpenBLAS ##
754787
# LAPACK is built into OpenBLAS by default
755788

@@ -791,7 +824,11 @@ endif
791824

792825
# 64-bit BLAS interface
793826
ifeq ($(USE_BLAS64), 1)
794-
OPENBLAS_BUILD_OPTS += INTERFACE64=1
827+
OPENBLAS_BUILD_OPTS += INTERFACE64=1 SYMBOLSUFFIX="64_"
828+
ifeq ($(OS), Darwin)
829+
OPENBLAS_BUILD_OPTS += OBJCONV=$(JULIAHOME)/deps/objconv/objconv
830+
$(OPENBLAS_OBJ_SOURCE): $(OBJCONV_SOURCE)
831+
endif
795832
endif
796833

797834
# Decide whether to build for 32-bit or 64-bit arch
@@ -827,6 +864,7 @@ endif
827864
mkdir -p openblas-$(OPENBLAS_VER) && \
828865
$(TAR) -C openblas-$(OPENBLAS_VER) --strip-components 1 -xf $<
829866
perl -i -ple 's/^\s*(EXTRALIB\s*\+=\s*-lSystemStubs)\s*$$/# $$1/g' openblas-$(OPENBLAS_VER)/Makefile.system
867+
cd openblas-$(OPENBLAS_VER) && patch -p1 < ../openblas-symbol-rename.patch
830868
echo 1 > $@
831869
$(OPENBLAS_OBJ_SOURCE): openblas-$(OPENBLAS_VER)/config.status
832870
$(MAKE) -C openblas-$(OPENBLAS_VER) $(OPENBLAS_BUILD_OPTS) || (echo "*** Clean the OpenBLAS build with 'make -C deps clean-openblas'. Rebuild with 'make OPENBLAS_USE_THREAD=0 if OpenBLAS had trouble linking libpthread.so, and with 'make OPENBLAS_TARGET_ARCH=NEHALEM' if there were errors building SandyBridge support. Both these options can also be used simultaneously. ***" && false)
@@ -989,12 +1027,28 @@ install-lapack: $(LAPACK_OBJ_TARGET)
9891027

9901028
## ARPACK ##
9911029
ARPACK_FFLAGS = $(GFORTBLAS_FFLAGS)
1030+
ARPACK_CFLAGS =
9921031

9931032
ifeq ($(USE_BLAS64), 1)
9941033
ifeq ($(USEIFC),1)
9951034
ARPACK_FFLAGS += -i8
9961035
else
9971036
ARPACK_FFLAGS += -fdefault-integer-8
1037+
ifeq ($(USE_SYSTEM_BLAS), 0)
1038+
ifneq ($(USE_INTEL_MKL), 1)
1039+
ARPACK_FFLAGS += -cpp -ffixed-line-length-none
1040+
ARPACK_OPENBLASFCNS1 = axpy copy gemv geqr2 lacpy lahqr lanhs larnv lartg lascl laset scal trevc trmm trsen
1041+
ARPACK_OPENBLASFCNS2 = dot ger labad laev2 lamch lanst lanv2 lapy2 larf larfg lasr nrm2 orm2r rot steqr swap
1042+
ARPACK_OPENBLASFCNS3 = dotc geru unm2r
1043+
ARPACK_OPENBLASFCNS4 = COPY LABAD LAMCH LANHS LANV2 LARFG ROT
1044+
ARPACK_FFLAGS += $(foreach fcn, $(ARPACK_OPENBLASFCNS1) $(ARPACK_OPENBLASFCNS2), -Ds$(fcn)=s$(fcn)_64 -Dd$(fcn)=d$(fcn)_64)
1045+
ARPACK_FFLAGS += $(foreach fcn, $(ARPACK_OPENBLASFCNS1) $(ARPACK_OPENBLASFCNS3), -Dc$(fcn)=c$(fcn)_64 -Dz$(fcn)=z$(fcn)_64)
1046+
ARPACK_FFLAGS += $(foreach fcn, $(ARPACK_OPENBLASFCNS4), -DS$(fcn)=S$(fcn)_64 -DD$(fcn)=D$(fcn)_64)
1047+
ARPACK_FFLAGS += -Dscnrm2=scnrm2_64 -Ddznrm2=dznrm2_64 -Dcsscal=csscal_64 -Dzdscal=zdscal_64
1048+
# CFLAGS are for the configure checks
1049+
ARPACK_CFLAGS += -Dsgemm_=sgemm_64_ -Dcheev_=cheev_64_
1050+
endif
1051+
endif
9981052
endif
9991053
endif
10001054

@@ -1007,7 +1061,7 @@ ARPACK_OBJ_TARGET = $(build_shlibdir)/libarpack.$(SHLIB_EXT)
10071061

10081062
ARPACK_MFLAGS = F77="$(FC)" MPIF77="$(FC)"
10091063
ARPACK_FFLAGS += $(FFLAGS) $(JFFLAGS)
1010-
ARPACK_FLAGS = --with-blas="$(LIBBLAS)" --with-lapack="$(LIBLAPACK)" --disable-mpi --enable-shared FFLAGS="$(ARPACK_FFLAGS)"
1064+
ARPACK_FLAGS = --with-blas="$(LIBBLAS)" --with-lapack="$(LIBLAPACK)" --disable-mpi --enable-shared FFLAGS="$(ARPACK_FFLAGS)" CFLAGS="$(ARPACK_CFLAGS)"
10111065
ifneq ($(OS),WINNT)
10121066
ARPACK_FLAGS += LDFLAGS="$(LDFLAGS) -Wl,-rpath,'$(build_libdir)'"
10131067
endif
@@ -1249,8 +1303,16 @@ SUITESPARSE_OBJ_SOURCE = SuiteSparse-$(SUITESPARSE_VER)/UMFPACK/Lib/libumfpack.a
12491303
SUITESPARSE_OBJ_TARGET = $(build_shlibdir)/libspqr.$(SHLIB_EXT)
12501304

12511305
ifeq ($(USE_BLAS64), 1)
1252-
UMFPACK_CONFIG = -DLONGBLAS='long long'
1253-
CHOLMOD_CONFIG = -DLONGBLAS='long long'
1306+
UMFPACK_CONFIG = -DLONGBLAS='long long'
1307+
CHOLMOD_CONFIG = -DLONGBLAS='long long'
1308+
SPQR_CONFIG = -DLONGBLAS='long long'
1309+
ifeq ($(USE_SYSTEM_BLAS), 0)
1310+
ifneq ($(USE_INTEL_MKL), 1)
1311+
UMFPACK_CONFIG += -DSUN64
1312+
CHOLMOD_CONFIG += -DSUN64
1313+
SPQR_CONFIG += -DSUN64
1314+
endif
1315+
endif
12541316
endif
12551317

12561318
SUITE_SPARSE_LIB = -lm
@@ -1264,7 +1326,7 @@ SUITE_SPARSE_LIB += -Wl,-rpath,'$(build_libdir)'
12641326
endif
12651327
SUITESPARSE_MFLAGS = CC="$(CC)" CXX="$(CXX)" F77="$(FC)" AR="$(AR)" RANLIB="$(RANLIB)" BLAS="$(LIBBLAS)" LAPACK="$(LIBLAPACK)" \
12661328
INSTALL_LIB="$(build_libdir)" INSTALL_INCLUDE="$(build_includedir)" LIB="$(SUITE_SPARSE_LIB)" \
1267-
UMFPACK_CONFIG="$(UMFPACK_CONFIG)" CHOLMOD_CONFIG="$(CHOLMOD_CONFIG)"
1329+
UMFPACK_CONFIG="$(UMFPACK_CONFIG)" CHOLMOD_CONFIG="$(CHOLMOD_CONFIG)" SPQR_CONFIG="$(SPQR_CONFIG)"
12681330

12691331
SuiteSparse-$(SUITESPARSE_VER).tar.gz:
12701332
$(JLDOWNLOAD) $@ http://faculty.cse.tamu.edu/davis/SuiteSparse/$@

0 commit comments

Comments
 (0)