File mpitests.spec of Package mpitests

#
# spec file for package mpitests
#
# Copyright (c) 2025 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%global flavor @BUILD_FLAVOR@%nil

%if "%{flavor}" == ""
%define pack_suff %{nil}
%else
%define pack_suff -%{flavor}
%if !%{mpi_available}
# Disable on non compatible archs
ExclusiveArch:  do_not_build
%endif
%endif

%define osu_ver  6.1
%define imb_ver  2021.3
%define imb_dir  mpi-benchmarks-IMB-v%{imb_ver}
%define osu_dir  osu-micro-benchmarks-%{osu_ver}

%define mpi_home %{mpi_prefix}
%define implem_list_dir %{_datadir}/mpitests/implem.d/

Name:           mpitests%{pack_suff}
%if "%{flavor}" == ""
Summary:        MPI Benchmarks common files
%else
Summary:        MPI Benchmarks and tests for %{flavor}
%endif
License:        BSD-3-Clause AND CPL-1.0
Group:          Development/Languages/Other
Version:        3.2
Release:        0
URL:            http://www.openfabrics.org/downloads.htm
Source0:        http://mvapich.cse.ohio-state.edu/download/mvapich/osu-micro-benchmarks-%{osu_ver}.tar.gz
Source1:        https://github.com/intel/mpi-benchmarks/archive/IMB-v%{imb_ver}.tar.gz
Source3:        mpitests-runtests.sh
Source4:        mpitests-run.sh
Source100:      mpitests-rpmlintrc
Source101:      _multibuild
Patch1:         osu-fix-bad-return-values.patch
Patch2:         imb-cpp-flags.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  dos2unix
BuildRequires:  gcc-c++
%if "%{flavor}" != ""
BuildRequires:  %{flavor}-macros-devel
%{mpi_requires}
BuildRequires:  mpitests = %{version}
Requires:       mpitests = %{version}
%endif

%description
Set of popular MPI benchmarks: IMB v%{imb_ver} OSU benchmarks ver %{osu_ver}

%prep
%setup -c -q
%setup -T -D -a 1 -q
%patch -P 1 -p0
%patch -P 2 -p0

%if 0%{?mpi_available}
%build
%setup_mpi

export CFLAGS="%{optflags}"
export CXXFLAGS="%{optflags}"
export LDFLAGS="%{optflags}"

# IMB Build
make  CC=%{mpi_prefix}/bin/mpicc CXX=%{mpi_prefix}/bin/mpicxx \
     -C %{imb_dir}/ all

# OSU Build
( cd %{osu_dir} && \
  ./configure CC=%{mpi_prefix}/bin/mpicc CXX=%{mpi_prefix}/bin/mpicxx &&
  make all )

%install
# IMB
for imb_test in IMB-EXT IMB-IO IMB-MPI1 IMB-NBC IMB-RMA; do \
	install -D -m0755  %{imb_dir}/$imb_test %{buildroot}%{mpi_prefix}/tests/IMB/$imb_test;\
done
# OSU
make -C %{osu_dir} install prefix=%{buildroot}/usr libexecdir=%{buildroot}%{mpi_prefix}/tests

# Run script
sed -e s/@IMPLEM@/%{flavor}/g -e 's&@MPI_HOME@&%{mpi_prefix}&g' %{S:3}  > %{buildroot}%{mpi_prefix}/tests/runtests.sh
chmod 0755 %{buildroot}%{mpi_prefix}/tests/runtests.sh
mkdir -p %{buildroot}%{implem_list_dir}
echo %{mpi_prefix}/tests/runtests.sh > %{buildroot}%{implem_list_dir}/%{flavor}

%check
%bcond_with mpitests_check
%if %{with mpitests_check}
export SHORT=%{short}
export IMPLEM_LIST_DIR=%{implem_list_dir}
export BUILDROOT=%{buildroot}
%{_datadir}/mpitests/runtests.sh
%else
echo "Skipping tests"
%endif
%endif

%if "%{flavor}" == ""
%install
install -D -m0755 %{S:4} %{buildroot}%{_datadir}/%{name}/runtests.sh
mkdir -p %{buildroot}%{_datadir}/mpitests/implem.d/
%endif

%files
%defattr(-, root, root)
%dir %{_datadir}/mpitests/
%dir %{_datadir}/mpitests/implem.d/
%if "%{flavor}" == ""
%{_datadir}/%{name}/runtests.sh
%else
%doc %{imb_dir}/license/license.txt
%doc %{imb_dir}/license/use-of-trademark-license.txt
%doc %{osu_dir}/COPYRIGHT
%{mpi_prefix}/tests
%{_datadir}/mpitests/implem.d/%{flavor}
%endif

%changelog
openSUSE Build Service is sponsored by