KaMinPar
Shared-Memory and Distributed-Memory Graph Partitioning
Description
KaMinPar
KaMinPar is a shared-memory parallel tool to heuristically solve the graph partitioning problem: divide a graph into k disjoint blocks of roughly equal weight while
minimizing the number of edges between blocks.
Competing algorithms are mostly evaluated for small values of k. If k is large, they often compute highly imbalance solutions, solutions of low quality or suffer excessive running time.
KaMinPar substantially mitigates these problems.
It computes partitions of comparable quality to other high-quality graph partitioning tools while guaranteeing the balance constraint for unweighted input graphs.
Moreover, for large values of k, it is an order of magnitude faster than competing algorithms.
Installation Notes
Requirements
- Compiler: GCC or Clang with C++20 support
- CPU: x86 or ARM
- Operating System: Linux or macOS
- Tools: CMake
- Libraries: Intel TBB, MPI (optional, for the distributed partitioner)
Building KaMinPar
Build KaMinPar following the standard CMake steps:
cmake -B build -DCMAKE_BUILD_TYPE=Release --preset=<default|memory|distributed>
cmake --build build --parallel
Using the Binaries
To partition a graph in METIS format using (d)KaMinPar, run
# KaMinPar: shared-memory partitioning
./build/apps/KaMinPar [-P default|strong|memory|largek] -G <graph filename> -k <number of blocks> -t <nproc> [--epsilon=0.03] [--seed=0]
# dKaMinPar: distributed partitioning
mpirun -n <nproc> ./build/apps/dKaMinPar [-P default|strong] -G <graph filename> -k <number of blocks> [--epsilon=0.03] [--seed=0]
Use the --help flag to see a list of all command line options.
To setup algorithmic tuning parameters, (d)KaMinPar offers configuration presets that can be loaded using the -P <preset> option (view --help for a list of all presets).
Presets can be viewed by using the --dump-config flag; to use a custom preset, load a configuration file using the -C <filename> option, e.g.,
# Write the default preset to a file
./KaMinPar -P default --dump-config > my_preset.ini
# ... modify the configuration by editing my_preset.ini ...
# Use your modified preset
./KaMinPar -C my_preset.ini -G <...> -k <...> -t <...>
For a description of the graph format, please refer to the KaHiP manual.
Using the Libraries
If you are using CMake, you can use the partitioners as libraries by adding this repository as a Git submodule to your project and including it in your CMake configuration:
add_subdirectory(external/KaMinPar)
target_link_libraries(<your-target> PUBLIC KaMinPar::KaMinPar) # Shared-memory partitioning
target_link_libraries(<your-target> PUBLIC KaMinPar::dKaMinPar) # Distributed partitioning
Alternatively, you can use FetchContent:
include(FetchContent)
FetchContent_Declare(KaMinPar
GIT_REPOSITORY https://github.com/KaHIP/KaMinPar.git
GIT_TAG main)
FetchContent_MakeAvailable(KaMinPar)
set_property(DIRECTORY "${KaMinPar_SOURCE_DIR}" PROPERTY EXCLUDE_FROM_ALL YES) # optional
target_link_libraries(<your-target> PUBLIC KaMinPar::KaMinPar) # Shared-memory partitioning
target_link_libraries(<your-target> PUBLIC KaMinPar::dKaMinPar) # Distributed partitioning
Then, call the libraries as follows:
#include <kaminpar-shm/kaminpar.h>
#include <kaminpar-dist/dkaminpar.h>
using namespace kaminpar;
// Call the shared-memory partitioner:
KaMinPar shm(int num_threads, shm::create_default_context());
// KaMinPar::reseed(int seed);
shm.borrow_and_mutate_graph(NodeID n, EdgeID *xadj, NodeID *adjncy, NodeWeight *vwgt = nullptr, EdgeWeight *adjwgt = nullptr);
// alternatively: shm.copy_graph(n, xadj, adjncy, vwgt, adjwgt); will work on a copy of the graph
shm.compute_partition(BlockID number_of_blocks, BlockID *out_partition);
// Call the distributed partitioner:
dKaMinPar dist(MPI_Comm comm, int num_threads, dist::create_default_context());
// dKaMinPar::reseed(int seed);
dist.import_graph(GlobalNodeID *vtxdist, GlobalEdgeID *xadj, GlobalNodeID *adjncy, GlobalNodeWeight *vwvgt = nullptr, GlobalEdgeWeight *adjwgt = nullptr);
dist.compute_partition(BlockID number_of_blocks, BlockID *out_partition);
Please take a look at apps/KaMinPar.cc and apps/dKaMinPar.cc for a full example on how to call the libraries.
Licensing
KaMinPar is free software provided under the MIT License.
If you publish results using our shared-memory partitioner, please acknowledge our work by citing the following paper (preprint, resources):
@InProceedings{DeepMultilevelGraphPartitioning,
author = {Lars Gottesb{\"{u}}ren and
Tobias Heuer and
Peter Sanders and
Christian Schulz and
Daniel Seemaier},
title = {Deep Multilevel Graph Partitioning},
booktitle = {29th Annual European Symposium on Algorithms, {ESA} 2021},
series = {LIPIcs},
volume = {204},
pages = {48:1--48:17},
publisher = {Schloss Dagstuhl - Leibniz-Zentrum f{\"{u}}r Informatik},
year = {2021},
url = {https://doi.org/10.4230/LIPIcs.ESA.2021.48},
doi = {10.4230/LIPIcs.ESA.2021.48}
}
If you publish results using out distributed-memory partitioner, please cite the following paper (preprint, resources):
@InProceedings{DistributedDeepMultilevelGraphPartitioning,
author = {Sanders, Peter and Seemaier, Daniel},
title = {Distributed Deep Multilevel Graph Partitioning},
booktitle = {Euro-Par 2023: Parallel Processing},
year = {2023},
publisher = {Springer Nature Switzerland},
pages = {443--457},
isbn = {978-3-031-39698-4}
}
Reference papers
- 1.Author(s): Peter Sanders, Daniel SeemaierPublished in Proceedings of the 36th ACM Symposium on Parallelism in Algorithms and Architectures by ACM in 2024, page: 443-44510.1145/3626183.3660257
- 2.Author(s): Lars Gottesbüren, Tobias Heuer, Peter Sanders, Christian Schulz, Daniel Seemaier, Petra Mutzel, Rasmus Pagh, Grzegorz HermanPublished by Schloss Dagstuhl – Leibniz-Zentrum für Informatik in 202110.4230/lipics.esa.2021.48
- 1.Author(s): Peter Sanders, Daniel SeemaierPublished by arXiv in 202410.48550/arxiv.2406.03169
- 2.Author(s): Peter Sanders, Daniel SeemaierPublished in 202310.1007/978-3-031-39698-4_30
- 3.Author(s): Peter Sanders, Daniel SeemaierPublished by arXiv in 202310.48550/arxiv.2303.01417
- 4.Author(s): Lars Gottesbüren, Tobias Heuer, Peter Sanders, Christian Schulz, Daniel SeemaierPublished by arXiv in 202110.48550/arxiv.2105.02022
Mentions
- 1.Author(s): Lars Gottesbüren, Nikolai Maas, Peter Sanders, Daniel SeemaierPublished in Proceedings of the 2024 ACM Workshop on Highlights of Parallel Computing by ACM in 2024, page: 19-2010.1145/3670684.3673417
- 2.Author(s): Yasunori Futamura, Ryota Wakaki, Tetsuya SakuraiPublished in 2021 IEEE High Performance Extreme Computing Conference (HPEC) by IEEE in 2021, page: 1-710.1109/hpec49654.2021.9622831
- 1.Author(s): Lars Gottesbüren, Laxman Dhulipala, Rajesh Jayaram, Jakub ŁąckiPublished in Proceedings of the VLDB Endowment by Association for Computing Machinery (ACM) in 2025, page: 1649-166210.14778/3725688.3725696
- 2.Author(s): Pengcheng Wei, Yuan Fang, Zhihao Wen, Zheng Xiao, Binbin ChenPublished in Neural Networks by Elsevier BV in 2025, page: 10682310.1016/j.neunet.2024.106823
- 3.Author(s): Kamal Eyubov, Marcelo Fonseca Faraj, Christian SchulzPublished in Algorithmica by Springer Science and Business Media LLC in 2025, page: 405-42810.1007/s00453-024-01291-8
- 4.Author(s): Pengfei Wang, Shiqi Li, Geng Sun, Changjun Zhou, Chengxi Gao, Sen Qiu, Tiwei Tao, Qiang ZhangPublished in Future Generation Computer Systems by Elsevier BV in 2024, page: 492-50410.1016/j.future.2023.12.008
- 1.Author(s): Alhassan Alshareedah, Amr MagdyPublished in 202510.1145/3748636.3762725
- 2.Author(s): Xuanye Chen, Xiaoshuang Xing, Mengjiao Ou, Jialin Chen, Xiaoyu MaPublished in 202510.1007/978-3-032-10466-3_36
- 3.Author(s): Wan Luan Lee, Shui Jiang, Dian-Lun Lin, Che Chang, Boyang Zhang, Yi-Hua Chung, Ulf Schlichtmann, Tsung-Yi Ho, Tsung-Wei HuangPublished in 202510.1109/dac63849.2025.11132904
- 4.Author(s): Budvin Edippuliarachchi, David Van Komen, Hari SundarPublished in 202510.1145/3712285.3759863
- 5.Author(s): Daniel Salwasser, Daniel Seemaier, Lars Gottesbüren, Peter SandersPublished in 202510.1109/ipdps64566.2025.00033
- 6.Author(s): Tim Niklas Uhl, Matthias Schimek, Lukas Hübner, Demian Hespe, Florian Kurpicz, Daniel Seemaier, Christoph Stelz, Peter SandersPublished in 202410.1109/sc41406.2024.00050
- 7.Author(s): Ismail Bustany, Andrew B. Kahng, Ioannis Koutis, Bodhisatta Pramanik, Zhiang WangPublished in 202310.1109/tcad.2023.3332268
- 8.Author(s): Sebastian SchlagPublished by Karlsruhe in 202010.5445/ir/1000105953