# By default, dotests are run. # No tests: rpmbuild -ba --without dotests *.spec %bcond_without dotests %global _libdir64 %{_libdir}64 %global _pkgconfigdir %{_libdir}/pkgconfig/ Summary: An optimized BLAS library based on GotoBLAS2 Name: openblas Version: 0.3.15 Release: 1 License: BSD Group: Development/Libraries URL: https://github.com/xianyi/OpenBLAS Source0: https://github.com/xianyi/OpenBLAS/archive/v%{version}/openblas-%{version}.tar.gz Patch0: openblas-Dont_cross_compile.patch # Patch reduced vs version for 0.3.6 #Patch1: openblas-0.3.8-power8-aix.patch #Patch2: openblas-power8-big-endian-fix.patch #Patch3: openblas-0.3.10-AIX-TARGETS.patch #Patch4: openblas-0.3.10-32BITS.patch #Patch5: openblas-0.3.10-AIX-NUM_CORES.patch BuildRequires: gcc-gfortran >= 8.3.0 BuildRequires: libgomp >= 8.3.0 BuildRequires: m4 Requires: libgcc >= 8.3.0 Requires: libgfortran >= 8.3.0 Requires: libgomp >= 8.3.0 %description OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version. It is an open source implementation of the BLAS (Basic Linear Algebra Subprograms) API with many hand-crafted optimizations for specific processor types. OpenBLAS adds optimized implementations of linear algebra kernels for several processor architectures. This version contains POWER 6 and POWER 8 builds. Depending on the processor running mode, either POWER6 or POWER8 files (libraries, headers, pkgconfig (.pc file)) will be set as default. This is done by the post installation script of this rpm. %package devel Group: Development/Libraries Summary: An optimized BLAS library based on GotoBLAS2 - development files Requires: %{name} = %{version}-%{release} %description devel Development files for OpenBLAS. %prep %setup -q -n OpenBLAS-%{version} %patch0 -p0 #%patch3 -p1 #%patch4 -p1 -b .32bit #%patch5 -p1 -b .AIX-NUM # Duplicate source for 32 & 64 bits rm -rf /tmp/%{name}-%{version}-Source cp -pr . /tmp/%{name}-%{version}-Source rm -rf ..?* .[!.]* * for mode in 32bit 64bit do for arch in power8 power6 do mkdir -p $mode/$arch cp -pr /tmp/%{name}-%{version}-Source/* $mode/$arch done done rm -rf /tmp/%{name}-%{version}-Source %build # setup environment for 32-bit and 64-bit builds export AR="/usr/bin/ar -X32_64" export NM="/usr/bin/nm -X32_64" build_openblas() { set -x export OBJECT_MODE=$1 export CC="gcc -maix${OBJECT_MODE}" export CXX="g++ -maix${OBJECT_MODE}" export FC="gfortran -maix${OBJECT_MODE}" if [ ${OBJECT_MODE} -eq 64 ] then export LDFLAGS="-Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib " else export CFLAGS="-D_LARGE_FILES" export LDFLAGS="-Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000" fi TRACE="--trace VERBOSE=1" cd ${OBJECT_MODE}bit for arch in power8 power6 do cd $arch gmake $TRACE BINARY=${OBJECT_MODE} TARGET=$(echo $arch | /usr/bin/tr '[a-z]' '[A-Z]') #This needs CreateExportList which comes from XLC fileset. #So better we use the one from GNU libtool #/usr/vac/bin/CreateExportList -X64 openblas.exp libopenblas.a `echo /usr/bin/nm -X32_64 | /usr/bin/sed -e 's/B\([^B]*\)$/P\1/'` -PCpgl libopenblas.a | \ /usr/bin/awk '{ if ((($ 2 == "T") || ($ 2 == "D") || ($ 2 == "B") || ($ 2 == "W") || ($ 2 == "V") || ($ 2 == "Z")) \ && (substr($ 1,1,1) != ".")) { if (($ 2 == "W") || ($ 2 == "V") || ($ 2 == "Z")) { print $ 1 " weak" } \ else { print $ 1 } } }' | /usr/bin/sort -u > openblas.exp # 32bit POWER8 target still uses POWER6 GEMM kernels so it produces the library as "power6p" instead of "power8p" if [ ${OBJECT_MODE} -eq 32 ] then $CC -shared libopenblas_power6p-r%{version}.a -o libopenblas.so.0 $LDFLAGS -lm -lpthread -lgfortran -lgomp -Wl,-bE:openblas.exp -Wl,-bbigtoc else $CC -shared libopenblas_${arch}p-r%{version}.a -o libopenblas.so.0 $LDFLAGS -lm -lpthread -lgfortran -lgomp -Wl,-bE:openblas.exp -Wl,-bbigtoc fi cd .. done cd .. } # first build the 64-bit version build_openblas 64 # now build the 32-bit version build_openblas 32 %install [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT} export AR="/usr/bin/ar -X32_64" export NM="/usr/bin/nm -X32_64" PATH=/opt/freeware/bin:$PATH install_openblas() { set -x export OBJECT_MODE=$1 export CC="gcc -maix${OBJECT_MODE}" export CXX="g++ -maix${OBJECT_MODE}" export FC="gfortran -maix${OBJECT_MODE}" if [ ${OBJECT_MODE} -eq 64 ] then export LDFLAGS="-Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib " else export CFLAGS="-D_LARGE_FILES" export LDFLAGS="-Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000" fi cd ${OBJECT_MODE}bit for arch in power8 power6 do TARGET=$(echo $arch | /usr/bin/tr '[a-z]' '[A-Z]') cd $arch make OPENBLAS_INCLUDE_DIR=%{_includedir}/openblas install DESTDIR=${RPM_BUILD_ROOT} PREFIX=%{_prefix} if [ ${OBJECT_MODE} -eq 32 ] then echo "No need to copy these files once again for 32bit, as both are same" else mkdir -p ${RPM_BUILD_ROOT}%{_includedir}/OpenBLAS_${TARGET} /usr/bin/mv ${RPM_BUILD_ROOT}%{_includedir}/openblas/*.h ${RPM_BUILD_ROOT}%{_includedir}/OpenBLAS_${TARGET} mkdir -p ${RPM_BUILD_ROOT}%{_libdir}/OpenBLAS_${TARGET} /usr/bin/mv ${RPM_BUILD_ROOT}%{_libdir}/pkgconfig ${RPM_BUILD_ROOT}%{_libdir}/OpenBLAS_${TARGET} fi /usr/bin/rm ${RPM_BUILD_ROOT}/%{_libdir}/libopenblas.* /usr/bin/ar -q ${RPM_BUILD_ROOT}/%{_libdir}/OpenBLAS_${TARGET}/libopenblas.a libopenblas.so.0 cd .. done cd .. } install_openblas 64 install_openblas 32 # create symbolic links in the original path towards POWER8 files ( cd ${RPM_BUILD_ROOT}%{_libdir} ln -sf OpenBLAS_POWER8/libopenblas.a . mkdir -p ${RPM_BUILD_ROOT}%{_pkgconfigdir} cd ${RPM_BUILD_ROOT}%{_pkgconfigdir} ln -sf ../OpenBLAS_POWER8/pkgconfig/openblas.pc . mkdir -p ${RPM_BUILD_ROOT}%{_includedir}/openblas cd ${RPM_BUILD_ROOT}%{_includedir}/openblas ln -sf ../OpenBLAS_POWER8/* . ) %check %if %{without dotests} echo "*** Skipping tests" exit 0 %endif # without dotests check_openblas() { set -x export OBJECT_MODE=$1 export CC="gcc -maix${OBJECT_MODE}" export CXX="g++ -maix${OBJECT_MODE}" export FC="gfortran -maix${OBJECT_MODE}" if [ ${OBJECT_MODE} -eq 64 ] then export LDFLAGS="-Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib " else export LDFLAGS="-Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000" fi cd ${OBJECT_MODE}bit for arch in power8 power6 do cd $arch cd utest $CC -I.. -I. utest_main2.c ../libopenblas.a -lgomp -lpthread -lm -o utest2 ( ./utest2 || true ) cd .. cd .. done cd .. } check_openblas 64 check_openblas 32 %pre # Processor Version: PV_7_Compat # Processor Version: PV_6_Compat # Processor Version: PV_5_Compat ProcVersion=`prtconf | grep "Processor Version:" | awk -F_ '{ print $2}'` #echo $ProcVersion if [ $ProcVersion -lt 6 ] then echo "This rpm will only work with Power6 (and above) compatibility mode." echo "prtconf: " prtconf | grep "Processor Version:" exit 1 fi %post ProcVersion=`prtconf | grep "Processor Version:" | awk -F_ '{ print $2}'` if [ $ProcVersion -lt 8 ] then cd %{_libdir} ; ln -sf OpenBLAS_POWER6/libopenblas.a . echo "Since the Machine Processor Version is below Power 8, Power 6 code built OpenBLAS library is made default." fi %post devel ProcVersion=`prtconf | grep "Processor Version:" | awk -F_ '{ print $2}'` if [ $ProcVersion -lt 8 ] then cd %{_includedir}/openblas ; ln -sf ../OpenBLAS_POWER6/* . cd %{_pkgconfigdir} ; ln -sf ../OpenBLAS_POWER6/pkgconfig/openblas.pc . echo "Since the Machine Processor Version is below Power 8, Power 6 code built header & pkgconfig(.pc) files are made default." fi %clean [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT} %files %defattr(-,root,system,-) %doc 32bit/power8/LICENSE 32bit/power8/README.md 32bit/power8/USAGE.md 32bit/power8/GotoBLAS_00License.txt %{_libdir}/libopenblas.a %{_libdir}/OpenBLAS_POWER6/libopenblas.a %{_libdir}/OpenBLAS_POWER8/libopenblas.a %files devel %defattr(-,root,system,-) %{_includedir}/openblas %{_includedir}/OpenBLAS_POWER6 %{_includedir}/OpenBLAS_POWER8 %{_libdir}/OpenBLAS_POWER6/pkgconfig %{_libdir}/OpenBLAS_POWER8/pkgconfig %{_libdir}/pkgconfig/openblas.pc %changelog * Tue May 18 2021 Ayappan P - 0.3.15-1 - Update to 0.3.15 * Fri Jun 26 2020 Étienne Guesnet - 0.3.10-1 - New version 0.3.10 - Add 32bits - Add check section - Add devel subpackage - 32 bit is available only on POWER 6 * Thu Aug 29 2019 Ayappan P - 0.3.6-1 - Update to 0.3.6 - Power8 code build as well * Wed Mar 20 2019 Ayappan P - 0.3.5-1 - First port to AIX Toolbox