Blob Blame History Raw
# Copyright (c) 2015, 2016  Dave Love, University of Liverpool
# Copyright (c) 2018  Dave Love, University of Manchester
# MIT licence, per Fedora policy

# Notes:
# rpmlint complains unused-direct-shlib-dependency and
# undefined-non-weak-symbol, but those seem to be deliberate -- see the
# use of --no-as-needed, --as-needed in the build.
# The specific compiler flags used are presumably chosen sensibly for the
# code, and there's no likely security implication for this.

# ix86 isn't built -- see
# https://github.com/hfp/libxsmm/issues/103#issuecomment-256887962

# The el6 compiler is too old, but we build for el6 in copr from the
# same source.  The el7 system compiler doesn't do avx512.
%if 0%{?el6}%{?el7}
%bcond_without devtoolset
%endif

# For historical reasons, these are out of step with the ABI
# versioning used by the base source.
%global somajor 1
%global sominor 9
%global soupd 4

Name:		libxsmm
Version:	1.9
Release:	3%{?dist}
Summary:	Small dense or sparse matrix multiplications and convolutions for x86_64
License:	BSD
URL:		https://github.com/hfp/libxsmm
Source0:	https://github.com/hfp/libxsmm/archive/%version/%name-%version.tar.gz
BuildRequires:	python2 openblas-devel
%if %{with devtoolset}
# Relase 6 supports avx512 and uses the same libgfortran version as
# the system compiler.
BuildRequires:	devtoolset-6-gcc-gfortran devtoolset-6-gcc-c++
%else
BuildRequires:	gcc-gfortran gcc-c++
%endif
ExclusiveArch:	x86_64

# Remove /bin/sh, /bin/bash dependencies from -doc (not actually
# required by packaging guidelines)
%global __requires_exclude /bin/.*sh$
%{?filter_setup:
%filter_from_requires /\/bin\/.*sh$/d
%filter_setup
}


%description
LIBXSMM is a library for small dense and small sparse matrix-matrix
multiplications, as well as for deep learning primitives such as small
convolutions targeting Intel Architecture (x86).  The library
generates code for the following instruction set extensions: Intel
SSE, Intel AVX, Intel AVX2, IMCI (KNCni) for Intel Xeon Phi
coprocessors ("KNC"), and Intel AVX‑512 as found in the Intel Xeon Phi
processor family ("KNL") and future Intel Xeon processors.  Small
convolutions are currently only optimized for Intel AVX‑512.
Historically the library was solely targeting the Intel Many
Integrated Core Architecture "MIC") using intrinsic functions.
Currently, optimized assembly code targets all aforementioned
instruction set extensions (static code generation), and Just‑In‑Time
(JIT) code generation targets Intel AVX and beyond.


%package	devel
Summary:	Development files for %name
Requires:	%name%{?_isa} = %version-%release

%description	devel
The %name-devel package contains libraries and header files for
developing applications that use %name.

%package	doc
Summary:	Documentation for %name
BuildArch:	noarch

%description	doc
Documentation for %name.


%prep
%setup -q
# MS-Windows stuff that rpmlint would complain about
find samples -name \*.vcxproj | xargs rm
chmod 0644 src/template/libxsmm_dnn_convolution_winograd_forward_custom_custom_input_trans_alpha6_avx512.tpl.c
# README would clobber the main one, and the others would be dangling links
rm documentation/{README,LICENSE,CONTRIBUTING}.md
# This should be obviated by
# https://github.com/hfp/libxsmm/commit/1913104cee619caa920115710a9c14a74d98fc16
# which doesn't apply cleanly.
for f in $(find -name \*.py); do
  sed -i -e 's;/usr/bin/env python;/usr/bin/python2;' $f
done


%build
%if %{with devtoolset}
. /opt/rh/devtoolset-6/enable
%endif
# OpenMP is only used by libxsmmext, so no need to turn it off.
# Avoid the ld hardening flags, which are taken care of by the library
# build system to the extent they don't affect perfromance.
# -lm and -ldl are neded for the test, for which the LDFLAGS need to be
# consistent.
%global makeflags STATIC=0 SYM=1 AVX=0 VERSION_MAJOR=%somajor VERSION_MINOR=%sominor VERSION_UPDATE=%soupd PYTHON=/usr/bin/python2
make %{?_smp_mflags} %makeflags


