File scalapack.spec of Package scalapack

#
# spec file for package scalapack
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           scalapack
%define so_ver  2
%define libname lib%{name}%{so_ver}
Version:        2.0.2
Release:        0
Summary:        A subset of LAPACK routines redesigned for heterogenous computing
License:        SUSE-Public-Domain
Group:          Development/Libraries/Parallel
# This is freely distributable without any restrictions.
Url:            http://www.netlib.org/scalapack/
Source0:        http://www.netlib.org/scalapack/scalapack-%{version}.tgz
Source1:        baselibs.conf
# PATCH-FIX-OPENSUSE scalapack-2.0.2-shared-lib.patch
Patch0:         scalapack-2.0.2-shared-lib.patch
# PATCH-FIX-OPENSUSE scalapack-2.0.2-shared-blacs.patch -- build shared blacs library
Patch1:         scalapack-2.0.2-shared-blacs.patch
BuildRequires:  blas-devel
BuildRequires:  gcc-fortran
BuildRequires:  lapack-devel
%if 0%{?sles_version}
BuildRequires:  mvapich2-devel
%endif
BuildRequires:  openmpi-devel
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%if 0%{?sles_version}
%define _mpi_list openmpi mvapich2
%else
%define _mpi_list openmpi
%endif

%description
The ScaLAPACK (or Scalable LAPACK) library includes a subset 
of LAPACK routines redesigned for distributed memory MIMD 
parallel computers. It is currently written in a 
Single-Program-Multiple-Data style using explicit message 
passing for interprocessor communication. It assumes 
matrices are laid out in a two-dimensional block cyclic 
decomposition.

ScaLAPACK is designed for heterogeneous computing and is 
portable on any computer that supports MPI or PVM.

Like LAPACK, the ScaLAPACK routines are based on 
block-partitioned algorithms in order to minimize the frequency 
of data movement between different levels of the memory hierarchy. 
(For such machines, the memory hierarchy includes the off-processor 
memory of other processors, in addition to the hierarchy of registers, 
cache, and local memory on each processor.) The fundamental building 
blocks of the ScaLAPACK library are distributed memory versions (PBLAS) 
of the Level 1, 2 and 3 BLAS, and a set of Basic Linear Algebra 
Communication Subprograms (BLACS) for communication tasks that arise 
frequently in parallel linear algebra computations. In the ScaLAPACK 
routines, all interprocessor communication occurs within the PBLAS and the 
BLACS. One of the design goals of ScaLAPACK was to have the ScaLAPACK 
routines resemble their LAPACK equivalents as much as possible. 


%package -n     %{libname}-openmpi
Summary:        ScaLAPACK libraries compiled against openmpi
Group:          Development/Libraries/Parallel
Obsoletes:      %{name}-openmpi < %{version}
Provides:       %{name}-openmpi = %{version}

%description -n %{libname}-openmpi
The ScaLAPACK (or Scalable LAPACK) library includes a subset
of LAPACK routines redesigned for distributed memory MIMD
parallel computers. It is currently written in a
Single-Program-Multiple-Data style using explicit message
passing for interprocessor communication. It assumes
matrices are laid out in a two-dimensional block cyclic
decomposition.

ScaLAPACK is designed for heterogeneous computing and is
portable on any computer that supports MPI or PVM.

Like LAPACK, the ScaLAPACK routines are based on
block-partitioned algorithms in order to minimize the frequency
of data movement between different levels of the memory hierarchy.
(For such machines, the memory hierarchy includes the off-processor
memory of other processors, in addition to the hierarchy of registers,
cache, and local memory on each processor.) The fundamental building
blocks of the ScaLAPACK library are distributed memory versions (PBLAS)
of the Level 1, 2 and 3 BLAS, and a set of Basic Linear Algebra
Communication Subprograms (BLACS) for communication tasks that arise
frequently in parallel linear algebra computations. In the ScaLAPACK
routines, all interprocessor communication occurs within the PBLAS and the
BLACS. One of the design goals of ScaLAPACK was to have the ScaLAPACK
routines resemble their LAPACK equivalents as much as possible.

This package contains ScaLAPACK	libraries compiled with	openmpi.

%package -n     %{libname}-openmpi-devel
Summary:        Development libraries for ScaLAPACK (openmpi)
Group:          Development/Libraries/Parallel
Requires:       %{libname}-openmpi = %{version}
Requires:       openmpi-devel
Obsoletes:      %{name}-openmpi-devel < %{version}
Provides:       %{name}-openmpi-devel = %{version}

