# 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.18 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 # Power10 build needs gnu assembler in /opt/freeware/bin with "as" as the binary name. # And gcc used should be built without "with-as" configure option Patch0: openblas-AIX-changes-for-P10-with-GNU-Compiler.patch BuildRequires: m4 %ifos aix7.1 aix7.2 BuildRequires: gcc-gfortran >= 8.3.0 BuildRequires: libgomp >= 8.3.0 Requires: libgcc >= 8.3.0 Requires: libgfortran >= 8.3.0 Requires: libgomp >= 8.3.0 %else BuildRequires: gcc-gfortran >= 10.3.0 BuildRequires: libgomp >= 10.3.0 Requires: libgcc >= 10.3.0 Requires: libgfortran >= 10.3.0 Requires: libgomp >= 10.3.0 %endif %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} %ifnos aix7.1 aix7.2 %patch0 -p1 %endif # Duplicate source for 32 & 64 bits rm -rf /tmp/%{name}-%{version}-Source cp -pr . /tmp/%{name}-%{version}-Source rm -rf ..?* .[!.]* * %ifos aix7.1 aix7.2 for arch in power8 power6 %else for arch in power10 power8 %endif do mkdir -p 64bit/$arch cp -pr /tmp/%{name}-%{version}-Source/* 64bit/$arch done # 32bit POWER8/POWER10 target still uses POWER6 GEMM kernels mkdir -p 32bit/power8 cp -pr /tmp/%{name}-%{version}-Source/* 32bit/power8 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" # 32bit POWER8/POWER10 target still uses POWER6 GEMM kernels if [ ${OBJECT_MODE} -eq 32 ] then power_target="power8" else %ifos aix7.1 aix7.2 power_target="power8 power6" %else power_target="power10 power8" %endif fi cd ${OBJECT_MODE}bit for arch in $power_target 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/POWER10 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 # 32bit POWER8/POWER10 target still uses POWER6 GEMM kernels if [ ${OBJECT_MODE} -eq 32 ] then power_target="power8" else %ifos aix7.1 aix7.2 power_target="power8 power6" %else power_target="power10 power8" %endif fi cd ${OBJECT_MODE}bit for arch in $power_target 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 # Add 32bit .so file into OpenBLAS_POWER6 & OPENBLAS_POWER10 library archives cd 32bit/power8 %ifos aix7.1 aix7.2 /usr/bin/ar -q ${RPM_BUILD_ROOT}/%{_libdir}/OpenBLAS_POWER6/libopenblas.a libopenblas.so.0 %else /usr/bin/ar -q ${RPM_BUILD_ROOT}/%{_libdir}/OpenBLAS_POWER10/libopenblas.a libopenblas.so.0 %endif # create symbolic links in the original path towards POWER8 files ( %ifos aix7.1 aix7.2 default=OpenBLAS_POWER8 %else default=OpenBLAS_POWER10 %endif cd ${RPM_BUILD_ROOT}%{_libdir} ln -sf ${default}/libopenblas.a . mkdir -p ${RPM_BUILD_ROOT}%{_pkgconfigdir} cd ${RPM_BUILD_ROOT}%{_pkgconfigdir} ln -sf ../${default}/pkgconfig/openblas.pc . mkdir -p ${RPM_BUILD_ROOT}%{_includedir}/openblas cd ${RPM_BUILD_ROOT}%{_includedir}/openblas ln -sf ../${default}/* . ) %ifos aix7.1 aix7.2 %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 %else %post ProcVersion=`prtconf | grep "Processor Version:" | awk -F_ '{ print $2}'` if [ $ProcVersion -lt 10 ] then cd %{_libdir} ; ln -sf OpenBLAS_POWER8/libopenblas.a . echo "Since the Machine Processor Version is below Power 10, Power 8 code built OpenBLAS library is made default." fi %post devel ProcVersion=`prtconf | grep "Processor Version:" | awk -F_ '{ print $2}'` if [ $ProcVersion -lt 10 ] then cd %{_includedir}/openblas ; ln -sf ../OpenBLAS_POWER8/* . cd %{_pkgconfigdir} ; ln -sf ../OpenBLAS_POWER8/pkgconfig/openblas.pc . echo "Since the Machine Processor Version is below Power 10, Power 8 code built header & pkgconfig(.pc) files are made default." fi %endif %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 %ifos aix7.1 aix7.2 %{_libdir}/OpenBLAS_POWER6/libopenblas.a %else %{_libdir}/OpenBLAS_POWER10/libopenblas.a %endif %{_libdir}/OpenBLAS_POWER8/libopenblas.a %files devel %defattr(-,root,system,-) %{_includedir}/openblas %ifos aix7.1 aix7.2 %{_includedir}/OpenBLAS_POWER6 %{_libdir}/OpenBLAS_POWER6/pkgconfig %else %{_includedir}/OpenBLAS_POWER10 %{_libdir}/OpenBLAS_POWER10/pkgconfig %endif %{_includedir}/OpenBLAS_POWER8 %{_libdir}/OpenBLAS_POWER8/pkgconfig %{_libdir}/pkgconfig/openblas.pc %changelog * Tue Nov 16 2021 Ayappan P - 0.3.18-1 - Update to 0.3.18 - Add support for Power10 * 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