%install
# Supply STATIC etc. since this actually builds stuff (a bug?),
# and otherwise we end up with bits built wrongly.
make install PREFIX=%buildroot%_prefix POUTDIR=$(basename %_libdir) %makeflags
mkdir -p %buildroot%_libdir
cp -a lib/*.so* %buildroot%_libdir
%if !0%{?el6} || %{with devtoolset}
mkdir -p %buildroot%_fmoddir
mv %buildroot%_includedir/libxsmm.mod %buildroot%_fmoddir
%endif
rm -r %buildroot%_datadir/libxsmm
# Build artefacts
find samples -name .make | xargs rm
cp Makefile.inc samples		# included by the sub-directories
echo "These are set up to be built in the original source tree.
You will have to adjust the make files to use an installed version." >samples/README

# Avoid rpmlint no-ldconfig-symlink
pushd %buildroot%_libdir
for i in *.so.*.*; do
    ln -sf $i $(echo $i | sed "s/\\.[0-9][0-9]*$//")
done
popd


%check
# Fixme: the test gives numerical errors inconsistently with openblas
# 0.3.1/gcc 8.1 on koji when the thread count isn't 1; sometimes 2
# works.
OMP_NUM_THREADS=1 make test-cp2k %makeflags
rm -r samples/cp2k/{cp2k,build,.make,.state}


%ldconfig_scriptlets


%files
%license LICENSE.md
%_libdir/libxsmm*.so.%{somajor}*

%files devel
%doc README.md
%_libdir/libxsmm*.so
%_includedir/libxsmm.f
%_includedir/libxsmm*.h
%_bindir/libxsmm_gemm_generator
%_bindir/libxsmm_conv_generator
%_bindir/libxsmm_convwino_generator
# Get the module directory owned.  Currently in Fedora, gfortran owns
# %%_fmoddir, but not %%_fmoddir/..
# In el6, el7, it doesn't own either, but el6's gfortran is too old to be used.
%if ! 0%{?el6} || %{with devtoolset}
%dir %_fmoddir/..
%dir %_fmoddir
%_fmoddir/*.mod
%endif


%files doc
%doc README.md documentation/* samples CONTRIBUTING.md
%license LICENSE.md


%changelog
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.9-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Wed Jul  4 2018 Dave Love <loveshack@fedoraproject.org> - 1.9-2
- Use python2 exlicitly in scripts
- Use single thread in %%check to fix FTBFS
- Use ldconfig_scriptlets
- Don't define LDFLAGS

* Wed Mar 21 2018 Dave Love <loveshack@fedoraproject.org> - 1.9-1
- Update to 1.9 (#1557708)
- Use devtoolset-6, not -7 for EPEL
- Don't avoid SSE (assumes sse3, which seems unlikely to cause problems)
- BR python2, per new policy
- Set VERSION_UPDATE for soname to avoid going backwards
- Fix issues with doc files

* Thu Mar  8 2018 Dave Love <loveshack@fedoraproject.org> - 1.8.3-1
- Update to 1.8.3 (#1528828)
- Fix running test
- Modify %%files for distribution changes and to specify lib soversion

* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.8.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Tue Dec 19 2017 Dave Love <loveshack@fedoraproject.org> - 1.8.1-4
- Don't run test
- Update possible devtoolset usage

* Sun Oct 29 2017 Dave Love <loveshack@fedoraproject.org> - 1.8.1-3
- Fix spurious executable permission
- Reinstate %%check
- Build with AVX=0

* Fri Oct 27 2017 Dave Love <loveshack@fedoraproject.org> - 1.8.1-2
- Fix bogus specification of soversion
  Actually kept at 1.8, not the intended 2.0, despite a few ABI differences
  from version 1.8.

* Thu Oct 26 2017 Dave Love <loveshack@fedoraproject.org> - 1.8.1-1
- New version
- Drop libxsmm-make.patch

* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.8-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild

* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.8-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Fri Jul 07 2017 Igor Gnatenko <ignatenko@redhat.com> - 1.8-2
- Rebuild due to bug in RPM (RHBZ #1468476)

* Tue May  2 2017 Dave Love <loveshack@fedoraproject.org> - 1.8-1
- Update soversion
- Ship libxsmm_convwino_generator
- New version

* Mon Feb 13 2017 Dave Love <loveshack@fedoraproject.org> - 1.6.3-1
- New version
  (Moving past 1.6.3 means more serious ABI changes.)

* Sun Feb 05 2017 Kalev Lember <klember@redhat.com> - 1.6.1-2
- Rebuilt for libgfortran soname bump

* Wed Dec  7 2016 Dave Love <loveshack@fedoraproject.org> - 1.6.1-1
- New version
- Some ABI incompatibility, but kept major sover as not made stable yet
  and in view of https://github.com/hfp/libxsmm/issues/120

* Wed Nov  9 2016 Dave Love <loveshack@fedoraproject.org> - 1.5.2-2
- Remove -doc dependencies

* Fri Nov  4 2016 Dave Love <loveshack@fedoraproject.org> - 1.5.2-1
- New version

* Thu Nov  3 2016 Dave Love <loveshack@fedoraproject.org> - 1.5.1-2
- Clean samples .make files too
- Use OMP build default
- Define FCFLAGS, LDFLAGS

* Mon Oct 31 2016 Dave Love <loveshack@fedoraproject.org> - 1.5.1-1
- New version, fixing interface bug
- Spec fixes from review
- Add samples to doc

* Wed Oct 26 2016 Dave Love <loveshack@fedoraproject.org> - 1.5-4
- Don't install .mod file directly in _includedir
- Don't build for ix86
- BR python

* Tue Oct 11 2016 Dave Love <loveshack@fedoraproject.org> - 1.5-3
- Install with STATIC=0
- Avoid sse3
- Fix Fortran modules installation and %%_fmoddir ownership

* Wed Oct  5 2016 Dave Love <loveshack@fedoraproject.org> - 1.5-2
- Fix installation of libraries

* Wed Oct  5 2016 Dave Love <loveshack@fedoraproject.org> - 1.5-1
- New version
- Remove %%check (run in %%build)

* Sat Aug 20 2016 Dave Love <loveshack@fedoraproject.org> - 1.4.4-2
- Drop devtoolset on el6 (not needed)

* Thu Aug 18 2016 Dave Love <loveshack@fedoraproject.org> - 1.4.4-1
- New version, with bumped soname
- Drop patch
- Modify install section

* Sat May 21 2016 Dave Love <loveshack@fedoraproject.org> - 1.4.3-1
- New version
- Fix debuginfo

* Mon May  9 2016 Dave Love <loveshack@fedoraproject.org> - 1.4.1-1
- New version
- Link --as-needed

* Mon Apr 25 2016 Dave Love <loveshack@fedoraproject.org> - 1.4-2
- Use PREFETCH=1

* Wed Apr  6 2016 Dave Love <loveshack@fedoraproject.org> - 1.4-1
- New version

* Fri Apr  1 2016 Dave Love <loveshack@fedoraproject.org> - 1.3-2
- Install README.md, and maybe README.EPEL6

* Fri Apr  1 2016 Dave Love <loveshack@fedoraproject.org> - 1.3-1
- New version
- Sanitize spec a bit

* Mon Feb 22 2016 Dave Love <loveshack@fedoraproject.org> - 1.2-1
- New version

* Sun Jan 24 2016 Dave Love <loveshack@fedoraproject.org> - 1.1.1-2
- Install Fortran module in %%_fmoddir

* Wed Dec 30 2015 Dave Love <loveshack@fedoraproject.org> - 1.1.1-1
- New version
- Add check
- BR python
- Make it serial, not openmp, for now
- Add doc subpackage

* Wed Dec  2 2015 Dave Love <loveshack@fedoraproject.org> - 1.0.1-1
- New version

* Wed Oct  7 2015 Dave Love <loveshack@fedoraproject.org> - 0.9.1-1
- Initial packaging