# KaHIP: Karlsruhe High Quality graph Partitioning. The serial library and tools # go in the base package; ParHIP (distributed-memory partitioning, which links # MPI) is built once per MPI implementation under its own prefix, per the Fedora # MPI guidelines, as scotch/ptscotch do. DOLFINx uses ParHIP for mesh partitioning. %bcond openmpi 1 %bcond mpich 1 Name: kahip Version: 3.25 Release: 1%{?dist} Summary: Karlsruhe High Quality graph partitioning License: MIT URL: https://kahip.github.io/ Source: https://github.com/KaHIP/KaHIP/archive/v%{version}/KaHIP-%{version}.tar.gz BuildRequires: cmake >= 3.10 BuildRequires: gcc-c++ BuildRequires: libgomp %if %{with openmpi} BuildRequires: openmpi-devel %endif %if %{with mpich} BuildRequires: mpich-devel %endif %global _description %{expand: KaHIP (Karlsruhe High Quality Partitioning) is a family of graph partitioning programs: KaFFPa (multilevel), KaFFPaE (evolutionary), node separators, node orderings and process mapping, with a C/C++ interface library. ParHIP is its distributed-memory parallel partitioner for very large graphs, used for example by DOLFINx to partition finite element meshes.} %description %_description %package devel Summary: Development files for KaHIP Requires: %{name}%{?_isa} = %{version}-%{release} %description devel Header, pkg-config file and unversioned library link for the serial KaHIP interface library (kaHIP_interface.h). %if %{with openmpi} %package openmpi Summary: KaHIP and ParHIP built against Open MPI Requires: openmpi%{?_isa} %description openmpi %_description This package contains the Open MPI build, including ParHIP. %package openmpi-devel Summary: Development files for KaHIP/ParHIP (Open MPI) Requires: %{name}-openmpi%{?_isa} = %{version}-%{release} Requires: openmpi-devel%{?_isa} %description openmpi-devel Headers, pkg-config files and library links for KaHIP and ParHIP built against Open MPI. %endif %if %{with mpich} %package mpich Summary: KaHIP and ParHIP built against MPICH Requires: mpich%{?_isa} %description mpich %_description This package contains the MPICH build, including ParHIP. %package mpich-devel Summary: Development files for KaHIP/ParHIP (MPICH) Requires: %{name}-mpich%{?_isa} = %{version}-%{release} Requires: mpich-devel%{?_isa} %description mpich-devel Headers, pkg-config files and library links for KaHIP and ParHIP built against MPICH. %endif %prep %autosetup -n KaHIP-%{version} # project() still says 3.24 at the v3.25 tag; the .pc files report it sed -i 's/^project(KaHIP VERSION 3\.24 /project(KaHIP VERSION %{version} /' CMakeLists.txt grep -q 'project(KaHIP VERSION %{version} ' CMakeLists.txt %build # NONATIVEOPTIMIZATIONS: upstream adds -march=native otherwise. # DETERMINISTIC_PARHIP: the same seed gives the same partition, which callers # such as DOLFINx assume (and %%check verifies). OPTIONS=( -DNONATIVEOPTIMIZATIONS=ON -DDETERMINISTIC_PARHIP=ON -DCMAKE_SKIP_INSTALL_RPATH=ON -DCMAKE_BUILD_TYPE=Release ) %global _vpath_builddir %{_target_platform}-serial %cmake ${OPTIONS[@]} -DNOMPI=ON -DCMAKE_INSTALL_LIBDIR=%{_lib} %cmake_build %if %{with openmpi} %{_openmpi_load} %global _vpath_builddir %{_target_platform}-openmpi %cmake ${OPTIONS[@]} -DCMAKE_INSTALL_PREFIX=${MPI_HOME} -DCMAKE_INSTALL_LIBDIR=lib %cmake_build %{_openmpi_unload} %endif %if %{with mpich} %{_mpich_load} %global _vpath_builddir %{_target_platform}-mpich %cmake ${OPTIONS[@]} -DCMAKE_INSTALL_PREFIX=${MPI_HOME} -DCMAKE_INSTALL_LIBDIR=lib %cmake_build %{_mpich_unload} %endif %install # Upstream installs libraries to /lib and headers to /include # whatever CMAKE_INSTALL_*DIR say; move them where Fedora wants them, drop the # static archives, and fix the pkg-config paths to match. %global _vpath_builddir %{_target_platform}-serial %cmake_install if [ "%{_lib}" != lib ]; then mv %{buildroot}%{_prefix}/lib/libkahip.so %{buildroot}%{_libdir}/; fi rm -f %{buildroot}%{_prefix}/lib/*.a %{buildroot}%{_libdir}/*.a mkdir -p %{buildroot}%{_includedir}/kahip mv %{buildroot}%{_includedir}/kaHIP_interface.h %{buildroot}%{_includedir}/kahip/ sed -i 's|^includedir=.*|includedir=%{_includedir}/kahip|' %{buildroot}%{_libdir}/pkgconfig/kahip.pc . /etc/profile.d/modules.sh for mpi in %{?with_openmpi:openmpi} %{?with_mpich:mpich}; do module load mpi/${mpi}-%{_arch} DESTDIR=%{buildroot} cmake --install %{_target_platform}-${mpi} rm -f %{buildroot}${MPI_LIB}/*.a mkdir -p %{buildroot}${MPI_INCLUDE}/kahip mv %{buildroot}${MPI_HOME}/include/*.h %{buildroot}${MPI_INCLUDE}/kahip/ rmdir %{buildroot}${MPI_HOME}/include for pc in %{buildroot}${MPI_LIB}/pkgconfig/*.pc; do sed -i "s|^includedir=.*|includedir=${MPI_INCLUDE}/kahip|" "$pc" done module unload mpi/${mpi}-%{_arch} done %check # Partition the bundled example graphs (32768 vertices each) and check that # every vertex gets a block in range; ParHIP must give the same partition for # the same seed on 2 ranks (DETERMINISTIC_PARHIP). check_partition () { # file nvertices k test "$(wc -l < "$1")" -eq "$2" awk -v k="$3" '$1 < 0 || $1 >= k { bad = 1 } END { exit bad }' "$1" } cd examples %{buildroot}%{_bindir}/kaffpa delaunay_n15.graph --k=4 --preconfiguration=fast --output_filename=serial.part check_partition serial.part 32768 4 %{buildroot}%{_bindir}/graphchecker delaunay_n15.graph export OMPI_MCA_rmaps_base_oversubscribe=1 export PRTE_MCA_rmaps_default_mapping_policy=:oversubscribe . /etc/profile.d/modules.sh for mpi in %{?with_openmpi:openmpi} %{?with_mpich:mpich}; do module load mpi/${mpi}-%{_arch} export LD_LIBRARY_PATH=%{buildroot}${MPI_LIB} for run in 1 2; do mpiexec -n 2 %{buildroot}${MPI_BIN}/parhip rgg_n_2_15_s0.graph --k=4 \ --preconfiguration=fastmesh --seed=7 --save_partition check_partition tmppartition.txtp 32768 4 mv tmppartition.txtp ${mpi}-run${run}.part done cmp ${mpi}-run1.part ${mpi}-run2.part unset LD_LIBRARY_PATH module unload mpi/${mpi}-%{_arch} done %files %license LICENSE %doc README.md %{_bindir}/* # Upstream sets no SOVERSION, so the library is unversioned and has to live in # the runtime package. %{_libdir}/libkahip.so %files devel %{_includedir}/kahip/ %{_libdir}/pkgconfig/kahip.pc %if %{with openmpi} %files openmpi %license LICENSE %{_libdir}/openmpi/bin/* %{_libdir}/openmpi/lib/libkahip.so %{_libdir}/openmpi/lib/libparhip_interface.so %files openmpi-devel %{_includedir}/openmpi-%{_arch}/kahip/ %{_libdir}/openmpi/lib/pkgconfig/*.pc %endif %if %{with mpich} %files mpich %license LICENSE %{_libdir}/mpich/bin/* %{_libdir}/mpich/lib/libkahip.so %{_libdir}/mpich/lib/libparhip_interface.so %files mpich-devel %{_includedir}/mpich-%{_arch}/kahip/ %{_libdir}/mpich/lib/pkgconfig/*.pc %endif %changelog * Sun Oct 25 2026 Morgan Hough - 3.25-1 - New package: KaHIP 3.25 with ParHIP for Open MPI and MPICH, for DOLFINx mesh partitioning. -march=native off, DETERMINISTIC_PARHIP on; %%check partitions the bundled graphs and checks ParHIP is repeatable on 2 ranks.