%description -n %{libname}-openmpi-devel
This package contains development libraries for ScaLAPACK, compiled against openmpi.

%package -n     %{libname}-openmpi-devel-static
Summary:        Static libraries for ScaLAPACK (openmpi)
Group:          Development/Libraries/Parallel
Requires:       %{libname}-openmpi-devel = %{version}
Obsoletes:      %{name}-openmpi-devel-static < %{version}
Provides:       %{name}-openmpi-devel-static = %{version}

%description -n %{libname}-openmpi-devel-static
This package contains static libraries for ScaLAPACK, compiled against openmpi.

%package        openmpi-test
Summary:        Test programs for ScaLAPACK (openmpi)
Group:          Development/Libraries/Parallel

%description    openmpi-test
This packages contains the few tests programs for ScaLAPACK compiled against
openmpi. These programs needs data files which are provided with this package
in the directory /usr/share/doc/packages/scalapack-test-openmpi.

%package -n     libblacs%{so_ver}-openmpi
Summary:        Basic Linear Algebra Communication Subprograms
Group:          Development/Libraries/Parallel

%description -n libblacs%{so_ver}-openmpi
The BLACS (Basic Linear Algebra Communication Subprograms) project is
an ongoing investigation whose purpose is to create a linear algebra
oriented message passing interface that may be implemented efficiently
and uniformly across a large range of distributed memory platforms.

The length of time required to implement efficient distributed memory
algorithms makes it impractical to rew/mpi/gccrite programs for every new
parallel machine. The BLACS exist in order to make linear algebra
applications both easier to program and more portable.

%package -n     blacs-devel-headers
Summary:        Development headers for BLACS
Group:          Development/Libraries/Parallel

%description -n blacs-devel-headers
This package contains headers for BLACS.

%package -n     libblacs%{so_ver}-openmpi-devel
Summary:        Development libraries for BLACS (OpenMPI)
Group:          Development/Libraries/Parallel
Requires:       blacs-devel-headers
Requires:       libblacs%{so_ver}-openmpi = %{version}
Requires:       openmpi-devel
Obsoletes:      blacs-openmpi-devel < %{version}
Provides:       blacs-openmpi-devel = %{version}

%description -n libblacs%{so_ver}-openmpi-devel
This package contains development libraries for BLACS, compiled against OpenMPI.

%package -n     libblacs%{so_ver}-openmpi-devel-static
Summary:        Development libraries for BLACS (OpenMPI)
Group:          Development/Libraries/Parallel
Requires:       libblacs%{so_ver}-openmpi-devel = %{version}

%description -n libblacs%{so_ver}-openmpi-devel-static
This package contains static libraries for BLACS, compiled against OpenMPI.

%if 0%{?sles_version}
%package -n     %{libname}-mvapich2
Summary:        ScaLAPACK libraries compiled against mvapich2
Group:          Development/Libraries/Parallel
Obsoletes:      %{name}-mvapich2 < %{version}
Provides:       %{name}-mvapich2 = %{version}

%description -n %{libname}-mvapich2
The ScaLAPACK (or Scalable LAPACK) library includes a subset
of LAPACK routines redesigned for distributed memory MIMD
parallel computers. It is currently written in a
Single-Program-Multiple-Data style using explicit message
passing for interprocessor communication. It assumes
matrices are laid out in a two-dimensional block cyclic
decomposition.

ScaLAPACK is designed for heterogeneous computing and is
portable on any computer that supports MPI or PVM.

Like LAPACK, the ScaLAPACK routines are based on
block-partitioned algorithms in order to minimize the frequency
of data movement between different levels of the memory hierarchy.
(For such machines, the memory hierarchy includes the off-processor
memory of other processors, in addition to the hierarchy of registers,
cache, and local memory on each processor.) The fundamental building
blocks of the ScaLAPACK library are distributed memory versions (PBLAS)
of the Level 1, 2 and 3 BLAS, and a set of Basic Linear Algebra
Communication Subprograms (BLACS) for communication tasks that arise
frequently in parallel linear algebra computations. In the ScaLAPACK
routines, all interprocessor communication occurs within the PBLAS and the
BLACS. One of the design goals of ScaLAPACK was to have the ScaLAPACK
routines resemble their LAPACK equivalents as much as possible.

This package contains ScaLAPACK	libraries compiled with	mvapich2.

