diff --git a/.gitignore b/.gitignore index e69de29..7febb18 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/v0.2.5.tar.gz diff --git a/openblas-0.2.5-libname.patch b/openblas-0.2.5-libname.patch new file mode 100644 index 0000000..e30ab8b --- /dev/null +++ b/openblas-0.2.5-libname.patch @@ -0,0 +1,24 @@ +diff -up OpenBLAS-0.2.5/Makefile.system.orig OpenBLAS-0.2.5/Makefile.system +--- OpenBLAS-0.2.5/Makefile.system.orig 2012-11-27 01:24:53.000000000 +0200 ++++ OpenBLAS-0.2.5/Makefile.system 2012-12-24 16:13:57.316689688 +0200 +@@ -758,16 +758,16 @@ ifndef SMP + LIBNAME = $(LIBPREFIX)_$(LIBCORE)$(REVISION).$(LIBSUFFIX) + LIBNAME_P = $(LIBPREFIX)_$(LIBCORE)$(REVISION)_p.$(LIBSUFFIX) + else +-LIBNAME = $(LIBPREFIX)_$(LIBCORE)p$(REVISION).$(LIBSUFFIX) +-LIBNAME_P = $(LIBPREFIX)_$(LIBCORE)p$(REVISION)_p.$(LIBSUFFIX) ++LIBNAME = $(LIBPREFIX)_$(LIBCORE)$(REVISION).$(LIBSUFFIX) ++LIBNAME_P = $(LIBPREFIX)_$(LIBCORE)$(REVISION)_p.$(LIBSUFFIX) + endif + else + ifndef SMP + LIBNAME = $(LIBPREFIX)$(REVISION).$(LIBSUFFIX) + LIBNAME_P = $(LIBPREFIX)$(REVISION)_p.$(LIBSUFFIX) + else +-LIBNAME = $(LIBPREFIX)p$(REVISION).$(LIBSUFFIX) +-LIBNAME_P = $(LIBPREFIX)p$(REVISION)_p.$(LIBSUFFIX) ++LIBNAME = $(LIBPREFIX)$(REVISION).$(LIBSUFFIX) ++LIBNAME_P = $(LIBPREFIX)$(REVISION)_p.$(LIBSUFFIX) + endif + endif + diff --git a/openblas-0.2.5-system_lapack.patch b/openblas-0.2.5-system_lapack.patch new file mode 100644 index 0000000..6eda04a --- /dev/null +++ b/openblas-0.2.5-system_lapack.patch @@ -0,0 +1,81 @@ +diff -up xianyi-OpenBLAS-e42259c.mod/Makefile.orig xianyi-OpenBLAS-e42259c.mod/Makefile +--- xianyi-OpenBLAS-e42259c.mod/Makefile.orig 2012-11-26 11:32:56.000000000 +0200 ++++ xianyi-OpenBLAS-e42259c.mod/Makefile 2012-12-12 23:06:03.076579588 +0200 +@@ -199,18 +199,9 @@ hpl_p : + fi; \ + done + +-ifeq ($(NO_LAPACK), 1) +-netlib : ++netlib : ++ -@$(MAKE) -C netliblapack + +-else +-netlib : lapack-3.4.2 patch.for_lapack-3.4.2 $(NETLIB_LAPACK_DIR)/make.inc +-ifndef NOFORTRAN +- -@$(MAKE) -C $(NETLIB_LAPACK_DIR) lapacklib +-endif +-ifndef NO_LAPACKE +- -@$(MAKE) -C $(NETLIB_LAPACK_DIR) lapackelib +-endif +-endif + + prof_lapack : lapack-3.4.2 $(NETLIB_LAPACK_DIR)/make.inc + -@$(MAKE) -C $(NETLIB_LAPACK_DIR) lapack_prof +@@ -241,37 +232,6 @@ endif + -@cat make.inc >> $(NETLIB_LAPACK_DIR)/make.inc + endif + +-lapack-3.4.2 : lapack-3.4.2.tgz +-ifndef NOFORTRAN +-ifndef NO_LAPACK +- @if test `$(MD5SUM) lapack-3.4.2.tgz | $(AWK) '{print $$1}'` = 61bf1a8a4469d4bdb7604f5897179478; then \ +- echo $(TAR) zxf $< ;\ +- $(TAR) zxf $< && (cd $(NETLIB_LAPACK_DIR); $(PATCH) -p1 < ../patch.for_lapack-3.4.2) ;\ +- rm -f $(NETLIB_LAPACK_DIR)/lapacke/make.inc ;\ +- else \ +- rm -rf $(NETLIB_LAPACK_DIR) ;\ +- echo " Cannot download lapack-3.4.2.tgz or the MD5 check sum is wrong (Please use orignal)."; \ +- exit 1; \ +- fi +-endif +-endif +- +-LAPACK_URL=http://www.netlib.org/lapack/lapack-3.4.2.tgz +- +-lapack-3.4.2.tgz : +-ifndef NOFORTRAN +-#http://stackoverflow.com/questions/7656425/makefile-ifeq-logical-or +-ifeq ($(OSNAME), $(filter $(OSNAME),Darwin NetBSD)) +- curl -O $(LAPACK_URL) +-else +-ifeq ($(OSNAME), FreeBSD) +- fetch $(LAPACK_URL) +-else +- wget $(LAPACK_URL) +-endif +-endif +-endif +- + large.tgz : + ifndef NOFORTRAN + -wget http://www.netlib.org/lapack/timing/large.tgz +@@ -320,4 +280,4 @@ clean :: + rm -rf $(NETLIB_LAPACK_DIR) ;\ + fi + @rm -f *.grd Makefile.conf_last config_last.h +- @echo Done. +\ No newline at end of file ++ @echo Done. +diff -up xianyi-OpenBLAS-e42259c.mod/Makefile.system.orig xianyi-OpenBLAS-e42259c.mod/Makefile.system +--- xianyi-OpenBLAS-e42259c.mod/Makefile.system.orig 2012-11-26 11:32:56.000000000 +0200 ++++ xianyi-OpenBLAS-e42259c.mod/Makefile.system 2012-12-12 22:56:06.147413758 +0200 +@@ -10,7 +10,7 @@ TOPDIR = . + endif + + ifndef NETLIB_LAPACK_DIR +-NETLIB_LAPACK_DIR = $(TOPDIR)/lapack-3.4.2 ++NETLIB_LAPACK_DIR = $(TOPDIR)/netliblapack + endif + + # Default C compiler diff --git a/openblas.spec b/openblas.spec new file mode 100644 index 0000000..d6f1577 --- /dev/null +++ b/openblas.spec @@ -0,0 +1,254 @@ +Name: openblas +Version: 0.2.5 +Release: 6%{?dist} +Summary: An optimized BLAS library based on GotoBLAS2 +Group: Development/Libraries +License: BSD +URL: https://github.com/xianyi/OpenBLAS/ +Source0: https://github.com/xianyi/OpenBLAS/archive/v0.2.5.tar.gz +# Use system lapack +Patch0: openblas-0.2.5-system_lapack.patch +# Drop extra p from threaded library name +Patch1: openblas-0.2.5-libname.patch +BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) + +BuildRequires: gcc-gfortran +# For execstack +BuildRequires: prelink +# LAPACK +BuildRequires: lapack-static + +# Compability for old versions of GCC +%if 0%{?rhel} == 5 +%global avxflag NO_AVX=1 +%endif + +# Do we have LAPACKE? (Needs at least lapack 3.4.0) +%if 0%{?fedora} > 16 +%global lapacke 1 +%else +%global lapacke 0 +%endif + +%global base_description \ +OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version. The\ +project is supported by the Lab of Parallel Software and Computational Science,\ +ISCAS. http://www.rdcps.ac.cn + + +%description +%{base_description} + +%package openmp +Summary: An optimized BLAS library based on GotoBLAS2, OpenMP version +Group: Development/Libraries + + +%description openmp +%{base_description} + +This package contains the library compiled with OpenMP support. + +%package threads +Summary: An optimized BLAS library based on GotoBLAS2, pthreads version +Group: Development/Libraries + +%description threads +%{base_description} + +This package contains the library compiled with threading support. + +%package devel +Summary: Development headers and libraries for OpenBLAS +Group: Development/Libraries +Requires: %{name}%{?_isa} = %{version}-%{release} +Requires: %{name}-openmp%{?_isa} = %{version}-%{release} +Requires: %{name}-threads%{?_isa} = %{version}-%{release} + +%description devel +%{base_description} + +This package contains the development headers and libraries. + +%package static +Summary: Static version of OpenBLAS +Group: Development/Libraries +Requires: %{name}-devel = %{version}-%{release} + +%description static +%{base_description} + +This package contains the static libraries. + +%prep +%setup -q -c -T + +# Untar source +tar zxf %{SOURCE0} +cd OpenBLAS-%{version} +%patch0 -p1 -b .netlib_lapack +%patch1 -p1 -b .libname + +# Setup LAPACK +mkdir netliblapack +cd netliblapack +ar x %{_libdir}/liblapack_pic.a +# Get rid of duplicate functions +for f in getf2 getrf getrs laswp lauu2 lauum potf2 potrf trti2 trtri; do + \rm {c,d,s,z}$f.o +done + +# LAPACKE +%if %{lapacke} +ar x %{_libdir}/liblapacke.a +%endif + +# Create makefile +echo "TOPDIR = .." > Makefile +echo "include ../Makefile.system" >> Makefile +echo "COMMONOBJS = \\" >> Makefile +for i in *.o; do + echo "$i \\" >> Makefile +done +echo -e "\n\ninclude \$(TOPDIR)/Makefile.tail" >> Makefile + +%if %{lapacke} +# Copy include files +cp -a %{_includedir}/lapacke . +%endif +cd .. + +# Make serial, threaded and OpenMP versions +cd .. +cp -ar OpenBLAS-%{version} openmp +cp -ar OpenBLAS-%{version} threaded +mv OpenBLAS-%{version} serial + +%build +%if %{lapacke} +LAPACKE="NO_LAPACKE=0" +%else +LAPACKE="NO_LAPACKE=1" +%endif + +make -C serial TARGET=CORE2 DYNAMIC_ARCH=1 USE_THREAD=0 USE_OPENMP=0 FC=gfortran CC=gcc COMMON_OPT="%{optflags}" NUM_THREADS=32 %{?avxflag} $LAPACKE +make -C threaded TARGET=CORE2 DYNAMIC_ARCH=1 USE_THREAD=1 USE_OPENMP=0 FC=gfortran CC=gcc COMMON_OPT="%{optflags}" NUM_THREADS=32 LIBPREFIX="libopenblasp" %{?avxflag} $LAPACKE +# USE_THREAD determines use of SMP, not of pthreads +make -C openmp TARGET=CORE2 DYNAMIC_ARCH=1 USE_THREAD=1 USE_OPENMP=1 FC=gfortran CC=gcc COMMON_OPT="%{optflags}" NUM_THREADS=32 LIBPREFIX="libopenblaso" %{?avxflag} $LAPACKE + + +%install +rm -rf %{buildroot} +# Install serial library and headers +make -C serial USE_THREAD=0 PREFIX=%{buildroot}%{_usr} install + +# Move include files to package specific directory, so that they don't clash with reference BLAS and LAPACK +mkdir %{buildroot}%{_includedir}/%{name} +mv %{buildroot}%{_includedir}/*.h %{buildroot}%{_includedir}/%{name} + +# Put libraries in correct location +if [ %_lib != lib ]; then + mkdir -p %{buildroot}%{_libdir} + mv %{buildroot}/usr/lib/libopen* %{buildroot}%{_libdir} +fi + +# Fix name of static library +slibname=`basename %{buildroot}%{_libdir}/libopenblas-*.so .so` +mv %{buildroot}%{_libdir}/${slibname}.a %{buildroot}%{_libdir}/lib%{name}.a + +# Install the OpenMP library +olibname=`echo ${slibname} | sed "s|lib%{name}|lib%{name}o|g"` +install -D -p -m 755 openmp/${olibname}.so %{buildroot}%{_libdir}/${olibname}.so +install -D -p -m 644 openmp/${olibname}.a %{buildroot}%{_libdir}/lib%{name}o.a + +# Install the threaded library +plibname=`echo ${slibname} | sed "s|lib%{name}|lib%{name}p|g"` +install -D -p -m 755 threaded/${plibname}.so %{buildroot}%{_libdir}/${plibname}.so +install -D -p -m 644 threaded/${plibname}.a %{buildroot}%{_libdir}/lib%{name}p.a + +# Fix source permissions (also applies to LAPACK) +find -name \*.f -exec chmod 644 {} \; + +# Fix symlinks +pushd %{buildroot}%{_libdir} +# Serial libraries +ln -sf ${slibname}.so lib%{name}.so +ln -sf ${slibname}.so lib%{name}.so.0 +# OpenMP libraries +ln -sf ${olibname}.so lib%{name}o.so +ln -sf ${olibname}.so lib%{name}o.so.0 +# Threaded libraries +ln -sf ${plibname}.so lib%{name}p.so +ln -sf ${plibname}.so lib%{name}p.so.0 + +# Get rid of executable stacks +for lib in %{buildroot}%{_libdir}/libopenblas{,o,p}-*.so; do + execstack -c $lib +done + +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig + +%post openmp -p /sbin/ldconfig +%postun openmp -p /sbin/ldconfig + +%post threads -p /sbin/ldconfig +%postun threads -p /sbin/ldconfig + +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root,-) +%doc serial/Changelog.txt serial/GotoBLAS* serial/LICENSE +%{_libdir}/lib%{name}-*.so +%{_libdir}/lib%{name}.so.* + +%files openmp +%defattr(-,root,root,-) +%{_libdir}/lib%{name}o-*.so +%{_libdir}/lib%{name}o.so.* + +%files threads +%defattr(-,root,root,-) +%{_libdir}/lib%{name}p-*.so +%{_libdir}/lib%{name}p.so.* + +%files devel +%defattr(-,root,root,-) +%{_libdir}/lib%{name}.so +%{_libdir}/lib%{name}o.so +%{_libdir}/lib%{name}p.so +%{_includedir}/%{name} + +%files static +%defattr(-,root,root,-) +%{_libdir}/lib%{name}.a +%{_libdir}/lib%{name}o.a +%{_libdir}/lib%{name}p.a + +%changelog +* Mon Dec 24 2012 Susi Lehtola - 0.2.5-6 +- Review fixes. + +* Fri Dec 21 2012 Susi Lehtola - 0.2.5-5 +- Disable LAPACKE support on distributions where it is not available due to + a too old version of lapack. + +* Mon Dec 17 2012 Susi Lehtola - 0.2.5-4 +- Don't use reference LAPACK functions that have optimized implementation. + +* Wed Dec 12 2012 Susi Lehtola - 0.2.5-3 +- Use system version of LAPACK. + +* Mon Nov 26 2012 Susi Lehtola - 0.2.5-2 +- Fixed 32-bit build, and build on EPEL 5. + +* Mon Nov 26 2012 Susi Lehtola - 0.2.5-1 +- Update to 0.2.5. + +* Thu Oct 06 2011 Jussi Lehtola - 0.1-2.alpha2.4 +- Added documentation. + +* Sun Sep 18 2011 Jussi Lehtola - 0.1-1.alpha2.4 +- First release. diff --git a/sources b/sources index e69de29..981b00c 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +f1d80f2ebbba2cbd019a86b6f1cbb165 v0.2.5.tar.gz