%package -n     %{libname}-mvapich2-devel
Summary:        Development libraries for ScaLAPACK (mvapich2)
Group:          Development/Libraries/Parallel
Requires:       %{libname}-mvapich2 = %{version}
Requires:       mvapich2-devel
Obsoletes:      %{name}-mvapich2-devel < %{version}
Provides:       %{name}-mvapich2-devel = %{version}

%description -n %{libname}-mvapich2-devel
This package contains development libraries for ScaLAPACK, compiled against mvapich2.

%package -n     %{libname}-mvapich2-devel-static
Summary:        Static libraries for ScaLAPACK (mvapich2)
Group:          Development/Libraries/Parallel
Requires:       %{libname}-mvapich2-devel = %{version}
Obsoletes:      %{name}-mvapich2-devel-static < %{version}
Provides:       %{name}-mvapich2-devel-static = %{version}

%description -n %{libname}-mvapich2-devel-static
This package contains static libraries for ScaLAPACK, compiled against mvapich2.

%package        mvapich2-test
Summary:        Test programs for ScaLAPACK (openmpi)
Group:          Development/Libraries/Parallel

%description    mvapich2-test
This packages contains the few tests programs for ScaLAPACK compiled against
mvapich2. These programs needs data files which are provided with this package
in the directory /usr/share/doc/packages/scalapack-test-mvapich2.

%package -n     libblacs%{so_ver}-mvapich2
Summary:        Basic Linear Algebra Communication Subprograms
Group:          Development/Libraries/Parallel

%description -n libblacs%{so_ver}-mvapich2
The BLACS (Basic Linear Algebra Communication Subprograms) project is
an ongoing investigation whose purpose is to create a linear algebra
oriented message passing interface that may be implemented efficiently
and uniformly across a large range of distributed memory platforms.

The length of time required to implement efficient distributed memory
algorithms makes it impractical to rew/mpi/gccrite programs for every new
parallel machine. The BLACS exist in order to make linear algebra
applications both easier to program and more portable.

%package -n     libblacs%{so_ver}-mvapich2-devel
Summary:        Development libraries for BLACS (mvapich2)
Group:          Development/Libraries/Parallel
Requires:       blacs-devel-headers
Requires:       libblacs%{so_ver}-mvapich2 = %{version}
Requires:       mvapich2-devel
Obsoletes:      blacs-mvapich2-devel < %{version}
Provides:       blacs-mvapich2-devel = %{version}

%description -n libblacs%{so_ver}-mvapich2-devel
This package contains development libraries for BLACS, compiled against mvapich2.

%package -n     libblacs%{so_ver}-mvapich2-devel-static
Summary:        Development libraries for BLACS (mvapich2)
Group:          Development/Libraries/Parallel
Requires:       libblacs%{so_ver}-mvapich2-devel = %{version}

%description -n libblacs%{so_ver}-mvapich2-devel-static
This package contains static libraries for BLACS, compiled against mvapich2.
%endif

%prep
%setup -q -c -n %{name}-%{version}
%patch0 -p1
%patch1 -p1
cd %{name}-%{version}/
cp SLmake.inc.example SLmake.inc
cd ..
for i in %_mpi_list; do
  cp -a %{name}-%{version} %{name}-%{version}-$i
done

%build
%define dobuild() \
cd %{name}-%{version}-$MPI_COMPILER_NAME ; \
make lib CC=/usr/%_lib/mpi/gcc/$MPI_COMPILER_NAME/bin/mpicc FC=/usr/%_lib/mpi/gcc/$MPI_COMPILER_NAME/bin/mpif90 ; \
cd TESTING/EIG ; \
make FCFLAGS="$RPM_OPT_FLAGS" CC=/usr/%_lib/mpi/gcc/$MPI_COMPILER_NAME/bin/mpicc FC=/usr/%_lib/mpi/gcc/$MPI_COMPILER_NAME/bin/mpif90; \
cd ../LIN; \
make FCFLAGS="$RPM_OPT_FLAGS" CC=/usr/%_lib/mpi/gcc/$MPI_COMPILER_NAME/bin/mpicc FC=/usr/%_lib/mpi/gcc/$MPI_COMPILER_NAME/bin/mpif90; \
cd ../.. ;\
cd ..

RPM_OPT_FLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing"

# Build OpenMPI version
export MPI_COMPILER_NAME=openmpi
%dobuild

# Build mvapich2 version
%if 0%{?sles_version}
export MPI_COMPILER_NAME=mvapich2
%dobuild
%endif

%install
mkdir -p %{buildroot}%{_libdir}
mkdir -p %{buildroot}%{_bindir}

for i in %_mpi_list; do
  mkdir -p %{buildroot}%{_libdir}/mpi/gcc/$i/%_lib
  mkdir -p %{buildroot}%{_libdir}/mpi/gcc/$i/bin/
  pushd %{name}-%{version}-$i
  for f in *.a *.so*; do
    cp -f $f %{buildroot}%{_libdir}/mpi/gcc/$i/%_lib/$f
    cp -f TESTING/x* %{buildroot}%{_libdir}/mpi/gcc/$i/bin
  done
  popd
  pushd %{buildroot}%{_libdir}/mpi/gcc/$i/%_lib
  ln -fs libscalapack.so.%{version} libscalapack.so.%{so_ver}
  ln -fs libscalapack.so.%{version} libscalapack.so
  ln -fs libblacs.so.%{version} libblacs.so.%{so_ver}
  ln -fs libblacs.so.%{version} libblacs.so
  popd
done

# blacs header
mkdir -p %{buildroot}%{_includedir}/blacs/
install -m 644 %{name}-%{version}/BLACS/SRC/Bdef.h %{buildroot}%{_includedir}/blacs/

# Copy docs
cd %{name}-%{version}
cp -f README LICENSE ../

%post -n %{libname}-openmpi -p /sbin/ldconfig

%postun -n %{libname}-openmpi -p /sbin/ldconfig

%post -n libblacs%{so_ver}-openmpi -p /sbin/ldconfig

%postun -n libblacs%{so_ver}-openmpi -p /sbin/ldconfig

%if 0%{?sles_version}
%post -n %{libname}-mvapich2 -p /sbin/ldconfig

%postun -n %{libname}-mvapich2 -p /sbin/ldconfig

%post -n libblacs%{so_ver}-mvapich2 -p /sbin/ldconfig

%postun -n libblacs%{so_ver}-mvapich2 -p /sbin/ldconfig
%endif

%files -n %{libname}-openmpi
%defattr(-,root,root,-)
%doc README LICENSE
%{_libdir}/mpi/gcc/openmpi/%_lib/libscalapack.so.*

%files openmpi-test
%defattr(-,root,root,-)
%doc scalapack-%{version}/TESTING/*.dat
%{_libdir}/mpi/gcc/openmpi/bin/*

%files -n %{libname}-openmpi-devel
%defattr(-,root,root,-)
%{_libdir}/mpi/gcc/openmpi/%_lib/libscalapack.so

%files -n %{libname}-openmpi-devel-static
%defattr(-,root,root,-)
%{_libdir}/mpi/gcc/openmpi/%_lib/libscalapack.a

%files -n blacs-devel-headers
%defattr(-,root,root,-)
%{_includedir}/blacs/

%files -n libblacs%{so_ver}-openmpi
%defattr(-,root,root,-)
%{_libdir}/mpi/gcc/openmpi/%_lib/libblacs.so.*

%files -n libblacs%{so_ver}-openmpi-devel
%defattr(-,root,root,-)
%{_libdir}/mpi/gcc/openmpi/%_lib/libblacs.so

%files -n libblacs%{so_ver}-openmpi-devel-static
%defattr(-,root,root,-)
%{_libdir}/mpi/gcc/openmpi/%_lib/libblacs.a

%if 0%{?sles_version}
%files -n %{libname}-mvapich2
%defattr(-,root,root,-)
%doc README LICENSE
%{_libdir}/mpi/gcc/mvapich2/%_lib/libscalapack.so.*

%files mvapich2-test
%defattr(-,root,root,-)
%doc scalapack-%{version}/TESTING/*.dat
%{_libdir}/mpi/gcc/mvapich2/bin/*

%files -n %{libname}-mvapich2-devel
%defattr(-,root,root,-)
%{_libdir}/mpi/gcc/mvapich2/%_lib/libscalapack.so

%files -n %{libname}-mvapich2-devel-static
%defattr(-,root,root,-)
%{_libdir}/mpi/gcc/mvapich2/%_lib/libscalapack.a

%files -n libblacs%{so_ver}-mvapich2
%defattr(-,root,root,-)
%{_libdir}/mpi/gcc/mvapich2/%_lib/libblacs.so.*

%files -n libblacs%{so_ver}-mvapich2-devel
%defattr(-,root,root,-)
%{_libdir}/mpi/gcc/mvapich2/%_lib/libblacs.so

%files -n libblacs%{so_ver}-mvapich2-devel-static
%defattr(-,root,root,-)
%{_libdir}/mpi/gcc/mvapich2/%_lib/libblacs.a
%endif

%changelog
openSUSE Build Service is sponsored by